From 4bced13726b95b519a30827cbde8fd900af78eef Mon Sep 17 00:00:00 2001 From: Xiretza Date: Mon, 6 Jun 2022 17:11:39 +0200 Subject: [PATCH] vhdl: implement magic number on receive --- vhdl/splink.vhdl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vhdl/splink.vhdl b/vhdl/splink.vhdl index 0c210ee..cf585da 100644 --- a/vhdl/splink.vhdl +++ b/vhdl/splink.vhdl @@ -45,7 +45,11 @@ architecture a of splink is signal all_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; begin driver_gen: for i in 0 to NUM_STRANDS-1 generate @@ -122,15 +126,22 @@ begin end if; if reset then - receive_state <= STRAND_NUM; clear_write_flags <= '1'; + receive_state <= RESET_STATE; elsif udp_valid then if udp_last then -- always resynchronize to start of packet - receive_state <= STRAND_NUM; + receive_state <= RESET_STATE; end if; 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 => -- TODO udp_length, range check with MAX_STRAND_LEN num_pixels <= MAX_STRAND_LEN;