1 ------------------------------------------------------------------------------
3 ---- Testbench for the ZPU Medium connection to the FPGA ----
5 ---- http://www.opencores.org/ ----
8 ---- This is a testbench to simulate the ZPU_Med1 core as used in the ----
9 ---- dmips_med1.vhdl ----
15 ---- - Salvador E. Tropea, salvador inti.gob.ar ----
17 ------------------------------------------------------------------------------
19 ---- Copyright (c) 2008 Salvador E. Tropea <salvador inti.gob.ar> ----
20 ---- Copyright (c) 2008 Instituto Nacional de TecnologĂa Industrial ----
22 ---- Distributed under the BSD license ----
24 ------------------------------------------------------------------------------
26 ---- Design unit: DMIPS_Med1_TB(Behave) (Entity and architecture) ----
27 ---- File name: dmips_med1_tb.vhdl ----
29 ---- Limitations: None known ----
30 ---- Errors: None known ----
31 ---- Library: work ----
32 ---- Dependencies: IEEE.std_logic_1164 ----
33 ---- IEEE.numeric_std ----
35 ---- zpu.txt_util ----
36 ---- work.zpu_memory ----
37 ---- Target FPGA: Spartan 3 (XC3S1500-4-FG456) ----
38 ---- Language: VHDL ----
39 ---- Wishbone: No ----
40 ---- Synthesis tools: N/A ----
41 ---- Simulation tools: GHDL [Sokcho edition] (0.2x) ----
42 ---- Text editor: SETEdit 0.5.x ----
44 ------------------------------------------------------------------------------
47 use IEEE.std_logic_1164.all;
48 use IEEE.numeric_std.all;
55 use work.zpu_memory.all;
57 entity DMIPS_Med1_TB is
58 end entity DMIPS_Med1_TB;
60 architecture Behave of DMIPS_Med1_TB is
61 constant WORD_SIZE : natural:=32; -- 32 bits data path
62 constant ADDR_W : natural:=18; -- 18 bits address space=256 kB, 128 kB I/O
63 constant BRAM_W : natural:=15; -- 15 bits RAM space=32 kB
64 constant D_CARE_VAL : std_logic:='0'; -- Fill value
65 constant CLK_FREQ : positive:=50; -- 50 MHz clock
66 constant CLK_S_PER : time:=1 us/(2.0*real(CLK_FREQ)); -- Clock semi period
67 constant BRATE : positive:=115200;
71 WORD_SIZE : natural:=32; -- 32 bits data path
72 D_CARE_VAL : std_logic:='X'; -- Fill value
73 CLK_FREQ : positive:=50; -- 50 MHz clock
74 BRATE : positive:=9600; -- RS232 baudrate
75 ADDR_W : natural:=18; -- 18 bits address space=256 kB, 128 kB I/O
76 BRAM_W : natural:=15); -- 15 bits RAM space=32 kB
78 clk_i : in std_logic; -- CPU clock
79 rst_i : in std_logic; -- Reset
80 break_o : out std_logic; -- Break executed
81 dbg_o : out zpu_dbgo_t; -- Debug info
82 rs232_tx_o : out std_logic; -- UART Tx
83 rs232_rx_i : in std_logic; -- UART Rx
84 gpio_in : in std_logic_vector(31 downto 0);
85 gpio_out : out std_logic_vector(31 downto 0);
86 gpio_dir : out std_logic_vector(31 downto 0) -- 1 = in, 0 = out
88 end component ZPU_Med1;
90 signal clk : std_logic;
91 signal reset : std_logic:='1';
93 signal break : std_logic;
94 signal dbg : zpu_dbgo_t; -- Debug info
95 signal rs232_tx : std_logic;
96 signal rs232_rx : std_logic;
100 WORD_SIZE => WORD_SIZE, D_CARE_VAL => D_CARE_VAL,
101 CLK_FREQ => CLK_FREQ, BRATE => BRATE, ADDR_W => ADDR_W,
104 clk_i => clk, rst_i => reset, rs232_tx_o => rs232_tx,
105 rs232_rx_i => rs232_rx, break_o => break, dbg_o => dbg,
106 gpio_in => (others => '0'));
110 ADDR_W => ADDR_W, WORD_SIZE => WORD_SIZE,
111 LOG_FILE => "dmips_med1.log")
113 clk_i => clk, dbg_i => dbg, stop_i => break, busy_i => '0');
123 print("* Break asserted, end of test");
126 end process do_clock;
131 wait until rising_edge(clk);
133 end process do_reset;
134 end architecture Behave; -- Entity: DMIPS_Med1_TB