2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
9 --------------------------------------------------------------------------------
11 architecture testbench of tb_pwm_min is
13 constant period : time := 1 us;
14 constant offset : time := 0 us;
16 constant IRF_ADR_W : integer := 5;
19 signal ACK_O : std_logic;
20 signal CLK_I : std_logic;
21 signal RST_I : std_logic;
22 signal STB_I : std_logic;
24 signal IRF_ACK_I : std_logic;
25 signal IRF_ADR_O : std_logic_vector (IRF_ADR_W-1 downto 0);
26 signal IRF_DAT_I : std_logic_vector (15 downto 0);
27 signal IRF_DAT_O : std_logic_vector (15 downto 0);
28 signal IRF_STB_O : std_logic;
29 signal IRF_WE_O : std_logic;
31 subtype word_t is std_logic_vector (15 downto 0);
33 signal dbg_ack : std_logic := '0';
35 signal dbg_mem0x06 : word_t := (others => '0');
36 signal dbg_mem0x11 : word_t := (others => '0');
37 signal dbg_mem0x15 : word_t := (others => '0');
38 signal dbg_mem0x19 : word_t := (others => '0');
40 --------------------------------------------------------------------------------
44 uut : entity work.pwm_min
46 IRF_ADR_W => IRF_ADR_W,
58 IRF_ACK_I => IRF_ACK_I,
59 IRF_ADR_O => IRF_ADR_O,
60 IRF_DAT_I => IRF_DAT_I,
61 IRF_DAT_O => IRF_DAT_O,
62 IRF_STB_O => IRF_STB_O,
63 IRF_WE_O => IRF_WE_O);
66 SYSCON_CLK : process is
78 SYSCON_RST : process is
90 DBG_MEM : process (IRF_STB_O, CLK_I) is
92 IRF_ACK_I <= IRF_STB_O and (IRF_WE_O or dbg_ack);
94 if rising_edge(CLK_I) then
98 if rising_edge(CLK_I) and IRF_STB_O = '1' then
99 if IRF_WE_O = '0' then
100 case conv_integer(IRF_ADR_O) is
101 when 16#11# => IRF_DAT_I <= dbg_mem0x11;
102 when 16#15# => IRF_DAT_I <= dbg_mem0x15;
103 when 16#19# => IRF_DAT_I <= dbg_mem0x19;
105 IRF_DAT_I <= (others => 'X');
106 report "Reading from non-readable register" severity warning;
109 case conv_integer(IRF_ADR_O) is
110 when 16#06# => dbg_mem0x06 <= IRF_DAT_O;
112 report "Writing to read-only registers" severity error;
118 --------------------------------------------------------------------------------
120 UUT_FEED : process is
128 dbg_mem0x11 <= "0000000111111111";
129 dbg_mem0x15 <= "0000000000100000";
130 dbg_mem0x19 <= "0000000001000000";
132 wait for 0.75*period;
134 wait for 0.25*period;
135 wait until rising_edge(CLK_I) and ACK_O = '1';
136 wait for 0.25*period;
138 wait for 0.75*period;