OpenCores
URL https://opencores.org/ocsvn/wrimm/wrimm/trunk

Subversion Repositories wrimm

[/] [wrimm/] [trunk/] [WrimmTestBench.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 barryw
--Propery of Tecphos Inc.  See License.txt for license details
2
--Latest version of all project files available at http://opencores.org/project,wrimm
3
--See WrimmManual.pdf for the Wishbone Datasheet and implementation details.
4
--See wrimm subversion project for version history
5
 
6
library ieee;
7
  use ieee.NUMERIC_STD.all;
8 8 barryw
  use ieee.std_logic_1164.all;
9
  use std.textio.all;
10 6 barryw
 
11
  use work.WrimmPackage.all;
12 5 barryw
 
13 8 barryw
entity WrimmTestBench is
14
end WrimmTestBench;
15
 
16
architecture TbArch of WrimmTestBench is
17 5 barryw
 
18 8 barryw
  component Wrimm is
19
    port (
20
      WbClk             : in  std_logic;
21
      WbRst             : out std_logic;
22
      WbMasterIn        : in  WbMasterOutArray; --Signals from Masters
23
      WbMasterOut       : out WbSlaveOutArray;  --Signals to Masters
24
      --WbSlaveIn         : out WbMasterOutArray;
25
      --WbSlaveOut        : in  WbSlaveOutArray;
26
      StatusRegs        : in  StatusArrayType;
27
      SettingRegs       : out SettingArrayType;
28
      SettingRsts       : in  SettingArrayBitType;
29
      Triggers          : out TriggerArrayType;
30
      TriggerClr        : in  TriggerArrayType;
31
      rstZ              : in  std_logic);        --Asynchronous reset
32
  end component Wrimm;
33
 
34
  signal wbMastersOut           : WbSlaveOutArray;
35
  signal wbMastersIn            : WbMasterOutArray;
36
  signal statusRegs             : StatusArrayType;
37
  signal settingRegs            : SettingArrayType;
38
  signal settingRsts            : SettingArrayBitType;
39
  signal triggers               : TriggerArrayType;
40
  signal triggerClrs            : TriggerArrayType;
41
 
42
  signal rstZ                   : std_logic;
43
  signal WishboneClock          : std_logic;
44
  signal WishBoneReset          : std_logic;
45 5 barryw
 
46
  constant clkPeriod          : time := 0.01 us; --100 MHz
47
 
48 8 barryw
begin
49
  procClk: process
50
  begin
51
    if WishBoneClock='1' then
52
      WishBoneClock <= '0';
53
    else
54
      WishBoneClock <= '1';
55
    end if;
56
    wait for clkPeriod/2;
57
  end process procClk;
58
 
59
  procRstZ: process
60
  begin
61
    rstZ  <= '0';
62
    wait for 10 ns;
63
    rstZ  <= '1';
64
    wait;
65
  end process procRstZ;
66
 
67
  instWrimm: Wrimm
68
  port map(
69
    WbClk             => WishboneClock,
70
    WbRst             => WishboneReset,
71
    WbMasterIn        => wbMastersIn,
72
    WbMasterOut       => wbMastersOut,
73
    --WbSlaveIn       => ,
74
    --WbSlaveOut      => ,
75
    StatusRegs        => statusRegs,
76
    SettingRegs       => settingRegs,
77
    SettingRsts       => settingRsts,
78
    Triggers          => triggers,
79
    TriggerClr        => triggerClrs,
80
    rstZ              => rstZ);
81
 
82
  procStatusStim: process(WishboneClock) is
83
          variable statusCount : unsigned (0 to WbDataBits-1) := (Others=>'0');
84
        begin
85
                if rising_edge(WishboneClock) then
86
                        loopStatusAssign: for i in StatusFieldType loop
87
                                statusRegs(i) <= std_logic_vector(statusCount);
88
                                statusCount     := statusCount + 1;     --actual values don't matter, just generating unique values.
89
                        end loop loopStatusAssign;
90
                end if; --Clk
91
        end process procStatusStim;
92
 
93
        procStatusVerify: process(WishboneClock) is
94
                variable L : line;
95
        begin
96
                if rising_edge(WishBoneClock) then
97
                        loopMasters: for i in WbMasterType loop
98
                                if wbMastersOut(i).Ack='1' and wbMastersIn(i).WrEn='0' then --valid Ack to Read request
99
                                        loopStatusRegs: for j in StatusFieldType loop
100
                                                        if StatusParams(j).Address=wbMastersIn(i).Addr then             --correct address
101
                                                                report "Evaluating Status Read" severity NOTE;
102
                                                                assert (statusRegs(j)=wbMastersOut(i).data) report "Invalid Status Register Read" severity Warning;
103
                                                        end if;
104
                                        end loop loopStatusRegs;
105
                                end if; -- valid Ack
106
                        end loop loopMasters;
107
                end if; --Clk
108
        end process procStatusVerify;
109
 
110
        procSettingResets: process(WishboneClock) is
111
                variable resetVector    : unsigned(0 to settingRsts'length-1) := (Others=>'0');
112
                variable resetCount             : integer := 0;
113
                variable resetIndex             : integer := 0;
114
        begin
115
                if rising_edge(WishboneClock) then
116
                        if resetCount=20 then
117
                                resetCount      := 0;
118
                                resetVector := resetVector+1;
119
                                resetIndex      := 0;
120
                                loopSetRsts: for i in SettingFieldType loop
121
                                        settingRsts(i)  <= resetVector(resetIndex);
122
                                        resetIndex := resetIndex + 1;
123
                                end loop loopSetRsts;
124
                        else
125
                                resetCount      := resetCount + 1;
126
                                settingRsts     <= (Others=>'0');
127
                        end if;
128
                end if; --Clk
129
        end process procSettingResets;
130
 
131
        procSettingMonitor: process(WishboneClock,rstZ) is
132
                variable settingTBRegs  : SettingArrayType;
133
        begin
134
                if (rstZ='0') then
135
                        loopSettingRstZ: for i in SettingFieldType loop
136
                                settingTBRegs(i) := SettingParams(i).Default;
137
                        end loop loopSettingRstZ;
138
                elsif rising_edge(WishboneClock) then
139
                        loopSettingRegsCheck : for k in SettingFieldType loop
140
                                assert (settingTBRegs(k)=settingRegs(k))        report "Setting Reg Mismatch" severity Warning;
141
                        end loop loopSettingRegsCheck;
142
                        loopMasters: for i in WbMasterType loop                                                                                                 --valid Ack
143
                                if wbMastersOut(i).Ack='1' then
144
                                        if wbMastersIn(i).WrEn='1' then                                                                                                                 -- Write request
145
                                                loopSettingWriteRegs: for j in SettingFieldType loop
146
                                                        if SettingParams(j).Address=wbMastersIn(i).Addr then            --valid setting address
147
                                                                report "Writing Setting Reg";
148
                                                                settingTBRegs(j) := wbMastersIn(i).data;
149
                                                        end if; --Address match
150
                                                end loop loopSettingWriteRegs;
151
                                        else                                                                                                                                                                                                                            -- Read request
152
                                                loopSettingReadRegs: for j in SettingFieldType loop
153
                                                        if SettingParams(j).Address=wbMastersIn(i).Addr then            --valid setting address
154
                                                                report "Reading Setting Reg";
155
                                                                assert (wbMastersOut(i).data=settingTBRegs(j)) report "Setting Read Mismatch" severity Warning;
156
                                                        end if; --Address match
157
                                                end loop loopSettingReadRegs;
158
                                        end if; --WrEn
159
                                end if; --Ack to write
160
                        end loop loopMasters;
161
                        loopSettingResets: for i in SettingFieldType loop
162
                                if settingRsts(i)='1' then
163
                                        settingTBRegs(i) := SettingParams(i).Default;
164
                                end if;
165
                        end loop loopSettingResets;
166
                end if; --Clk
167
        end process procSettingMonitor;
168 5 barryw
 
169 8 barryw
  procMasterStim: process(WishboneClock,rstZ) is
170
    variable rCount             : unsigned(0 to WbAddrBits) := (Others=>'0');
171
    variable rData              : unsigned(0 to WbDataBits-1) := (Others=>'0');
172
    variable burstCount : integer := 5;
173
    variable idleCount  : integer := 4;
174
  begin
175
    if rising_edge(WishboneClock) then
176
                        rData                           := rData + 1;
177
      if WbMastersOut(Q).Ack='1' or WbMastersOut(Q).Rty='1' or WbMastersOut(Q).Err='1' then
178
        rCount                  := rCount + 1;
179
              burstCount        := burstcount - 1;
180
              if burstCount=0 then
181
                      idleCount := 3;
182
                    end if;
183
      elsif idleCount=0 then
184
        if burstCount=0 then
185
          burstCount := 4;
186
        end if;
187
      else
188
        idleCount := idleCount - 1;
189
      end if;
190
 
191
                        wbMastersIn(Q).Data <= std_logic_vector(rData);
192
            wbMastersIn(Q).Addr <= std_logic_vector(rCount(1 to WbAddrBits));
193
            wbMastersIn(Q).WrEn <= rCount(0);    --read then write
194
            if burstCount=0 then
195
                                wbMastersIn(Q).Strobe <= '0';
196
                          wbMastersIn(Q).Cyc            <= '0';
197
                        else
198
                                wbMastersIn(Q).Strobe <= '1';
199
                                wbMastersIn(Q).Cyc              <= '1';
200
                  end if;
201
    end if; --Clk
202
  end process procMasterStim;
203 5 barryw
 
204 8 barryw
end TbArch;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.