Line 10... |
Line 10... |
-- Description : Testbench instantiates data and instruction memories, core,
|
-- Description : Testbench instantiates data and instruction memories, core,
|
-- core address decoder, wishbone adapter and wishbone stdio
|
-- core address decoder, wishbone adapter and wishbone stdio
|
--
|
--
|
----------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------
|
|
|
LIBRARY ieee;
|
library ieee;
|
USE ieee.std_logic_1164.ALL;
|
use ieee.std_logic_1164.all;
|
USE ieee.std_logic_unsigned.ALL;
|
use ieee.std_logic_unsigned.all;
|
|
|
LIBRARY mblite;
|
library mblite;
|
USE mblite.config_Pkg.ALL;
|
use mblite.config_Pkg.all;
|
USE mblite.core_Pkg.ALL;
|
use mblite.core_Pkg.all;
|
USE mblite.std_Pkg.ALL;
|
use mblite.std_Pkg.all;
|
|
|
ENTITY testbench IS
|
entity testbench is
|
END testbench;
|
end testbench;
|
|
|
ARCHITECTURE arch OF testbench IS
|
architecture arch of testbench is
|
|
|
COMPONENT wb_stdio IS PORT
|
component wb_stdio is port
|
(
|
(
|
wb_o : OUT wb_slv_out_type;
|
wb_o : out wb_slv_out_type;
|
wb_i : IN wb_slv_in_type
|
wb_i : in wb_slv_in_type
|
);
|
);
|
END COMPONENT;
|
end component;
|
|
|
SIGNAL dmem_o : dmem_out_type;
|
signal dmem_o : dmem_out_type;
|
SIGNAL dmem_i : dmem_in_type;
|
signal dmem_i : dmem_in_type;
|
SIGNAL imem_o : imem_out_type;
|
signal imem_o : imem_out_type;
|
SIGNAL imem_i : imem_in_type;
|
signal imem_i : imem_in_type;
|
SIGNAL s_dmem_o : dmem_out_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
|
signal s_dmem_o : dmem_out_array_type(CFG_NUM_SLAVES - 1 downto 0);
|
SIGNAL s_dmem_i : dmem_in_array_type(CFG_NUM_SLAVES - 1 DOWNTO 0);
|
signal s_dmem_i : dmem_in_array_type(CFG_NUM_SLAVES - 1 downto 0);
|
|
|
SIGNAL m_wb_i : wb_mst_in_type;
|
signal m_wb_i : wb_mst_in_type;
|
SIGNAL m_wb_o : wb_mst_out_type;
|
signal m_wb_o : wb_mst_out_type;
|
SIGNAL s_wb_i : wb_slv_in_type;
|
signal s_wb_i : wb_slv_in_type;
|
SIGNAL s_wb_o : wb_slv_out_type;
|
signal s_wb_o : wb_slv_out_type;
|
|
|
SIGNAL sys_clk_i : std_logic := '0';
|
signal sys_clk_i : std_logic := '0';
|
SIGNAL sys_int_i : std_logic;
|
signal sys_int_i : std_logic;
|
SIGNAL sys_rst_i : std_logic;
|
signal sys_rst_i : std_logic;
|
|
|
CONSTANT rom_size : integer := 16;
|
constant rom_size : integer := 16;
|
CONSTANT ram_size : integer := 16;
|
constant ram_size : integer := 16;
|
|
|
SIGNAL sel_o : std_logic_vector(3 DOWNTO 0);
|
signal sel_o : std_logic_vector(3 downto 0);
|
SIGNAL ena_o : std_logic;
|
signal ena_o : std_logic;
|
|
|
BEGIN
|
begin
|
|
|
sys_clk_i <= NOT sys_clk_i AFTER 10000 ps;
|
sys_clk_i <= not sys_clk_i after 10000 ps;
|
sys_rst_i <= '1' AFTER 0 ps, '0' AFTER 150000 ps;
|
sys_rst_i <= '1' after 0 ps, '0' after 150000 ps;
|
sys_int_i <= '1' AFTER 500000000 ps, '0' after 500040000 ps;
|
sys_int_i <= '1' after 500000000 ps, '0' after 500040000 ps;
|
|
|
-- Warning: an infinite loop like while(1) {} triggers this timeout too!
|
-- Warning: an infinite loop like while(1) {} triggers this timeout too!
|
-- disable this feature when a premature finish occur.
|
-- disable this feature when a premature finish occur.
|
timeout: PROCESS(sys_clk_i)
|
timeout: process(sys_clk_i)
|
BEGIN
|
begin
|
IF NOW = 10 ms THEN
|
if NOW = 10 ms then
|
REPORT "TIMEOUT" SEVERITY FAILURE;
|
report "TIMEOUT" severity FAILURE;
|
END IF;
|
end if;
|
-- BREAK ON EXIT (0xB8000000)
|
-- BREAK ON EXIT (0xB8000000)
|
IF compare(imem_i.dat_i, "10111000000000000000000000000000") = '1' THEN
|
if compare(imem_i.dat_i, "10111000000000000000000000000000") = '1' then
|
-- Make sure the simulator finishes when an error is encountered.
|
-- Make sure the simulator finishes when an error is encountered.
|
-- For modelsim: see menu Simulate -> Runtime options -> Assertions
|
-- For modelsim: see menu Simulate -> Runtime options -> Assertions
|
REPORT "FINISHED" SEVERITY FAILURE;
|
report "FINISHED" severity FAILURE;
|
END IF;
|
end if;
|
END PROCESS;
|
end process;
|
|
|
s_wb_i.clk_i <= sys_clk_i;
|
s_wb_i.clk_i <= sys_clk_i;
|
s_wb_i.rst_i <= sys_rst_i;
|
s_wb_i.rst_i <= sys_rst_i;
|
s_wb_i.adr_i <= m_wb_o.adr_o;
|
s_wb_i.adr_i <= m_wb_o.adr_o;
|
s_wb_i.dat_i <= m_wb_o.dat_o;
|
s_wb_i.dat_i <= m_wb_o.dat_o;
|
Line 89... |
Line 89... |
m_wb_i.rst_i <= sys_rst_i;
|
m_wb_i.rst_i <= sys_rst_i;
|
m_wb_i.dat_i <= s_wb_o.dat_o;
|
m_wb_i.dat_i <= s_wb_o.dat_o;
|
m_wb_i.ack_i <= s_wb_o.ack_o;
|
m_wb_i.ack_i <= s_wb_o.ack_o;
|
m_wb_i.int_i <= s_wb_o.int_o;
|
m_wb_i.int_i <= s_wb_o.int_o;
|
|
|
stdio : wb_stdio PORT MAP
|
stdio : wb_stdio port map
|
(
|
(
|
wb_i => s_wb_i,
|
wb_i => s_wb_i,
|
wb_o => s_wb_o
|
wb_o => s_wb_o
|
);
|
);
|
|
|
wb_adapter : core_wb_adapter PORT MAP
|
wb_adapter : core_wb_adapter port map
|
(
|
(
|
dmem_i => s_dmem_i(1),
|
dmem_i => s_dmem_i(1),
|
wb_o => m_wb_o,
|
wb_o => m_wb_o,
|
dmem_o => s_dmem_o(1),
|
dmem_o => s_dmem_o(1),
|
wb_i => m_wb_i
|
wb_i => m_wb_i
|
);
|
);
|
|
|
s_dmem_i(0).ena_i <= '1';
|
s_dmem_i(0).ena_i <= '1';
|
sel_o <= s_dmem_o(0).sel_o WHEN s_dmem_o(0).we_o = '1' ELSE (OTHERS => '0');
|
sel_o <= s_dmem_o(0).sel_o when s_dmem_o(0).we_o = '1' else (others => '0');
|
ena_o <= NOT sys_rst_i AND s_dmem_o(0).ena_o;
|
ena_o <= not sys_rst_i and s_dmem_o(0).ena_o;
|
|
|
dmem : sram_4en GENERIC MAP
|
dmem : sram_4en generic map
|
(
|
(
|
WIDTH => CFG_DMEM_WIDTH,
|
WIDTH => CFG_DMEM_WIDTH,
|
SIZE => ram_size - 2
|
SIZE => ram_size - 2
|
)
|
)
|
PORT MAP
|
port map
|
(
|
(
|
dat_o => s_dmem_i(0).dat_i,
|
dat_o => s_dmem_i(0).dat_i,
|
dat_i => s_dmem_o(0).dat_o,
|
dat_i => s_dmem_o(0).dat_o,
|
adr_i => s_dmem_o(0).adr_o(ram_size - 1 DOWNTO 2),
|
adr_i => s_dmem_o(0).adr_o(ram_size - 1 downto 2),
|
wre_i => sel_o,
|
wre_i => sel_o,
|
ena_i => ena_o,
|
ena_i => ena_o,
|
clk_i => sys_clk_i
|
clk_i => sys_clk_i
|
);
|
);
|
|
|
decoder : core_address_decoder GENERIC MAP
|
decoder : core_address_decoder generic map
|
(
|
(
|
G_NUM_SLAVES => CFG_NUM_SLAVES
|
G_NUM_SLAVES => CFG_NUM_SLAVES
|
)
|
)
|
PORT MAP
|
port map
|
(
|
(
|
m_dmem_i => dmem_i,
|
m_dmem_i => dmem_i,
|
s_dmem_o => s_dmem_o,
|
s_dmem_o => s_dmem_o,
|
m_dmem_o => dmem_o,
|
m_dmem_o => dmem_o,
|
s_dmem_i => s_dmem_i,
|
s_dmem_i => s_dmem_i,
|
clk_i => sys_clk_i
|
clk_i => sys_clk_i
|
);
|
);
|
|
|
imem : sram GENERIC MAP
|
imem : sram generic map
|
(
|
(
|
WIDTH => CFG_IMEM_WIDTH,
|
WIDTH => CFG_IMEM_WIDTH,
|
SIZE => rom_size - 2
|
SIZE => rom_size - 2
|
)
|
)
|
PORT MAP
|
port map
|
(
|
(
|
dat_o => imem_i.dat_i,
|
dat_o => imem_i.dat_i,
|
dat_i => "00000000000000000000000000000000",
|
dat_i => "00000000000000000000000000000000",
|
adr_i => imem_o.adr_o(rom_size - 1 DOWNTO 2),
|
adr_i => imem_o.adr_o(rom_size - 1 downto 2),
|
wre_i => '0',
|
wre_i => '0',
|
ena_i => imem_o.ena_o,
|
ena_i => imem_o.ena_o,
|
clk_i => sys_clk_i
|
clk_i => sys_clk_i
|
);
|
);
|
|
|
core0 : core PORT MAP
|
core0 : core port map
|
(
|
(
|
imem_o => imem_o,
|
imem_o => imem_o,
|
dmem_o => dmem_o,
|
dmem_o => dmem_o,
|
imem_i => imem_i,
|
imem_i => imem_i,
|
dmem_i => dmem_i,
|
dmem_i => dmem_i,
|
int_i => sys_int_i,
|
int_i => sys_int_i,
|
rst_i => sys_rst_i,
|
rst_i => sys_rst_i,
|
clk_i => sys_clk_i
|
clk_i => sys_clk_i
|
);
|
);
|
|
|
END arch;
|
end arch;
|
|
|
No newline at end of file
|
No newline at end of file
|