library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity tb_pwm_min_dump is end tb_pwm_min_dump; -------------------------------------------------------------------------------- architecture testbench of tb_pwm_min_dump is constant period : time := 1 us; constant offset : time := 0 us; constant IRF_ADR_W : integer := 5; signal ACK_O : std_logic; signal CLK_I : std_logic; signal RST_I : std_logic; signal STB_I : std_logic; signal IRF_ACK_I : std_logic; signal IRF_ADR_O : std_logic_vector (IRF_ADR_W-1 downto 0); signal IRF_DAT_I : std_logic_vector (15 downto 0); signal IRF_DAT_O : std_logic_vector (15 downto 0); signal IRF_STB_O : std_logic; signal IRF_WE_O : std_logic; signal PWM_DAT_O : std_logic_vector (9 downto 0); signal PWM_STB_O : std_logic; subtype word_t is std_logic_vector (15 downto 0); signal dbg_ack : std_logic := '0'; signal dbg_mem0x06 : word_t := (others => '0'); signal dbg_mem0x11 : word_t := (others => '0'); -------------------------------------------------------------------------------- begin uut : entity work.pwm_min_dump generic map ( IRF_ADR_W => IRF_ADR_W, BASE => 0, PWMMIN_OFF => 16#06#, P_BASE => 16#10#, PWM_OFF => 1, PWM_W => 10) port map ( ACK_O => ACK_O, CLK_I => CLK_I, RST_I => RST_I, STB_I => STB_I, PWM_DAT_O => PWM_DAT_O, PWM_STB_O => PWM_STB_O, IRF_ACK_I => IRF_ACK_I, IRF_ADR_O => IRF_ADR_O, IRF_DAT_I => IRF_DAT_I, IRF_STB_O => IRF_STB_O); SYSCON_CLK : process is begin CLK_I <= '0'; wait for offset; loop CLK_I <= '1'; wait for period/2; CLK_I <= '0'; wait for period/2; end loop; end process; SYSCON_RST : process is begin RST_I <= '0'; wait for offset; wait for 0.75*period; RST_I <= '1'; wait for 2*period; RST_I <= '0'; wait; end process; DBG_MEM : process (IRF_STB_O, CLK_I) is begin IRF_ACK_I <= IRF_STB_O and (IRF_WE_O or dbg_ack); if rising_edge(CLK_I) then dbg_ack <= IRF_STB_O; end if; if rising_edge(CLK_I) and IRF_STB_O = '1' then if IRF_WE_O = '0' then case conv_integer(IRF_ADR_O) is when 16#06# => IRF_DAT_I <= dbg_mem0x06; when 16#11# => IRF_DAT_I <= dbg_mem0x11; when others => IRF_DAT_I <= (others => 'X'); report "Reading from non-readable register" severity warning; end case; else case conv_integer(IRF_ADR_O) is when others => report "Writing to read-only registers" severity error; end case; end if; end if; end process; -------------------------------------------------------------------------------- UUT_FEED : process is begin IRF_DAT_O <= (others => '0'); IRF_WE_O <= '0'; STB_I <= '0'; wait for offset; wait for 4*period; for i in 0 to 0 loop dbg_mem0x06 <= conv_std_logic_vector(10, 16); dbg_mem0x11 <= conv_std_logic_vector(45, 16); wait for 0.75*period; STB_I <= '1'; wait for 0.25*period; wait until rising_edge(CLK_I) and ACK_O = '1'; wait for 0.25*period; STB_I <= '0'; wait for 0.75*period; wait for 4*period; end loop; wait; end process; end testbench;