From 5545f12e817e8d97950a3cba38031479035029f6 Mon Sep 17 00:00:00 2001 From: Romain Broucquart <romain.broucquart@synchrotron-soleil.fr> Date: Wed, 23 Mar 2022 08:35:47 +0100 Subject: [PATCH] Change CRC state machine * Do not allow to start CRC computation right after a result * CRC word counter up to 12 then roll over to 0 --- hdl/combpm_protocol_electron.vhd | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hdl/combpm_protocol_electron.vhd b/hdl/combpm_protocol_electron.vhd index 636a385..8a383f9 100644 --- a/hdl/combpm_protocol_electron.vhd +++ b/hdl/combpm_protocol_electron.vhd @@ -178,23 +178,25 @@ begin crc_reg <= C_CRCINIT; crc_cnt <= (others => '0'); elsif rising_edge(clk) then - if crc_cnt = 0 then - if flag_sop_inc = '1' then + case crc_cnt is + when "0000" => + if flag_sop_inc = '1' then + crc_cnt <= crc_cnt+1; + crc_reg <= C_CRCINIT; + else + crc_cnt <= (others => '0'); + end if; + when "1011" => + crc_reg <= crc_reg; crc_cnt <= crc_cnt+1; - crc_reg <= C_CRCINIT; - else - crc_cnt <= (others => '0'); - end if; - else - if crc_cnt = 10 then + when "1100" => + crc_reg <= crc_reg; crc_cnt <= (others => '0'); - else - crc_cnt <= crc_cnt +1; - end if; - crc_reg <= lfsr_c; - + when others => + crc_reg <= lfsr_c; + crc_cnt <= crc_cnt+1; + end case; - end if; end if; end process p_crc; -- GitLab