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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [bench/] [vhdl/] [tb_copyBlaze_ecoSystem_wb-sram.vhd] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: tb_copyBlaze_ecoSystem_wb-sram.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      copyBlaze_ecoSystem testbench
9
--
10
-- File history:
11
-- v1.0: 08/12/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_sram
23
--
24
-- Description:
25
--      
26
--      REMARQUE:
27
--
28
--      
29
-- History:
30
-- 08/12/11 AM: Creation
31
-- ---------------------
32
-- xx/xx/xx AM: 
33
--                              
34
--------------------------------------------------------------------------------
35
entity tb_copyBlaze_ecoSystem_wb_sram is
36
end tb_copyBlaze_ecoSystem_wb_sram;
37
 
38
--------------------------------------------------------------------------------
39
-- Architecture: behavior
40
-- of entity : tb_copyBlaze_ecoSystem_wb_sram
41
--------------------------------------------------------------------------------
42
architecture behavior of tb_copyBlaze_ecoSystem_wb_sram 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_sram
123
                generic
124
                (
125
                        GEN_WIDTH_DATA          : positive := 8;
126
                        GEN_DEPTH_MEM           : positive := 64
127
                );
128
                port
129
                (
130
                        clk      : in  std_ulogic;
131
                        reset    : in  std_ulogic;
132
                        -- Wishbone bus
133
                        wb_adr_i : in  std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
134
                        wb_dat_i : in  std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
135
                        wb_dat_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
136
                        wb_cyc_i : in  std_ulogic;
137
                        wb_stb_i : in  std_ulogic;
138
                        wb_ack_o : out std_ulogic;
139
                        wb_we_i  : in  std_ulogic
140
                );
141
        end component;
142
 
143
        --------------------------------------------------------------------------------
144
        -- Définition des signaux interne
145
        --------------------------------------------------------------------------------
146
        signal iClk                             : std_ulogic := '0';
147
        signal iReset                   : std_ulogic;
148
        signal iResetN                  : std_ulogic;
149
 
150
        signal iInterrupt               : std_ulogic;
151
        signal iInterrupt_Ack   : std_ulogic;
152
        signal iIn_port                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
153
        signal iOut_port                : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
154
        signal iPort_id                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
155
        signal iRead_strobe             : std_ulogic;
156
        signal iWrite_strobe    : std_ulogic;
157
 
158
        signal iFreeze                  : std_ulogic := '0'; -- Freeze the processor
159
 
160
        signal iReset_counter   : natural range 0 to CST_RESET_LENGTH := CST_RESET_LENGTH;       -- VERY BAD SOLUTION
161
        signal iCounter                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
162
        signal iWaveForms               : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
163
        signal iExtIntEvent             : std_ulogic;-- := '0';
164
 
165
        signal iWbSTB                   : std_ulogic;
166
        signal iWbCYC                   : std_ulogic;
167
        signal iWbACK                   : std_ulogic;
168
        signal iWbWE                    : std_ulogic;
169
 
170
        signal iWbDAT_I                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
171
        signal iWbDAT_O                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
172
        signal iWbADR                   : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
173
 
174
begin
175
 
176
        -- ***************************************** --
177
        -- UUT : Unit Under Test : cp_copyBlaze_ecoSystem --
178
        -- ***************************************** --
179
        uut: cp_copyBlaze_ecoSystem
180
                generic map
181
                (
182
                        GEN_WIDTH_DATA          => CST_WIDTH_DATA,
183
                        GEN_WIDTH_PC            => CST_WIDTH_PC,
184
                        GEN_WIDTH_INST          => CST_WIDTH_INST,
185
 
186
                        GEN_DEPTH_STACK         => CST_DEPTH_STACK,
187
                        GEN_DEPTH_BANC          => CST_DEPTH_BANC,
188
                        GEN_DEPTH_SCRATCH       => CST_DEPTH_SCRATCH,
189
 
190
                        GEN_INT_VECTOR          => CST_INT_VECTOR
191
                )
192
                Port map
193
                (
194
                        --------------------------------------------------------------------------------
195
                        -- Signaux Systeme
196
                        --------------------------------------------------------------------------------
197
                                Clk_i                           => iClk,
198
                                --Rst_i_n                               : in std_ulogic;
199
 
200
                        --------------------------------------------------------------------------------
201
                        -- Signaux Fonctionels
202
                        --------------------------------------------------------------------------------
203
                                Interrupt_i                     => iExtIntEvent,--iInterrupt,
204
                                Interrupt_Ack_o         => iInterrupt_Ack,
205
 
206
                                IN_PORT_i                       => iIn_port,
207
                                OUT_PORT_o                      => iOut_port,
208
                                PORT_ID_o                       => iPort_id,
209
                                READ_STROBE_o           => iRead_strobe,
210
                                WRITE_STROBE_o          => iWrite_strobe,
211
                        --------------------------------------------------------------------------------
212
                        -- Signaux WishBone
213
                        --------------------------------------------------------------------------------
214
                                Freeze_i                        => iFreeze,
215
 
216
                        --------------------------------------------------------------------------------
217
                        -- Signaux Wishbone Interface
218
                        --------------------------------------------------------------------------------
219
                                --RST_I                         => iReset,
220
                                --CLK_I                         => Clk_i,
221
 
222
                                ADR_O                           => iWbADR,
223
                                DAT_I                           => iWbDAT_I,
224
                                DAT_O                           => iWbDAT_O,
225
                                WE_O                            => iWbWE,
226
                                SEL_O                           => open,
227
 
228
                                STB_O                           => iWbSTB,
229
                                ACK_I                           => iWbACK,
230
                                CYC_O                           => iWbCYC
231
                );
232
 
233
        uut_wb_sram : wb_sram
234
                generic map
235
                (
236
                        GEN_WIDTH_DATA          => CST_WIDTH_DATA,
237
                        GEN_DEPTH_MEM           => 64
238
                )
239
                port map
240
                (
241
                        clk      => iClk,
242
                        reset    => iReset,
243
                        -- Wishbone bus
244
                        wb_adr_i => iWbADR,
245
                        wb_dat_i => iWbDAT_O,
246
                        wb_dat_o => iWbDAT_I,
247
                        wb_cyc_i => iWbCYC,
248
                        wb_stb_i => iWbSTB,
249
                        wb_ack_o => iWbACK,
250
                        wb_we_i  => iWbWE
251
                );
252
 
253
        --------------------------------------------------------------------------------
254
        -- Process : Interrupt_Proc
255
        -- Description: Interrupt Logic for cp_copyBlaze_ecoSystem
256
        --------------------------------------------------------------------------------
257
        Interrupt_Proc: process(iReset, iClk)
258
        begin
259
                if (iReset='0') then
260
                        iInterrupt      <= '0';
261
                elsif ( rising_edge(iClk) ) then
262
                        if (iExtIntEvent='1') then
263
                                iInterrupt      <= '1';
264
                        elsif (iInterrupt_Ack='1') then
265
                                iInterrupt      <= '0';
266
                        end if;
267
                end if;
268
        end process Interrupt_Proc;
269
 
270
        --------------------------------------------------------------------------------
271
        -- Process : Reset_Proc
272
        -- Description: Reset Logic for cp_copyBlaze_ecoSystem
273
        --------------------------------------------------------------------------------
274
        Reset_Proc: process(iClk)
275
        begin
276
                -- delayed iReset circuit
277
                if ( rising_edge(iClk) ) then
278
                        if ( iReset_counter = 0 ) then
279
                                iReset                  <=      '1';
280
                        else
281
                                iReset                  <=      '0';
282
                                iReset_counter  <=      iReset_counter - 1;
283
                        end if;
284
                end if;
285
        end process Reset_Proc;
286
        iResetN <=      not(iReset);
287
 
288
        --------------------------------------------------------------------------------
289
        -- Process : IO_Proc
290
        -- Description: adding the output registers to the processor
291
        --------------------------------------------------------------------------------
292
        IO_Proc: process(iClk)
293
        begin
294
                -- waveform register at iAddress 02
295
                if ( rising_edge(iClk) ) then
296
                        if (iPort_id(1)='1' and iWrite_strobe='1') then
297
                                iWaveForms <= iOut_port;
298
                        end if;
299
                end if;
300
 
301
                -- Interrupt iCounter register at iAddress 04
302
                if ( rising_edge(iClk) ) then
303
                        if (iPort_id(2)='1' and iWrite_strobe='1') then
304
                                iCounter <= iOut_port;
305
                        end if;
306
                end if;
307
 
308
        end process IO_Proc;
309
 
310
        -- ********************* --
311
        -- STIMULIS FOR THE TEST --
312
        -- ********************* --
313
        -- Unused inputs on processor
314
        iIn_port        <= x"28";
315
 
316
        --iClk <= not iClk after 0.5 * CST_PERIOD;
317
        --------------------------------------------------------------------------------
318
        -- Process : INT_Proc
319
        -- Description: Nominal 100MHz clock which also defines number of cycles in simulation 
320
        --------------------------------------------------------------------------------
321
        INT_Proc : process
322
                variable max_cycles             : integer :=    CST_MAX_CYCLES;
323
                variable cycle_count    : integer :=    0;
324
        begin
325
                -- Define the clock cycles and the clock cycle iCounter
326
                while cycle_count < max_cycles loop
327
 
328
--                      wait until rising_edge(iClk) ;
329
                                iClk <= '0';
330
                        wait for CST_PERIOD;
331
                                iClk <= '1';
332
                                cycle_count := cycle_count + 1;
333
                        wait for CST_PERIOD;
334
 
335
 
336
                        --Now define stimulus relative to a given clock cycle
337
                        case cycle_count is
338
                                -- *************** --
339
                                -- INTERRUPT EVENT --
340
                                -- *************** --
341
                                --when 30 =>    iExtIntEvent <= '1'; 
342
                                --when 34 =>    iExtIntEvent <= '0'; 
343
                --
344
                                --when 67 =>    iExtIntEvent <= '1'; -- Take care when the "iIE" bit is not set. In this case how to manage Interrupt_Ack_o
345
                                --when 71 =>    iExtIntEvent <= '0'; 
346
 
347
                                --when 300 =>           iExtIntEvent <= '1'; 
348
                                --when 304 =>           iExtIntEvent <= '0'; 
349
 
350
                                -- ************ --
351
                                -- FREEZE EVENT --
352
                                -- ************ --
353
                                when 130 =>             iFreeze <= '1';
354
                                when 150 =>             iFreeze <= '0';
355
 
356
                                -- ****** --
357
                                -- WB ACK --
358
                                -- ****** --
359
                                --when 420      =>              iWbACK  <= '1';
360
                                --when 420+1    =>              iWbACK  <= '0';
361
 
362
                                when others =>  --iExtIntEvent <= iExtIntEvent;   -- hold last defined value
363
 
364
                        end case;
365
 
366
                end loop;
367
 
368
                wait; -- end of simulation.
369
 
370
        end process INT_Proc;
371
 
372
end behavior;

powered by: WebSVN 2.1.0

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