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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [bench/] [vhdl/] [tb_copyBlaze_ecoSystem_wb-gpio.vhd] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 23 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: tb_copyBlaze_ecoSystem_wb_gpio.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      copyBlaze_ecoSystem testbench
9
--
10
-- File history:
11
-- v1.0: 21/10/11: Creation
12
--
13
-- Targeted device: ProAsic A3P250 VQFP100
14
-- Author: AbdAllah Meziti
15
--------------------------------------------------------------------------------
16
 
17
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.numeric_std.all;
20
 
21
--------------------------------------------------------------------------------
22
-- Entity: tb_copyBlaze_ecoSystem_wb_gpio
23
--
24
-- Description:
25
--      
26
--      REMARQUE:
27
--
28
--      
29
-- History:
30
-- 21/10/11 AM: Creation
31
-- ---------------------
32
-- xx/xx/xx AM: 
33
--                              
34
--------------------------------------------------------------------------------
35
entity tb_copyBlaze_ecoSystem_wb_gpio is
36
end tb_copyBlaze_ecoSystem_wb_gpio;
37
 
38
--------------------------------------------------------------------------------
39
-- Architecture: behavior
40
-- of entity : tb_copyBlaze_ecoSystem_wb_gpio
41
--------------------------------------------------------------------------------
42
architecture behavior of tb_copyBlaze_ecoSystem_wb_gpio is
43
 
44
        --------------------------------------------------------------------------------
45
        -- Définition des constantes
46
        --------------------------------------------------------------------------------
47
        -- Constant for testbench
48
        constant        CST_RESET_LENGTH        : positive := 7;
49
        constant        CST_MAX_CYCLES          : positive := 500;
50
 
51
        constant        CST_FREQ                        : integer       := 4;   -- Mhz
52
        constant        CST_PERIOD                      : time          := 1 us/CST_FREQ;
53
 
54
        -- Constant for the cp_copyBlaze_ecoSystem generic
55
        constant        CST_WIDTH_DATA          : positive := 8;
56
        constant        CST_WIDTH_PC            : positive := 10;
57
        constant        CST_WIDTH_INST          : positive := 18;
58
 
59
        constant        CST_DEPTH_STACK         : positive := 31;
60
        constant        CST_DEPTH_BANC          : positive := 16;
61
        constant        CST_DEPTH_SCRATCH       : positive := 64;
62
 
63
        constant        CST_INT_VECTOR          : std_ulogic_vector(11 downto 0) := x"3FF";
64
 
65
        --------------------------------------------------------------------------------
66
        -- Déclaration des composants
67
        --------------------------------------------------------------------------------
68
        component cp_copyBlaze_ecoSystem
69
                generic
70
                (
71
                        GEN_WIDTH_DATA          : positive := 8;
72
                        GEN_WIDTH_PC            : positive := 10;
73
                        GEN_WIDTH_INST          : positive := 18;
74
 
75
                        GEN_DEPTH_STACK         : positive := 15;       -- Taille (en octet) de la Stack
76
                        GEN_DEPTH_BANC          : positive := 16;       -- Taille (en octet) du Banc Register
77
                        GEN_DEPTH_SCRATCH       : positive := 64;       -- Taille (en octet) du Scratch Pad
78
 
79
                        GEN_INT_VECTOR          : std_ulogic_vector(11 downto 0) := x"3FF"
80
                );
81
                Port (
82
                        --------------------------------------------------------------------------------
83
                        -- Signaux Systeme
84
                        --------------------------------------------------------------------------------
85
                                Clk_i                           : in std_ulogic;
86
                                --Rst_i_n                               : in std_ulogic;
87
 
88
                        --------------------------------------------------------------------------------
89
                        -- Signaux Fonctionels
90
                        --------------------------------------------------------------------------------
91
                                Interrupt_i                     : in std_ulogic;
92
                                Interrupt_Ack_o         : out std_ulogic;
93
 
94
                                IN_PORT_i                       : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
95
                                OUT_PORT_o                      : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
96
                                PORT_ID_o                       : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
97
                                READ_STROBE_o           : out std_ulogic;
98
                                WRITE_STROBE_o          : out std_ulogic;
99
                        --------------------------------------------------------------------------------
100
                        -- Signaux WishBone
101
                        --------------------------------------------------------------------------------
102
                                Freeze_i                        : in std_ulogic;
103
 
104
                        --------------------------------------------------------------------------------
105
                        -- Signaux Wishbone Interface
106
                        --------------------------------------------------------------------------------
107
                                --RST_I                         : in    std_ulogic;
108
                                --CLK_I                         : in    std_ulogic;
109
 
110
                                ADR_O                           : out   std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
111
                                DAT_I                           : in    std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
112
                                DAT_O                           : out   std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
113
                                WE_O                            : out   std_ulogic;
114
                                SEL_O                           : out   std_ulogic_vector(1 downto 0);
115
 
116
                                STB_O                           : out   std_ulogic;
117
                                ACK_I                           : in    std_ulogic;
118
                                CYC_O                           : out   std_ulogic
119
                );
120
        end component;
121
 
122
        component wb_gpio_08
123
        port (
124
                        clk      : in  std_ulogic;
125
                        reset    : in  std_ulogic;
126
                        -- Wishbone bus
127
                        wb_adr_i : in  std_ulogic_vector(7 downto 0);
128
                        wb_dat_i : in  std_ulogic_vector(7 downto 0);
129
                        wb_dat_o : out std_ulogic_vector(7 downto 0);
130
                        wb_cyc_i : in  std_ulogic;
131
                        wb_stb_i : in  std_ulogic;
132
                        wb_ack_o : out std_ulogic;
133
                        wb_we_i  : in  std_ulogic;
134
                        -- I/O ports
135
                        iport    : in  std_ulogic_vector(7 downto 0);
136
                        oport    : out std_ulogic_vector(7 downto 0)
137
                );
138
        end component;
139
 
140
        --------------------------------------------------------------------------------
141
        -- Définition des signaux interne
142
        --------------------------------------------------------------------------------
143
        signal iClk                             : std_ulogic := '0';
144
        signal iReset                   : std_ulogic;
145
        signal iResetN                  : std_ulogic;
146
 
147
        signal iInterrupt               : std_ulogic;
148
        signal iInterrupt_Ack   : std_ulogic;
149
        signal iIn_port                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
150
        signal iOut_port                : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
151
        signal iPort_id                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
152
        signal iRead_strobe             : std_ulogic;
153
        signal iWrite_strobe    : std_ulogic;
154
 
155
        signal iFreeze                  : std_ulogic := '0'; -- Freeze the processor
156
 
157
        signal iReset_counter   : natural range 0 to CST_RESET_LENGTH := CST_RESET_LENGTH;       -- VERY BAD SOLUTION
158
        signal iCounter                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
159
        signal iWaveForms               : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
160
        signal iExtIntEvent             : std_ulogic := '0';
161
 
162
        signal iWbSTB                   : std_ulogic;
163
        signal iWbCYC                   : std_ulogic;
164
        signal iWbACK                   : std_ulogic;-- := '0';--'0';
165
        signal iWbWE                    : std_ulogic;-- := '0';--'0';
166
 
167
        signal iWbDAT_I                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
168
        signal iWbDAT_O                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
169
        signal iWbADR                   : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
170
 
171
begin
172
 
173
        -- ***************************************** --
174
        -- UUT : Unit Under Test : cp_copyBlaze_ecoSystem --
175
        -- ***************************************** --
176
        uut: cp_copyBlaze_ecoSystem
177
                generic map
178
                (
179
                        GEN_WIDTH_DATA          => CST_WIDTH_DATA,
180
                        GEN_WIDTH_PC            => CST_WIDTH_PC,
181
                        GEN_WIDTH_INST          => CST_WIDTH_INST,
182
 
183
                        GEN_DEPTH_STACK         => CST_DEPTH_STACK,
184
                        GEN_DEPTH_BANC          => CST_DEPTH_BANC,
185
                        GEN_DEPTH_SCRATCH       => CST_DEPTH_SCRATCH,
186
 
187
                        GEN_INT_VECTOR          => CST_INT_VECTOR
188
                )
189
                Port map
190
                (
191
                        --------------------------------------------------------------------------------
192
                        -- Signaux Systeme
193
                        --------------------------------------------------------------------------------
194
                                Clk_i                           => iClk,
195
                                --Rst_i_n                               : in std_ulogic;
196
 
197
                        --------------------------------------------------------------------------------
198
                        -- Signaux Fonctionels
199
                        --------------------------------------------------------------------------------
200
                                Interrupt_i                     => iInterrupt,
201
                                Interrupt_Ack_o         => iInterrupt_Ack,
202
 
203
                                IN_PORT_i                       => iIn_port,
204
                                OUT_PORT_o                      => iOut_port,
205
                                PORT_ID_o                       => iPort_id,
206
                                READ_STROBE_o           => iRead_strobe,
207
                                WRITE_STROBE_o          => iWrite_strobe,
208
                        --------------------------------------------------------------------------------
209
                        -- Signaux WishBone
210
                        --------------------------------------------------------------------------------
211
                                Freeze_i                        => iFreeze,
212
 
213
                        --------------------------------------------------------------------------------
214
                        -- Signaux Wishbone Interface
215
                        --------------------------------------------------------------------------------
216
                                --RST_I                         => iReset,
217
                                --CLK_I                         => Clk_i,
218
 
219
                                ADR_O                           => iWbADR,
220
                                DAT_I                           => iWbDAT_I,--(others => '0'),
221
                                DAT_O                           => iWbDAT_O,--open,
222
                                WE_O                            => iWbWE,--open,
223
                                SEL_O                           => open,
224
 
225
                                STB_O                           => iWbSTB,
226
                                ACK_I                           => iWbACK,
227
                                CYC_O                           => iWbCYC
228
                );
229
 
230
        wb_gpio : wb_gpio_08
231
        port map (
232
                        clk      => iClk, --: in  std_ulogic;
233
                        reset    => iReset, --: in  std_ulogic;
234
                        -- Wishbone bus
235
                        wb_adr_i => iWbADR, --: in  std_ulogic_vector(7 downto 0);
236
                        wb_dat_i => iWbDAT_O, --: in  std_ulogic_vector(7 downto 0);
237
                        wb_dat_o => iWbDAT_I, --: out std_ulogic_vector(7 downto 0);
238
                        wb_cyc_i => iWbCYC, --: in  std_ulogic;
239
                        wb_stb_i => iWbSTB, --: in  std_ulogic;
240
                        wb_ack_o => iWbACK, --: out std_ulogic;
241
                        wb_we_i  => iWbWE, --: in  std_ulogic;
242
                        -- I/O ports
243
                        iport    => x"45", --: in  std_ulogic_vector(7 downto 0);
244
                        oport    => open --: out std_ulogic_vector(7 downto 0)
245
                );
246
 
247
        --------------------------------------------------------------------------------
248
        -- Process : Interrupt_Proc
249
        -- Description: Interrupt Logic for cp_copyBlaze_ecoSystem
250
        --------------------------------------------------------------------------------
251
        Interrupt_Proc: process(iReset, iClk)
252
        begin
253
                if (iReset='0') then
254
                        iInterrupt      <= '0';
255
                elsif ( rising_edge(iClk) ) then
256
                        if (iExtIntEvent='1') then
257
                                iInterrupt      <= '1';
258
                        elsif (iInterrupt_Ack='1') then
259
                                iInterrupt      <= '0';
260
                        end if;
261
                end if;
262
        end process Interrupt_Proc;
263
 
264
        --------------------------------------------------------------------------------
265
        -- Process : Reset_Proc
266
        -- Description: Reset Logic for cp_copyBlaze_ecoSystem
267
        --------------------------------------------------------------------------------
268
        Reset_Proc: process(iClk)
269
        begin
270
                -- delayed iReset circuit
271
                if ( rising_edge(iClk) ) then
272
                        if ( iReset_counter = 0 ) then
273
                                iReset                  <=      '1';
274
                        else
275
                                iReset                  <=      '0';
276
                                iReset_counter  <=      iReset_counter - 1;
277
                        end if;
278
                end if;
279
        end process Reset_Proc;
280
        iResetN <=      not(iReset);
281
 
282
        --------------------------------------------------------------------------------
283
        -- Process : IO_Proc
284
        -- Description: adding the output registers to the processor
285
        --------------------------------------------------------------------------------
286
        IO_Proc: process(iClk)
287
        begin
288
                -- waveform register at iAddress 02
289
                if ( rising_edge(iClk) ) then
290
                        if (iPort_id(1)='1' and iWrite_strobe='1') then
291
                                iWaveForms <= iOut_port;
292
                        end if;
293
                end if;
294
 
295
                -- Interrupt iCounter register at iAddress 04
296
                if ( rising_edge(iClk) ) then
297
                        if (iPort_id(2)='1' and iWrite_strobe='1') then
298
                                iCounter <= iOut_port;
299
                        end if;
300
                end if;
301
 
302
        end process IO_Proc;
303
 
304
        -- ********************* --
305
        -- STIMULIS FOR THE TEST --
306
        -- ********************* --
307
        -- Unused inputs on processor
308
        iIn_port        <= x"28";
309
 
310
        --iClk <= not iClk after 0.5 * CST_PERIOD;
311
        --------------------------------------------------------------------------------
312
        -- Process : INT_Proc
313
        -- Description: Nominal 100MHz clock which also defines number of cycles in simulation 
314
        --------------------------------------------------------------------------------
315
        INT_Proc : process
316
                variable max_cycles             : integer :=    CST_MAX_CYCLES;
317
                variable cycle_count    : integer :=    0;
318
        begin
319
                -- Define the clock cycles and the clock cycle iCounter
320
                while cycle_count < max_cycles loop
321
 
322
--                      wait until rising_edge(iClk) ;
323
                                iClk <= '0';
324
                        wait for CST_PERIOD;
325
                                iClk <= '1';
326
                                cycle_count := cycle_count + 1;
327
                        wait for CST_PERIOD;
328
 
329
 
330
                        --Now define stimulus relative to a given clock cycle
331
                        case cycle_count is
332
                                -- *************** --
333
                                -- INTERRUPT EVENT --
334
                                -- *************** --
335
                                --when 30 =>    iExtIntEvent <= '1'; 
336
                                --when 34 =>    iExtIntEvent <= '0'; 
337
                --
338
                                --when 67 =>    iExtIntEvent <= '1'; -- Take care when the "iIE" bit is not set. In this case how to manage Interrupt_Ack_o
339
                                --when 71 =>    iExtIntEvent <= '0'; 
340
 
341
                                when 300 =>             iExtIntEvent <= '1';
342
                                when 304 =>             iExtIntEvent <= '0';
343
 
344
                                -- ************ --
345
                                -- FREEZE EVENT --
346
                                -- ************ --
347
                                when 130 =>             iFreeze <= '1';
348
                                when 150 =>             iFreeze <= '0';
349
 
350
                                -- ****** --
351
                                -- WB ACK --
352
                                -- ****** --
353
                                --when 420      =>              iWbACK  <= '1';
354
                                --when 420+1    =>              iWbACK  <= '0';
355
 
356
                                when others =>  iExtIntEvent <= iExtIntEvent;   -- hold last defined value
357
 
358
                        end case;
359
 
360
                end loop;
361
 
362
                wait; -- end of simulation.
363
 
364
        end process INT_Proc;
365
 
366
end behavior;

powered by: WebSVN 2.1.0

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