From 0f497e76e85b357ff3b950339cd1b5593e281cdb Mon Sep 17 00:00:00 2001 From: Xiretza Date: Mon, 6 Jun 2022 18:25:27 +0200 Subject: [PATCH] vhdl: implement bounds checking for strand number --- vhdl/splink.vhdl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vhdl/splink.vhdl b/vhdl/splink.vhdl index cf585da..ccd3062 100644 --- a/vhdl/splink.vhdl +++ b/vhdl/splink.vhdl @@ -146,10 +146,12 @@ begin -- TODO udp_length, range check with MAX_STRAND_LEN num_pixels <= MAX_STRAND_LEN; - -- FIXME bounds check - active_strand <= to_integer(unsigned(udp_data)); - - receive_state <= FRAME_NUM; + if unsigned(udp_data) >= NUM_STRANDS then + receive_state <= DROP; + else + active_strand <= to_integer(unsigned(udp_data)); + receive_state <= FRAME_NUM; + end if; when FRAME_NUM => if not some_strands_written then