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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [tb_d.vhd] - Rev 9

Compare with Previous | Blame | View Log

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
 
use ieee.std_logic_textio.all;
use std.textio.all;
 
  ENTITY testbench IS
  END testbench;
 
  ARCHITECTURE behavior OF testbench IS 
 
COMPONENT xmatch_controller 
PORT
(
	rst_CODMU	: IN STD_LOGIC;
	clk_CODMU 	: IN STD_LOGIC;
	rst_HOST		: IN STD_LOGIC;
	clk_HOST 	: IN STD_LOGIC;
	din_HOST 	: IN STD_LOGIC_VECTOR(31 DOWNTO 0);
	wr_en_HOST 	: IN STD_LOGIC;
	rd_en_HOST 	: IN STD_LOGIC;
	dout_HOST 	: OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
	full_HOST 	: OUT STD_LOGIC;
	empty_HOST 	: OUT STD_LOGIC;
	command_CR_HOST	: in std_logic_vector(31 DOWNTO 0);
	status_CDI_HOST	: out std_logic_vector(31 DOWNTO 0)
);
END COMPONENT;
 
  --Inputs
 
	signal rst_CODMU : std_logic := '0';
	signal clk_CODMU : std_logic := '0';
 
	signal rst_HOST : std_logic := '1';
	signal clk_HOST : std_logic := '0';
 
	signal din_HOST : std_logic_vector(31 downto 0) := (others => '0');
	signal wr_en_HOST : std_logic := '0';
	signal rd_en_HOST : std_logic := '0';
 
 
signal command_CR_HOST : std_logic_vector(31 downto 0) := (others => '0');
 
 	--Outputs
 
   signal dout_HOST : std_logic_vector(31 downto 0);
   signal full_HOST : std_logic;
   signal empty_HOST : std_logic;
 
	signal status_CDI_HOST : std_logic_vector(31 downto 0);
 
   -- Clock period definitions
   constant clk_CODMU_period : time := 10 ns;
   constant clk_HOST_period : time := 10 ns;
 
	-- others
	signal tlast_boolean : boolean := false;
 
  BEGIN
 
  -- Component Instantiation
          uut: xmatch_controller PORT MAP(	
		clk_CODMU 			=> clk_CODMU,
		rst_CODMU			=> rst_CODMU,
		clk_HOST 			=> clk_HOST,
		rst_HOST			=> rst_HOST,
		din_HOST 			=> din_HOST,
		wr_en_HOST 			=> wr_en_HOST,
		rd_en_HOST 			=> rd_en_HOST,
		dout_HOST 			=> dout_HOST,
		full_HOST 			=> full_HOST,
		empty_HOST 			=> empty_HOST,
		command_CR_HOST 			=> command_CR_HOST,
		status_CDI_HOST	=> status_CDI_HOST
          );
 
   clk_CODMU_process :process
   begin
		clk_CODMU <= '1';
		wait for clk_CODMU_period/2;
		clk_CODMU <= '0';
		wait for clk_CODMU_period/2;
   end process;
 
   clk_HOST_process :process
   begin
		clk_HOST <= '1';
		wait for clk_HOST_period/2;
		clk_HOST <= '0';
		wait for clk_HOST_period/2;
   end process;
 
 
--
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION START HERE --------------------------
--
	WRITE_CMD_D : process
	begin
 
	wait for clk_CODMU_period*2;
	-- command_CR_HOST_HOST (32-bit):
	-- addr (4-bit) & ctrl (4-bit) & trhshold (8-bit) & blocksize (16-bit)
----	command_CR_HOST	<= "10011000000010000000001000000000"; -- BlockSize 512
----	command_CR_HOST	<= "10011000000010000000010000000000"; -- BlockSize 1024
----	command_CR_HOST	<= "10011000000010000000100000000000"; -- BlockSize 2048
----	command_CR_HOST	<= "10011000000010000001000000000000"; -- BlockSize 4096
----	command_CR_HOST	<= "10011000000010000010000000000000"; -- BlockSize 8192
----	command_CR_HOST	<= "10011000000010000100000000000000"; -- BlockSize 16384
----	command_CR_HOST	<= "10011000000010001000000000000000"; -- BlockSize 32768
--
--	-- addr(4) & ctrl(4) & trhshold(8) & reserved (16)
	command_CR_HOST	<= "1001100000001000" & "0000000000000000";
--	
	wait for clk_CODMU_period*50;
--	command_CR_HOST 	<= "00000000000000101000111001100000"; -- U_alice_167520.txt file
--	--command_CR_HOST 	<= "00000000000000000010000000000000"; -- U_alice_8192.txt file
--	--command_CR_HOST 	<= "00000000000000000010000000000000"; -- U_alice_8192.txt file
--	--command_CR_HOST 	<= "00000000000000001000000000000000"; -- this is the file U_alice_32768.txt
command_CR_HOST 	<= "00000000000000000001111100000000"; -- this is the file 7936 bytes
--												 
	wait for clk_CODMU_period*50;
	command_CR_HOST	<= "00000000000000000000000000000000";
	wait;
	end process;
--	-- DECOMPRESS
	WRITE_D: process
--
--	--file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_32768_NEW_BLOCKSIZE" & ".txt";
	file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_167520_NEW_BLOCKSIZE" & ".txt"; -------------- simulate 1000us
--	--file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_8192_NEW_BLOCKSIZE" & ".txt";
--	--file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
	variable LIN : line;
	variable SPACE : character;
	variable tdata_file : std_logic_vector(31 downto 0);
	variable tlast_file : std_logic;
--	
   begin		
--	
	wait for 0 ns;	
--	
	rst_CODMU <= '1';
	rst_HOST <= '1';
	wait for clk_CODMU_period*1;
 
	wr_en_HOST <= '0';
 
	wait for clk_CODMU_period*1;
 
	rst_HOST <= '1';
	wait for clk_CODMU_period*1;
	rst_HOST <= '1';
 
 
	while ((not(endfile(INPUT_FILE_txt)))) loop	
 
	if (full_HOST ='0') then
		readline(INPUT_FILE_txt , LIN);
		read(LIN , tdata_file);
		read(LIN , SPACE);
		read(LIN , tlast_file);
 
		wait for clk_HOST_period;
 
			din_HOST <= tdata_file;
			wr_en_HOST <= '1';
 
		--command_CR_HOST_HOST	<= "00000000000000000000000000000000";
--		if tlast_file /= '0' then
----			tlast_boolean <= false;
----		else
----			tlast_boolean <= true;
----		end if;
	else
		wait for clk_HOST_period;
		wr_en_HOST <= '0';
	end if;
 
	end loop;
--		
		wait for clk_HOST_period;
		wr_en_HOST <= '0';
		wait;
--	 
   end process;
--
	READ_D: process
--	
   file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_32768_NEW_BLOCKSIZE" & ".txt";
--	file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_167520_NEW_BLOCKSIZE" & ".txt";
--	--file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_8192_NEW_BLOCKSIZE" & ".txt";
--	--file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
   variable  outline  : line;   --line number declaration  
	variable    linenumber : integer:=1; 
	variable C_DATAOUT_std_temp : std_logic_vector(31 downto 0) := x"FFFFFFFF";
--	
	begin						 
--	
	rd_en_HOST <= '0';
	wait for 0 ns;
	wait for clk_HOST_period*1;
--		
	while ((empty_HOST ='0')) loop	
--		
		rd_en_HOST <='1';		
		wait for clk_HOST_period;
		rd_en_HOST <='0';		
		wait for clk_HOST_period;
		C_DATAOUT_std_temp := dout_HOST;
		write(outline, C_DATAOUT_std_temp);
		writeline(OUTPUT_FILE_txt, outline);
		linenumber := linenumber + 1;
--
--		
	end loop;	   
 
	end process;
--
--	
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION END HERE --------------------------
 
 
  END;
 

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.