Files
es-abschlussprojekt/Hardware/axis_crc_alt copy.vhd
T
2025-02-01 20:28:53 +01:00

70 lines
2.0 KiB
VHDL

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity axis_crc is
generic (
CRC_WIDTH : positive := 32;
DWIDTH : positive := 16
);
port (
CLK : in std_logic;
RESETN : in std_logic;
-- for crc calculation
initial_value : in std_logic_vector(CRC_WIDTH-1 downto 0);
polynomial : in std_logic_vector(CRC_WIDTH-1 downto 0);
-- AXI Streaming Target Port
S_AXIS_TVALID : in std_logic;
S_AXIS_TDATA : in std_logic_vector(DWIDTH-1 downto 0);
S_AXIS_TLAST : in std_logic := '0';
S_AXIS_TREADY : out std_logic;
-- AXI Streaming Initiator Port
M_AXIS_TVALID : out std_logic;
M_AXIS_TDATA : out std_logic_vector(DWIDTH-1 downto 0);
M_AXIS_TLAST : out std_logic;
M_AXIS_TREADY : in std_logic
);
end entity;
architecture rtl of axis_crc is
type state_t is (DATA, CHECKSUM);
signal state : state_t := DATA;
signal M_AXIS_TVALID_sig : std_logic;
-- CRC-Pruefsumme
signal checksum : std_logic_vector(CRC_WIDTH-1);
begin
S_AXIS_TREADY <= M_AXIS_TREADY or (not M_AXIS_TVALID_sig) and (state=DATA);
process
begin
wait until rising_edge(CLK);
if RESETN = '0' then
state <= DATA;
checksum <= initial_value;
else
case state is
when DATA =>
if M_AXIS_TREADY = '1' or M_AXIS_TVALID_sig = '0' then
M_AXIS_TDATA <= S_AXIS_TDATA;
M_AXIS_TVALID <= S_AXIS_TVALID;
M_AXIS_TVALID_sig <= S_AXIS_TVALID;
M_AXIS_TLAST <= S_AXIS_TLAST;
end if;
when CHECKSUM =>
when others => null;
end case;
end if;
end process;
end architecture;