📄 cmp_data_8bit.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_8bit is
port(
clk : in std_logic;
data_valid : in std_logic;
lfsr_data : in std_logic_vector(15 downto 0);
read_data : in std_logic_vector(15 downto 0);
rst : in std_logic;
led_error_output : out std_logic;
data_valid_out : out std_logic
);
end cmp_data_8bit;
architecture arc_cmp_data_8bit of cmp_data_8bit 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(7 downto 0);
signal lfsr_1 : std_logic_vector(7 downto 0);
signal data_0 : std_logic_vector(7 downto 0);
signal data_1 : std_logic_vector(7 downto 0);
signal byte_err : std_logic;
signal byte_err1 : std_logic;
signal valid_1 : std_logic;
signal read_data_reg : std_logic_vector(15 downto 0);
signal val_reg : std_logic;
begin
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_valid_out <= valid;
data_0 <= read_data_reg(7 downto 0);
data_1 <= read_data_reg(15 downto 8);
lfsr_0 <= lfsr_data( 7 downto 0 );
lfsr_1 <= lfsr_data(15 downto 8 );
process(clk)
begin
if clk'event and clk = '1' then
if (rst='1') then
byte_err <= '0';
byte_err1 <= '0';
val_reg <= '0';
else
val_reg <= valid;
if (data_0(7 downto 0) /= lfsr_0(7 downto 0)) then
byte_err <= '1';
else
byte_err <= '0';
end if;
if (data_1(7 downto 0) /= lfsr_1(7 downto 0)) then
byte_err1 <= '1';
else
byte_err1 <= '0';
end if;
end if;
end if;
end process;
error <= (byte_err or byte_err1) 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 <= '1' when led_state = '1' else
'0';
end arc_cmp_data_8bit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -