Altera_Forum
Honored Contributor
15 years agoHow to destuff can frame?
Hi,
I am trying to destuff can frame without using can controller. All i know about a can frame that 1) the normal size of can frame is 108 bits. If i have a max number of stuffed bits will be 130. 2) the stuffed bits can be in the area between SOF and CRC Sequence. I wrote some code but till now, it is not working. entity validation is port( clk : in std_logic; message_in : in std_logic_vector (129 downto 0); message_out : out std_logic_vector (129 downto 0); confirmation : out std_logic); end validation; architecture archi of validation is signal tmp2: std_logic_vector(129 downto 0); signal tmp: std_logic_vector(107 downto 0); begin process(message_in, tmp, clk) variable j : integer :=0 ; variable i : integer :=13 ; begin if (clk'event and clk='1') then tmp(12 downto 0) <= message_in(12 downto 0); if (j <= 107) then if ((message_in(i) /= message_in(i+1)) and (message_in(i) /= message_in(i+2)) and (message_in(i) /= message_in(i+3)) and (message_in(i) /= message_in(i+4)) and (message_in(i)/= message_in(i+5))) then tmp(j+16 downto j+13) <= message_in(i+4) & message_in(i+3) & message_in(i+2) & message_in(i+1); j:=j+4; i:=i+5; elsif ((message_in(i) = message_in(i+1)) or (message_in(i) = message_in(i+2)) or (message_in(i) /= message_in(i+3)) or (message_in(i) /= message_in(i+4)) or (message_in(i)/= message_in(i+5))) then tmp(j+13) <= message_in(i); j:=j+1; i:=i+1; end if; elsif (j > 107) then if (tmp(98 downto 96) = "101") then confirmation <='1'; tmp2<= message_in; end if; end if; end if; end process; message_out <= tmp2; end archi; I just want with this code check any bit, and then if it is like what i want just me pass the real message with the stuffes bits and send a confirmation signal. So is there anyone have an ideas or find smth wrong in my code.