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

Subversion Repositories tinyvliw8

[/] [tinyvliw8/] [trunk/] [testbench/] [sysArch_tb.vhd] - Rev 4

Go to most recent revision | Compare with Previous | Blame | View Log

library IEEE;
use IEEE.std_logic_1164.all;
 
entity sysArch_tb is
end sysArch_tb;
 
architecture beh of sysArch_tb is
 
component sysArch
	port (
		-- clock input
		clk           : in std_logic;
 
		-- instruction bus
		instMemAddr   : out std_logic_vector(10 downto 0);
		instMemDataIn : in  std_logic_vector(31 downto 0);
		instMemEn_n   : out std_logic;
 
		-- data bus
		dataMemAddr    : out std_logic_vector(7 downto 0);
		dataMemDataIn  : in  std_logic_vector(7 downto 0);
		dataMemDataOut : out std_logic_vector(7 downto 0);
		dataMemEn_n    : out std_logic;
		dataMemWr_n    : out std_logic;
 
		ioAddr    : out std_logic_vector(7 downto 0);
		ioDataIn  : in  std_logic_vector(7 downto 0);
		ioDataOut : out std_logic_vector(7 downto 0);
		ioWrEn_n  : out std_logic;
		ioRdEn_n  : out std_logic;
 
		-- interrupt handling
		irqLine        : in  std_logic;
		irqLineAck     : out std_logic;
 
		-- general purpose IO
		gpio_in  : in  std_logic_vector(7 downto 0);
		gpio_out : out	std_logic_vector(7 downto 0);
		gpio_dir : out	std_logic_vector(7 downto 0);
 
		spi_clk  : OUT STD_LOGIC;	-- SPI clock
		spi_cs   : OUT STD_LOGIC;	-- SPI slave select, active level configurable
		spi_mosi : OUT STD_LOGIC;	-- SPI master output, slave input
		spi_miso : IN  STD_LOGIC; 	-- SPI master input, slave output
 
		stall_n      : in std_logic;
		stalled_n    : out std_logic;
 
		-- reset input
		rst_n        : in std_logic
	);
end component;
 
component symDecoder
	port (
		clk          : in std_logic;
 
		codeA        : in std_logic;
		codeB        : in std_logic;
 
		ioAddr       : in std_logic_vector(3 downto 0);	 -- register address
		ioWriteEn_n  : in std_logic;	                 -- write enable, low active
		ioReadEn_n   : in std_logic;                     -- read enable, low active
 
		ioDataOut    : out std_logic_vector(7 downto 0); -- data bus for writing register
		ioDataIn     : in std_logic_vector(7 downto 0);  -- data bus for reading register
 
		irq          : out std_logic;
		irq_ack      : in  std_logic;
 
		rst_n        : in std_logic
	);
end component;
 
component lib_tb_clock32kHz is
	port (
		signal clk   : out std_logic;
		signal rst_n : out std_logic
	);
end component;
 
component dataMem
	PORT (
		address  	: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
		data  		: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
		inclock		: IN STD_LOGIC;
		outclock		: IN STD_LOGIC;
		wren  		: IN STD_LOGIC;
		q  			: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
	);
end component dataMem;
 
component lib_tb_rom32bit is
	generic ( fileName : string );
	port (
		signal addr    : in std_logic_vector(10 downto 0);
		signal dataOut : out std_logic_vector(31 downto 0);
		signal en_n    : in std_logic
	);
end component;
 
component wurCodeGen_tb is
	port (
		clk     : in std_logic;
 
		pattern : in std_logic_vector(31 downto 0);
		mask    : in std_logic_vector(31 downto 0);
 
		codeA   : out std_logic;
		codeB   : out std_logic;
 
		finished : out std_logic;
 
		rst_n   : in std_logic
	);
end component;
 
component gendelay
	generic (n: integer := 1);
	port (
		a_in	: in	std_logic;
		a_out	: out	std_logic
	);
end component;
 
	signal clk_s       : std_logic;
 
	signal dataAddr_s  : std_logic_vector(7 downto 0);
	signal dataIn_s    : std_logic_vector(7 downto 0);
	signal dataOut_s   : std_logic_vector(7 downto 0);
	signal dataEn_n_s  : std_logic;
	signal dataEnDly_n_s  : std_logic;
	signal dataWr_n_s  : std_logic;
	signal dataWr_s  : std_logic;
 
	signal instAddr_s  : std_logic_vector(10 downto 0);
	signal instData_s  : std_logic_vector(31 downto 0);
	signal instEn_n_s  : std_logic;
 
	signal gpio_in_s   : std_logic_vector(7 downto 0);
	signal gpio_out_s  : std_logic_vector(7 downto 0);
	signal gpio_dir_s  : std_logic_vector(7 downto 0);
 
	signal stall_n_s   : std_logic := '1';
	signal stalled_n_s : std_logic;
 
	signal ioAddr_s     : std_logic_vector(7 downto 0) := (others => '0');
	signal ioDataIn_s   : std_logic_vector(7 downto 0) := (others => '0');
	signal ioDataOut_s  : std_logic_vector(7 downto 0);
	signal ioWrEn_n_s   : std_logic                    := '1';
	signal ioRdEn_n_s   : std_logic                    := '1';
 
	signal irqLine_s    : std_logic;
	signal irqLineAck_s : std_logic                    := '0';
 
	signal spiClk_s  : std_logic;
	signal spiCs_s   : std_logic;
	signal spiMosi_s : std_logic;
	signal spiMiso_s : std_logic := '0';
 
	signal dataInClk_s   : std_logic;
	signal dataOutClk_s  : std_logic;
 
	signal ioSymRdEn_n_s : std_logic;
 
	signal wurPattern_s  : std_Logic_vector(31 downto 0);
	signal wurMsk_s      : std_Logic_vector(31 downto 0);
	signal codeA_s       : std_logic;
	signal codeB_s       : std_logic;
 
	signal wurCodeEn_n_s : std_logic;
	signal wurCodeFin_s  : std_logic;
 
	signal rst_n_s     : std_logic                     := '1';
 
begin
 
	sysArch_i : sysArch
	port map(
		clk           => clk_s,
 
		-- instruction bus
		instMemAddr   => instAddr_s,
		instMemDataIn => instData_s,
		instMemEn_n   => instEn_n_s,
 
		-- data bus
		dataMemAddr    => dataAddr_s,
		dataMemDataIn  => dataIn_s,
		dataMemDataOut => dataOut_s,
		dataMemEn_n    => dataEn_n_s,
		dataMemWr_n    => dataWr_n_s,
 
		ioAddr         => ioAddr_s,
		ioDataIn       => ioDataIn_s,
		ioDataOut      => ioDataOut_s,
		ioWrEn_n       => ioWrEn_n_s,
		ioRdEn_n       => ioRdEn_n_s,
 
		irqLine        => irqLine_s,
		irqLineAck     => irqLineAck_s,
 
		-- general purpose IO
		gpio_in  => gpio_in_s,
		gpio_out => gpio_out_s,
		gpio_dir => gpio_dir_s,
 
		spi_clk  => spiClk_s,
		spi_cs   => spiCs_s,
		spi_mosi => spiMosi_s,
		spi_miso => spiMiso_s,
 
		stall_n        => stall_n_s,
		stalled_n      => stalled_n_s,
 
		rst_n         => rst_n_s
	);
 
	symDecoder_i: symDecoder
	port map (
		clk          => clk_s,
 
		codeA        => codeA_s,
		codeB        => codeB_s,
 
		ioAddr       => ioAddr_s(3 downto 0),
		ioWriteEn_n  => ioWrEn_n_s,
		ioReadEn_n   => ioSymRdEn_n_s,
 
		ioDataOut    => ioDataIn_s,
		ioDataIn     => ioDataOut_s,
 
		irq          => irqLine_s,
		irq_ack      => irqLineAck_s,
 
		rst_n        => rst_n_s
	);
 
	ioSymRdEn_n_s <= ioRdEn_n_s when ioAddr_s(7 downto 4) = "0100" else
			           '1';
 
	tb_wurCodeGen_i: wurCodeGen_tb
	port map (
		clk      => clk_s,
		pattern  => wurPattern_s,
		mask     => wurMsk_s,
		codeA    => codeA_s,
		codeB    => codeB_s,
		finished => wurCodeFin_s,
		rst_n    => wurCodeEn_n_s
	);
 
	tb_clock32kHz_i: lib_tb_clock32kHz
	port map (
		clk     => clk_s,
		rst_n   => rst_n_s
	);
 
	tb_rom32bit_i: lib_tb_rom32bit
	generic map ( fileName => "../programs/sha1Test.ihex" )
	port map (
		addr    => instAddr_s,
		dataOut => instData_s,
		en_n    => instEn_n_s
	);
 
	dataMem_i : dataMem
	port map (
		address   => dataAddr_s,
		data      => dataOut_s,
		inclock   => dataInClk_s,
		outclock  => dataOutClk_s,
		wren      => dataWr_s,
		q         => dataIn_s
	);
 
	dataWr_s <= not(dataWr_n_s);
 
	dataMemOutClk_delay_i: gendelay
		generic map (n => 5)
		port map (
			a_in	=> dataEn_n_s,
			a_out	=> dataEnDly_n_s
		);
 
	dataInClk_s <= '1' when (dataEn_n_s = '0' and dataEnDly_n_s = '1' and dataWr_n_s = '1') or
	                        (dataEn_n_s = '0' and dataEnDly_n_s = '0' and dataWr_n_s = '0') else
	               '0';
	dataOutClk_s <= not(dataInClk_s);
 
 
	wurGen_p : process
	begin
		wurMsk_s     <= x"ffffffff";
		wurPattern_s <= x"abababab";
		wurCodeEn_n_s <= '0';
 
		loop
			wait on rst_n_s;
			exit when rst_n_s = '1';
		end loop;
 
		loop
			wait for 100 ms;
 
			wurCodeEn_n_s <= '1';
 
			loop
				wait on wurCodeFin_s;
				exit when wurCodeFin_s = '1';
			end loop;
 
			wurCodeEn_n_s <= '0';
		end loop;
	end process;
 
end beh;
 
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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