vhdl: implement magic number on receive

This commit is contained in:
Xiretza 2022-06-06 17:11:39 +02:00
parent 904f34f4d4
commit 4bced13726

View file

@ -45,7 +45,11 @@ architecture a of splink is
signal all_strands_written : std_logic; signal all_strands_written : std_logic;
signal some_strands_written : std_logic; signal some_strands_written : std_logic;
type receive_state_t is (FRAME_NUM, STRAND_NUM, DATA, DROP); -- "PIXL"
constant MAGIC_NUMBER : std_logic_vector(31 downto 0) := x"5049584c";
type receive_state_t is (MAGIC, FRAME_NUM, STRAND_NUM, DATA, DROP);
constant RESET_STATE : receive_state_t := MAGIC;
signal receive_state : receive_state_t; signal receive_state : receive_state_t;
begin begin
driver_gen: for i in 0 to NUM_STRANDS-1 generate driver_gen: for i in 0 to NUM_STRANDS-1 generate
@ -122,15 +126,22 @@ begin
end if; end if;
if reset then if reset then
receive_state <= STRAND_NUM;
clear_write_flags <= '1'; clear_write_flags <= '1';
receive_state <= RESET_STATE;
elsif udp_valid then elsif udp_valid then
if udp_last then if udp_last then
-- always resynchronize to start of packet -- always resynchronize to start of packet
receive_state <= STRAND_NUM; receive_state <= RESET_STATE;
end if; end if;
case receive_state is case receive_state is
when MAGIC =>
if udp_data = MAGIC_NUMBER then
receive_state <= STRAND_NUM;
else
receive_state <= DROP;
end if;
when STRAND_NUM => when STRAND_NUM =>
-- TODO udp_length, range check with MAX_STRAND_LEN -- TODO udp_length, range check with MAX_STRAND_LEN
num_pixels <= MAX_STRAND_LEN; num_pixels <= MAX_STRAND_LEN;