⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmp_data_16bit.vhd

📁 XILINX memory interface generator. XILINX的外部存储器接口。
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--
-- pragma translate_off
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
-- pragma translate_on

entity   cmp_data_16bit  is
port(
     clk            : in std_logic;
     data_valid     : in std_logic;
     lfsr_data      : in std_logic_vector(31 downto 0);
     read_data      : in std_logic_vector(31 downto 0);
     rst            : in std_logic;
     led_error_output : out std_logic
     );
end   cmp_data_16bit;  

architecture   arc_cmp_data_16bit of   cmp_data_16bit    is

component OBUF 
	port(
	     O    :	out   STD_LOGIC;
	     I    :	in    STD_LOGIC
	     );
	end component;

--type state is (idle, flag_error);
--signal led_state     : state;

signal led_state     : std_logic;
signal valid         : std_logic;
signal error         : std_logic;
signal lfsr_0        : std_logic_vector(15 downto 0);
signal lfsr_1        : std_logic_vector(15 downto 0);
signal data_0        : std_logic_vector(15 downto 0);
signal data_1        : std_logic_vector(15 downto 0);
signal byte_err      : std_logic_vector(1 downto 0);
signal byte_err1     : std_logic_vector(1 downto 0);
signal valid_1       : std_logic;
signal val_reg       : std_logic;
signal read_data_reg : std_logic_vector(31 downto 0);


begin

--read_data_reg <= read_data;

process(clk)
begin
 if clk'event and clk = '1' then
  if rst = '1' then
    read_data_reg <= (others => '0');
  else
    read_data_reg <= read_data;
  end if;
 end if;
end process;

process (clk)
begin
 if clk'event and clk ='1' then
  if rst = '1' then
      valid_1 <= '0';
      valid <= '0';
  else
      valid_1 <= data_valid;
      valid <= data_valid;
  end if;
 end if;
end process;       

data_0 <= read_data_reg(15 downto 0);
data_1 <= read_data_reg(31 downto 16);
			
lfsr_0 <= lfsr_data( 15 downto 0 );
lfsr_1 <= lfsr_data(31 downto 16 );

process(clk)
begin
	if clk'event and clk = '1' then
		if (rst='1') then
                        byte_err  <= "00";
                        byte_err1 <= "00";
                        val_reg   <= '0';
		else
                                val_reg  <= valid;
				if (data_0(7 downto 0) /= lfsr_0(7 downto 0)) then
					byte_err(0) <= '1';
				else
					byte_err(0) <= '0';
				end if;
				if (data_1(7 downto 0) /= lfsr_1(7 downto 0)) then
					byte_err(1) <= '1';
				else
					byte_err(1) <= '0';
				end if;
					

				if (data_0(15 downto 8) /= lfsr_0(15 downto 8)) then
					byte_err1(0) <= '1';
				else
					byte_err1(0) <= '0';
				end if;
				if (data_1(15 downto 8) /= lfsr_1(15 downto 8)) then
					byte_err1(1) <= '1';
				else
					byte_err1(1) <= '0';
				end if;
		end if;
	end if;
end process;

error <= ( (byte_err(0) or byte_err(1) ) or
           (byte_err1(0) or byte_err1(1)) )
            and val_reg;

-- LED error output
process(clk)
begin
   if clk'event and clk = '1' then
	led_state <= (not rst and ( error or led_state));
   end if;
end process; 

led_error_output <= '0' when led_state = '1' else
                    '1';
              
	
end   arc_cmp_data_16bit;  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -