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

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-ip/] [core/] [USB_TMC_IP_tb.vhd] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 nussgipfel
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
 
5
---- Uncomment the following library declaration if instantiating
6
---- any Xilinx primitives in this code.
7
library UNISIM;
8
use UNISIM.VComponents.all;
9
 
10
library XilinxCoreLib;
11
 
12
library work;
13
use work.USB_TMC_IP_Defs.all;
14
 
15
entity USB_TMC_IP_tb is
16
 
17
end USB_TMC_IP_tb;
18
 
19
 
20
 
21
architecture simulation of USB_TMC_IP_tb is
22
 
23
  -- components
24
 
25
 
26
component USB_TMC_IP
27
 port (
28
    i_nReset,
29
    i_IFCLK,                                                                     -- GPIF CLK (is Master)
30
         i_SYSCLK,                                                                       -- FPGA System CLK
31
    i_WRU,                              -- write from GPIF
32
    i_RDYU        : in          std_logic;        -- GPIF is ready
33
--       i_ENAIP          : in          std_logic;               -- enable the IP core
34
--       i_RDYD2IP : in         std_logic;                       -- data RDY 2 the IP core   
35
--       i_d2USB   : in         std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
36
--       i_RxD    : in          std_logic;
37
--       o_TxD     : out                std_logic;
38
--       i_Switches: in         std_logic_vector(NUMBER_OF_SW-1 downto 0);
39
    o_WRX,                              -- To write to GPIF
40
    o_RDYX    : out     std_logic;      -- Core is ready
41
--       o_RDYIP   : out        std_logic;               -- IP ready FPGA site
42
--       o_DAVIP   : out        std_logic;               -- Data available for FPGA
43
         o_LEDrx,                            -- controll LED rx __DEB_INFO__
44
         o_LEDtx : out          std_logic;               -- controll LED tx __DEB_INFO__
45
         o_LEDrun  : out        std_logic;      -- controll LED running signalisation __DEB_INFO__
46
--       o_d2FPGA  : out        std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
47
    b_dbus        : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
48
end component USB_TMC_IP;
49
 
50
 
51
 
52
        -- simulation types
53
        type TsimSend is (finish, sending, waiting);
54
  -- simulation constants
55
 
56
 --constant TIME_BASE  : time := 1 ns;
57
 
58
  constant CLK_PERIOD : time := 20 ns;
59
 
60
  constant DATA_BUS_SIZE  : integer                                     := SIZE_DBUS_GPIF;
61
  constant WORD_VALUE1    : std_logic_vector(DATA_BUS_SIZE-1 downto 0) := x"FF00";
62
  constant WORD_VALUE2    : std_logic_vector(DATA_BUS_SIZE-1 downto 0) := x"B030";
63
  constant WORD_VALUE3    : std_logic_vector(DATA_BUS_SIZE-1 downto 0) := x"50A0";
64
  -- signals
65
 
66
  signal sim_clk : std_logic;
67
  signal sim_rst : std_logic;
68
 
69
  signal s_RxD, s_TxD, s_LEDrun, s_LEDrxtx : std_logic;
70
  signal s_Switches : std_logic_vector(NUMBER_OF_SW-1 downto 0);
71
 
72
 
73
  signal sim_1      : boolean := false;
74
 
75
  signal send_data  : TsimSend := finish;
76
 
77
 
78
  signal WRU  : std_logic;
79
  signal RDYU : std_logic;
80
 
81
  signal WRX  : std_logic;
82
  signal RDYX : std_logic;
83
 
84
 
85
  signal data_bus : std_logic_vector(DATA_BUS_SIZE-1 downto 0);
86
 
87
 
88
begin  -- simulation
89
 
90
-------------------------------------------------------------------------------
91
-- Design maps
92
-------------------------------------------------------------------------------
93
 
94
DUT : USB_TMC_IP
95
  port map(
96
    i_nReset   => sim_rst,
97
    i_IFCLK    => sim_clk,                                                                       -- GPIF CLK (is Master)
98
         i_SYSCLK   => sim_clk,                                                                  -- FPGA System CLK
99
    i_WRU      => WRU,                             -- write from GPIF
100
    i_RDYU         => RDYU,        -- GPIF is ready
101
--       i_ENAIP           => ,                  -- enable the IP core
102
--       i_RDYD2IP      => ,     -- data RDY 2 the IP core   
103
--       i_d2USB    => ,   -- FPGA DBUS
104
--       i_RxD     => s_RxD, 
105
--       o_TxD      => s_TxD,
106
--       i_Switches => s_Switches,
107
    o_WRX      => WRX,                        -- To write to GPIF
108
    o_RDYX     => RDYX,   -- Core is ready
109
--       o_RDYIP    => ,         -- IP ready FPGA site
110
--       o_DAVIP    => ,                 -- Data available for FPGA
111
         o_LEDrx    => s_LEDrx,                  -- controll LED rx
112
         o_LEDtx    => s_LEDtx,                  -- controll LED tx
113
         o_LEDrun   => s_LEDrun,        -- controll LED running signalisation
114
--       o_d2FPGA   => ,  -- FPGA DBUS
115
    b_dbus         => data_bus -- bidirect data bus
116
        );
117
 
118
-------------------------------------------------------------------------------
119
-- monitoring FSM
120
------------------------------------------------------------------------------
121
 --state_monitor : entity work.state_monitor(tracing);
122
 
123
-- monitor: process (fsm_clk)
124
--  use std.textio.all;
125
--  file state_file : TEXT open WRITE_MODE is "FSM_STATES.txt";
126
--  
127
-- -- alias fsm_state is byte_com_tb.dut.pr_state;      
128
-- -- alias fsm_clk is DUT.i_IFCLK;
129
--      
130
--  begin  -- process monitor
131
--    if falling_edge(fsm_clk) then
132
--      report to_string(now) & ": " & to_string(fsm_state);
133
--    end if;
134
--  end process monitor;
135
 
136
 
137
-------------------------------------------------------------------------------
138
-- CLK process
139
-------------------------------------------------------------------------------
140
   clk_process: process
141
        begin
142
                sim_clk<='0';
143
                wait for CLK_PERIOD/2;
144
                sim_clk<='1';
145
                wait for CLK_PERIOD/2;
146
                if sim_1 then
147
                        wait;
148
                end if;
149
        end process;
150
 
151
 
152
 
153
        rst_process: process
154
        begin
155
                sim_rst<='0';
156
                wait for CLK_PERIOD;
157
                sim_rst<='1';
158
                wait;
159
        end process;
160
 
161
 
162
 
163
 
164
  assert not(WRX = '1' and RDYX = '1') report "WRX and RDYX are high on the same time" severity warning;
165
 
166
  assert not(WRU = '1' and RDYU = '1') report "WRU and RDYU -> DATA delet" severity note;
167
 
168
 
169
  assert sim_rst = '0' report "system reset" severity note;
170
 
171
-------------------------------------------------------------------------------
172
-- Send Data
173
-------------------------------------------------------------------------------
174
   sendData: process(sim_clk)
175
                variable v_toggle : integer range 0 to 3 := 0;
176
        begin
177
                if rising_edge(sim_clk) then
178
                        if send_data = sending then
179
                                if v_toggle = 0 then
180
                                        v_toggle := 1;
181
                                        data_bus <= WORD_VALUE1;
182
                                elsif v_toggle = 1 then
183
                                        v_toggle := 2;
184
                                        data_bus <= WORD_VALUE2;
185
                                elsif v_toggle = 2 then
186
                                        v_toggle := 0;
187
                                        data_bus <= WORD_VALUE3;
188
                                end if;
189
                        elsif send_data = finish then
190
                                data_bus <= (others => 'Z');
191
 
192
                        end if;
193
                end if;
194
        end process sendData;
195
-------------------------------------------------------------------------------
196
-- stimuli
197
-------------------------------------------------------------------------------
198
 
199
 
200
 
201
  stimuli : process
202
  begin
203
    WRU  <= '0';
204
    RDYU <= '0';
205
         send_data <= finish;
206
 
207
 
208
    assert sim_rst = '1' report "system ready to start" severity note;
209
 
210
    wait for 10 ns;
211
 
212
    assert sim_1 report "Simulation started" severity note;
213
 
214
    wait for  2*CLK_PERIOD;
215
 
216
 
217
    WRU <= '1';
218
 
219
    wait for CLK_PERIOD;
220
 
221
    if(WRX = '1') then
222
      assert WRX = '1' report "WRX : busreservation during a GPIF reservation" severity warning;
223
         else
224
           assert WRX = '0' report "WRX : no buscolision" severity warning;
225
    end if;
226
 
227
         wait for CLK_PERIOD;
228
 
229
         send_data <= sending;
230
 
231
         wait for CLK_PERIOD;
232
 
233
         if(RDYX = '0') then
234
                send_data <= waiting;
235
      assert RDYX = '0' report "RDYX : wait on IP ready ...." severity note;
236
      wait on RDYX until RDYX = '1';
237
                assert RDYX = '1' report "CORE is ready for data >>>" severity note;
238
    else
239
       assert RDYX = '1' report "CORE is ready for data >>>" severity note;
240
    end if;
241
 
242
         for i in 1 to 15 loop -- then wait for a few clock periods...
243
                if RDYX = '1' then
244
                        send_data <= sending;
245
                else
246
                        send_data <= waiting;
247
                end if;
248
                wait until rising_edge(sim_clk);
249
         end loop;
250
 
251
    WRU <= '0';
252
         send_data <= finish;
253
    assert WRU = '0' report "DATA written" severity note;
254
    wait for CLK_PERIOD;
255
 
256
    assert WRU = '0' report "output Z" severity note;
257
 
258
    wait for CLK_PERIOD;
259
 
260
 
261
  --end process writeData;
262
 
263
    if(WRX = '0') then
264
      assert WRX = '0' report "WRX : Waiting on incoming MSG ...." severity note;
265
      wait on WRX until WRX= '1';
266
                RDYU <= '1';
267
                assert WRX = '1' report "CORE send data RQ >>>" severity note;
268
    else
269
                RDYU <= '1';
270
                assert WRX = '1' report "CORE send data RQ >>>" severity note;
271
    end if;
272
 
273
 
274
 
275
                while WRX = '1' loop
276
                        RDYU <= '1';
277
                        send_data <= finish;
278
                        assert WRX = '1' report "CORE sended Data >>>" severity note;
279
                        wait until rising_edge(sim_clk);
280
                end loop;
281
 
282
                RDYU <= '0';
283
 
284
      wait for CLK_PERIOD;
285
 
286
      sim_1 <= false;
287
 
288
                assert sim_1 report "<<< End of simulation >>>" severity note;
289
 
290
  --  end process readData;
291
  end process stimuli;
292
 
293
end simulation;

powered by: WebSVN 2.1.0

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