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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [designs/] [core_decoder_wb/] [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 instantiates data and instruction memories, core, 
11
--                           core address decoder, wishbone adapter and wishbone 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 wb_stdio IS PORT
30
    (
31
        wb_o : OUT wb_slv_out_type;
32
        wb_i : IN wb_slv_in_type
33
    );
34
    END COMPONENT;
35
 
36
    SIGNAL dmem_o : dmem_out_type;
37
    SIGNAL dmem_i : dmem_in_type;
38
    SIGNAL imem_o : imem_out_type;
39
    SIGNAL imem_i : imem_in_type;
40
    SIGNAL s_dmem_o : dmem_out_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
41
    SIGNAL s_dmem_i : dmem_in_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
42
 
43
    SIGNAL m_wb_i : wb_mst_in_type;
44
    SIGNAL m_wb_o : wb_mst_out_type;
45
    SIGNAL s_wb_i : wb_slv_in_type;
46
    SIGNAL s_wb_o : wb_slv_out_type;
47
 
48 6 takar
    SIGNAL sys_clk_i : std_logic := '0';
49
    SIGNAL sys_int_i : std_logic;
50
    SIGNAL sys_rst_i : std_logic;
51 2 takar
 
52
    CONSTANT rom_size : integer := 16;
53
    CONSTANT ram_size : integer := 16;
54
 
55 6 takar
    SIGNAL sel_o : std_logic_vector(3 DOWNTO 0);
56
    SIGNAL ena_o : std_logic;
57 2 takar
 
58
BEGIN
59
 
60
    sys_clk_i <= NOT sys_clk_i AFTER 10000 ps;
61
    sys_rst_i <= '1' AFTER 0 ps, '0' AFTER  150000 ps;
62
    sys_int_i <= '1' AFTER 500000000 ps, '0' after 500040000 ps;
63
 
64
    -- Warning: an infinite loop like while(1) {} triggers this timeout too!
65
    -- disable this feature when a premature finish occur.
66
    timeout: PROCESS(sys_clk_i)
67
    BEGIN
68
        IF NOW = 10 ms THEN
69
            REPORT "TIMEOUT" SEVERITY FAILURE;
70
        END IF;
71
        -- BREAK ON EXIT (0xB8000000)
72
        IF compare(imem_i.dat_i, "10111000000000000000000000000000") = '1' THEN
73
            -- Make sure the simulator finishes when an error is encountered.
74
            -- For modelsim: see menu Simulate -> Runtime options -> Assertions
75
            REPORT "FINISHED" SEVERITY FAILURE;
76
        END IF;
77
    END PROCESS;
78
 
79
    s_wb_i.clk_i <= sys_clk_i;
80
    s_wb_i.rst_i <= sys_rst_i;
81
    s_wb_i.adr_i <= m_wb_o.adr_o;
82
    s_wb_i.dat_i <= m_wb_o.dat_o;
83
    s_wb_i.we_i  <= m_wb_o.we_o;
84
    s_wb_i.stb_i <= m_wb_o.stb_o;
85
    s_wb_i.sel_i <= m_wb_o.sel_o;
86
    s_wb_i.cyc_i <= m_wb_o.cyc_o;
87
 
88
    m_wb_i.clk_i <= sys_clk_i;
89
    m_wb_i.rst_i <= sys_rst_i;
90
    m_wb_i.dat_i <= s_wb_o.dat_o;
91
    m_wb_i.ack_i <= s_wb_o.ack_o;
92
    m_wb_i.int_i <= s_wb_o.int_o;
93
 
94
    stdio : wb_stdio PORT MAP
95
    (
96
        wb_i  => s_wb_i,
97
        wb_o  => s_wb_o
98
    );
99
 
100
    wb_adapter : core_wb_adapter PORT MAP
101
    (
102
        dmem_i => s_dmem_i(1),
103
        wb_o   => m_wb_o,
104
        dmem_o => s_dmem_o(1),
105
        wb_i   => m_wb_i
106
    );
107
 
108
    s_dmem_i(0).ena_i <= '1';
109
    sel_o <= s_dmem_o(0).sel_o WHEN s_dmem_o(0).we_o = '1' ELSE (OTHERS => '0');
110
    ena_o <= NOT sys_rst_i AND s_dmem_o(0).ena_o;
111
 
112
    dmem : sram_4en GENERIC MAP
113
    (
114
        WIDTH => CFG_DMEM_WIDTH,
115
        SIZE => ram_size - 2
116
    )
117
    PORT MAP
118
    (
119
        dat_o => s_dmem_i(0).dat_i,
120
        dat_i => s_dmem_o(0).dat_o,
121
        adr_i => s_dmem_o(0).adr_o(ram_size - 1 DOWNTO 2),
122
        wre_i => sel_o,
123
        ena_i => ena_o,
124
        clk_i => sys_clk_i
125
    );
126
 
127
    decoder : core_address_decoder GENERIC MAP
128
    (
129
        G_NUM_SLAVES => CFG_NUM_SLAVES
130
    )
131
    PORT MAP
132
    (
133
        m_dmem_i => dmem_i,
134
        s_dmem_o => s_dmem_o,
135
        m_dmem_o => dmem_o,
136
        s_dmem_i => s_dmem_i,
137
        clk_i    => sys_clk_i
138
    );
139
 
140
    imem : sram GENERIC MAP
141
    (
142
        WIDTH => CFG_IMEM_WIDTH,
143
        SIZE => rom_size - 2
144
    )
145
    PORT MAP
146
    (
147
        dat_o => imem_i.dat_i,
148
        dat_i => "00000000000000000000000000000000",
149
        adr_i => imem_o.adr_o(rom_size - 1 DOWNTO 2),
150
        wre_i => '0',
151
        ena_i => imem_o.ena_o,
152
        clk_i => sys_clk_i
153
    );
154
 
155
    core0 : core PORT MAP
156
    (
157
        imem_o => imem_o,
158
        dmem_o => dmem_o,
159
        imem_i => imem_i,
160
        dmem_i => dmem_i,
161
        int_i  => sys_int_i,
162
        rst_i  => sys_rst_i,
163
        clk_i  => sys_clk_i
164
    );
165
 
166
END arch;

powered by: WebSVN 2.1.0

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