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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_decoder/] [testbench.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : config_Pkg.vhd
4
--      Design name        : config_Pkg
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description        : Testbench which instantiates instruction memory, data memory,
11
--                           core, core address decoder and stdio
12
--
13
----------------------------------------------------------------------------------------------
14
 
15
LIBRARY ieee;
16
USE ieee.std_logic_1164.ALL;
17
USE ieee.std_logic_unsigned.ALL;
18
 
19
LIBRARY mblite;
20
USE mblite.config_Pkg.ALL;
21
USE mblite.core_Pkg.ALL;
22
USE mblite.std_Pkg.ALL;
23
 
24
ENTITY testbench IS
25
END testbench;
26
 
27
ARCHITECTURE arch OF testbench IS
28
 
29
    COMPONENT mblite_stdio IS PORT
30
    (
31
        dmem_i : OUT dmem_in_type;
32
        dmem_o : IN dmem_out_type;
33 6 takar
        clk_i  : IN std_logic
34 2 takar
    );
35
    END COMPONENT;
36
 
37
    SIGNAL dmem_o : dmem_out_type;
38
    SIGNAL dmem_i : dmem_in_type;
39
    SIGNAL imem_o : imem_out_type;
40
    SIGNAL imem_i : imem_in_type;
41
    SIGNAL s_dmem_o : dmem_out_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
42
    SIGNAL s_dmem_i : dmem_in_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
43
 
44 6 takar
    SIGNAL sys_clk_i : std_logic := '0';
45
    SIGNAL sys_int_i : std_logic;
46
    SIGNAL sys_rst_i : std_logic;
47 2 takar
 
48
    CONSTANT rom_size : integer := 16;
49
    CONSTANT ram_size : integer := 16;
50
 
51 6 takar
    SIGNAL sel_o : std_logic_vector(3 DOWNTO 0);
52
    SIGNAL ena_o : std_logic;
53 2 takar
 
54
BEGIN
55
 
56
    sys_clk_i <= NOT sys_clk_i AFTER 10000 ps;
57
    sys_rst_i <= '1' AFTER 0 ps, '0' AFTER  150000 ps;
58
    sys_int_i <= '1' AFTER 500000000 ps, '0' after 500040000 ps;
59
 
60
    -- Warning: an infinite loop like while(1) {} triggers this timeout too!
61
    -- disable this feature when a premature finish occur.
62
    timeout: PROCESS(sys_clk_i)
63
    BEGIN
64
        IF NOW = 10 ms THEN
65
            REPORT "TIMEOUT" SEVERITY FAILURE;
66
        END IF;
67
        -- BREAK ON EXIT (0xB8000000)
68
        IF compare(imem_i.dat_i, "10111000000000000000000000000000") = '1' THEN
69
            -- Make sure the simulator finishes when an error is encountered.
70
            -- For modelsim: see menu Simulate -> Runtime options -> Assertions
71
            REPORT "FINISHED" SEVERITY FAILURE;
72
        END IF;
73
    END PROCESS;
74
 
75
    stdio : mblite_stdio PORT MAP
76
    (
77
        dmem_i => s_dmem_i(1),
78
        dmem_o => s_dmem_o(1),
79
        clk_i  => sys_clk_i
80
    );
81
 
82
    s_dmem_i(0).ena_i <= '1';
83
    sel_o <= s_dmem_o(0).sel_o WHEN s_dmem_o(0).we_o = '1' ELSE (OTHERS => '0');
84
    ena_o <= NOT sys_rst_i AND s_dmem_o(0).ena_o;
85
 
86
    dmem : sram_4en GENERIC MAP
87
    (
88
        WIDTH => CFG_DMEM_WIDTH,
89
        SIZE => ram_size - 2
90
    )
91
    PORT MAP
92
    (
93
        dat_o => s_dmem_i(0).dat_i,
94
        dat_i => s_dmem_o(0).dat_o,
95
        adr_i => s_dmem_o(0).adr_o(ram_size - 1 DOWNTO 2),
96
        wre_i => sel_o,
97
        ena_i => ena_o,
98
        clk_i => sys_clk_i
99
    );
100
 
101
    decoder : core_address_decoder GENERIC MAP
102
    (
103
        G_NUM_SLAVES => CFG_NUM_SLAVES
104
    )
105
    PORT MAP
106
    (
107
        m_dmem_i => dmem_i,
108
        s_dmem_o => s_dmem_o,
109
        m_dmem_o => dmem_o,
110
        s_dmem_i => s_dmem_i,
111
        clk_i    => sys_clk_i
112
    );
113
 
114
    imem : sram GENERIC MAP
115
    (
116
        WIDTH => CFG_IMEM_WIDTH,
117
        SIZE => rom_size - 2
118
    )
119
    PORT MAP
120
    (
121
        dat_o => imem_i.dat_i,
122
        dat_i => "00000000000000000000000000000000",
123
        adr_i => imem_o.adr_o(rom_size - 1 DOWNTO 2),
124
        wre_i => '0',
125
        ena_i => imem_o.ena_o,
126
        clk_i => sys_clk_i
127
    );
128
 
129
    core0 : core PORT MAP
130
    (
131
        imem_o => imem_o,
132
        dmem_o => dmem_o,
133
        imem_i => imem_i,
134
        dmem_i => dmem_i,
135
        int_i  => sys_int_i,
136
        rst_i  => sys_rst_i,
137
        clk_i  => sys_clk_i
138
    );
139
 
140
END arch;

powered by: WebSVN 2.1.0

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