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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [bench/] [vhdl/] [tb_copyBlaze_ecoSystem.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: tb_copyBlaze_ecoSystem.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
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 is
36
end tb_copyBlaze_ecoSystem;
37
 
38
--------------------------------------------------------------------------------
39
-- Architecture: behavior
40
-- of entity : tb_copyBlaze_ecoSystem
41
--------------------------------------------------------------------------------
42
architecture behavior of tb_copyBlaze_ecoSystem 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
                                TAGN_O                          : out   std_ulogic_vector(1 downto 0);
121
                                TAGN_I                          : in    std_ulogic_vector(1 downto 0)
122
                );
123
        end component;
124
 
125
        component WBOPRT08
126
                port(
127
                        -- WISHBONE SLAVE interface:
128
                        ACK_O   : out std_ulogic;
129
                        CLK_I   : in std_ulogic;
130
                        DAT_I   : in std_ulogic_vector( 7 downto 0 );
131
                        DAT_O   : out std_ulogic_vector( 7 downto 0 );
132
                        RST_I   : in std_ulogic;
133
                        STB_I   : in std_ulogic;
134
                        WE_I    : in std_ulogic;
135
                        -- Output port (non-WISHBONE signals):
136
                        PRT_O   : 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 iWbACK                   : std_ulogic;-- := '0';--'0';
164
        signal iWbWE                    : std_ulogic;-- := '0';--'0';
165
 
166
        signal iWbDAT_I                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
167
        signal iWbDAT_O                 : std_ulogic_vector(CST_WIDTH_DATA-1 downto 0);
168
 
169
begin
170
 
171
        -- ***************************************** --
172
        -- UUT : Unit Under Test : cp_copyBlaze_ecoSystem --
173
        -- ***************************************** --
174
        uut: cp_copyBlaze_ecoSystem
175
                generic map
176
                (
177
                        GEN_WIDTH_DATA          => CST_WIDTH_DATA,
178
                        GEN_WIDTH_PC            => CST_WIDTH_PC,
179
                        GEN_WIDTH_INST          => CST_WIDTH_INST,
180
 
181
                        GEN_DEPTH_STACK         => CST_DEPTH_STACK,
182
                        GEN_DEPTH_BANC          => CST_DEPTH_BANC,
183
                        GEN_DEPTH_SCRATCH       => CST_DEPTH_SCRATCH,
184
 
185
                        GEN_INT_VECTOR          => CST_INT_VECTOR
186
                )
187
                Port map
188
                (
189
                        --------------------------------------------------------------------------------
190
                        -- Signaux Systeme
191
                        --------------------------------------------------------------------------------
192
                                Clk_i                           => iClk,
193
                                --Rst_i_n                               : in std_ulogic;
194
 
195
                        --------------------------------------------------------------------------------
196
                        -- Signaux Fonctionels
197
                        --------------------------------------------------------------------------------
198
                                Interrupt_i                     => iInterrupt,
199
                                Interrupt_Ack_o         => iInterrupt_Ack,
200
 
201
                                IN_PORT_i                       => iIn_port,
202
                                OUT_PORT_o                      => iOut_port,
203
                                PORT_ID_o                       => iPort_id,
204
                                READ_STROBE_o           => iRead_strobe,
205
                                WRITE_STROBE_o          => iWrite_strobe,
206
                        --------------------------------------------------------------------------------
207
                        -- Signaux WishBone
208
                        --------------------------------------------------------------------------------
209
                                Freeze_i                        => iFreeze,
210
 
211
                        --------------------------------------------------------------------------------
212
                        -- Signaux Wishbone Interface
213
                        --------------------------------------------------------------------------------
214
                                RST_I                           => iReset,
215
                                --CLK_I                         => Clk_i,
216
 
217
                                ADR_O                           => open,
218
                                DAT_I                           => iWbDAT_I,--(others => '0'),
219
                                DAT_O                           => iWbDAT_O,--open,
220
                                WE_O                            => iWbWE,--open,
221
                                SEL_O                           => open,
222
 
223
                                STB_O                           => iWbSTB,
224
                                ACK_I                           => iWbACK,
225
                                CYC_O                           => open,
226
 
227
                                TAGN_O                          => open,
228
                                TAGN_I                          => (others => '0')
229
                );
230
 
231
        WB_port : WBOPRT08
232
                port map
233
                (
234
                        -- WISHBONE SLAVE interface:
235
                        ACK_O   => iWbACK,
236
                        CLK_I   => iClk,
237
                        DAT_I   => iWbDAT_O,
238
                        DAT_O   => iWbDAT_I,
239
                        RST_I   => iResetN,
240
                        STB_I   => iWbSTB,
241
                        WE_I    => iWbWE,
242
                        -- Output port (non-WISHBONE signals):
243
                        PRT_O   => open --: out std_ulogic_vector( 7 downto 0 )
244
                );
245
 
246
        --------------------------------------------------------------------------------
247
        -- Process : Interrupt_Proc
248
        -- Description: Interrupt Logic for cp_copyBlaze_ecoSystem
249
        --------------------------------------------------------------------------------
250
        Interrupt_Proc: process(iReset, iClk)
251
        begin
252
                if (iReset='0') then
253
                        iInterrupt      <= '0';
254
                elsif ( rising_edge(iClk) ) then
255
                        if (iExtIntEvent='1') then
256
                                iInterrupt      <= '1';
257
                        elsif (iInterrupt_Ack='1') then
258
                                iInterrupt      <= '0';
259
                        end if;
260
                end if;
261
        end process Interrupt_Proc;
262
 
263
        --------------------------------------------------------------------------------
264
        -- Process : Reset_Proc
265
        -- Description: Reset Logic for cp_copyBlaze_ecoSystem
266
        --------------------------------------------------------------------------------
267
        Reset_Proc: process(iClk)
268
        begin
269
                -- delayed iReset circuit
270
                if ( rising_edge(iClk) ) then
271
                        if ( iReset_counter = 0 ) then
272
                                iReset                  <=      '1';
273
                        else
274
                                iReset                  <=      '0';
275
                                iReset_counter  <=      iReset_counter - 1;
276
                        end if;
277
                end if;
278
        end process Reset_Proc;
279
        iResetN <=      not(iReset);
280
 
281
        --------------------------------------------------------------------------------
282
        -- Process : IO_Proc
283
        -- Description: adding the output registers to the processor
284
        --------------------------------------------------------------------------------
285
        IO_Proc: process(iClk)
286
        begin
287
                -- waveform register at iAddress 02
288
                if ( rising_edge(iClk) ) then
289
                        if (iPort_id(1)='1' and iWrite_strobe='1') then
290
                                iWaveForms <= iOut_port;
291
                        end if;
292
                end if;
293
 
294
                -- Interrupt iCounter register at iAddress 04
295
                if ( rising_edge(iClk) ) then
296
                        if (iPort_id(2)='1' and iWrite_strobe='1') then
297
                                iCounter <= iOut_port;
298
                        end if;
299
                end if;
300
 
301
        end process IO_Proc;
302
 
303
        -- ********************* --
304
        -- STIMULIS FOR THE TEST --
305
        -- ********************* --
306
        -- Unused inputs on processor
307
        iIn_port        <= x"28";
308
 
309
        --iClk <= not iClk after 0.5 * CST_PERIOD;
310
        --------------------------------------------------------------------------------
311
        -- Process : INT_Proc
312
        -- Description: Nominal 100MHz clock which also defines number of cycles in simulation 
313
        --------------------------------------------------------------------------------
314
        INT_Proc : process
315
                variable max_cycles             : integer :=    CST_MAX_CYCLES;
316
                variable cycle_count    : integer :=    0;
317
        begin
318
                -- Define the clock cycles and the clock cycle iCounter
319
                while cycle_count < max_cycles loop
320
 
321
--                      wait until rising_edge(iClk) ;
322
                                iClk <= '0';
323
                        wait for CST_PERIOD;
324
                                iClk <= '1';
325
                                cycle_count := cycle_count + 1;
326
                        wait for CST_PERIOD;
327
 
328
 
329
                        --Now define stimulus relative to a given clock cycle
330
                        case cycle_count is
331
                                -- *************** --
332
                                -- INTERRUPT EVENT --
333
                                -- *************** --
334
                                --when 30 =>    iExtIntEvent <= '1'; 
335
                                --when 34 =>    iExtIntEvent <= '0'; 
336
                --
337
                                --when 67 =>    iExtIntEvent <= '1'; -- Take care when the "iIE" bit is not set. In this case how to manage Interrupt_Ack_o
338
                                --when 71 =>    iExtIntEvent <= '0'; 
339
 
340
                                when 300 =>             iExtIntEvent <= '1';
341
                                when 304 =>             iExtIntEvent <= '0';
342
 
343
                                -- ************ --
344
                                -- FREEZE EVENT --
345
                                -- ************ --
346
                                when 130 =>             iFreeze <= '1';
347
                                when 150 =>             iFreeze <= '0';
348
 
349
                                -- ****** --
350
                                -- WB ACK --
351
                                -- ****** --
352
                                --when 420      =>              iWbACK  <= '1';
353
                                --when 420+1    =>              iWbACK  <= '0';
354
 
355
                                when others =>  iExtIntEvent <= iExtIntEvent;   -- hold last defined value
356
 
357
                        end case;
358
 
359
                end loop;
360
 
361
                wait; -- end of simulation.
362
 
363
        end process INT_Proc;
364
 
365
end behavior;

powered by: WebSVN 2.1.0

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