aeneas81
Junior Member level 1
need help with this, pls
Dear all,
I've written the following process to calculate the crc-5 of an 11 bit data for usb purpose. it takes one data at a clock cycle and stores to a signal, then at the 12 clock cycle will perform the calculation. however, for some unknown reason, quartus II keep synthesized away my registers, and i couldn't get the correct output.
btw, i've read from book that variables does not hold it's value as signals do, but I've seen codes with variables that can hold its value over clock edge just like signal does, how come?
Thanks for your help and advice.
the crc-5 code i'm working on:
SIGNAL stuffed_dataSig : std_logic_vector(10 DOWNTO 0);
process (clk, rst, din)
variable stuffed_data : std_logic_vector(10 DOWNTO 0);
variable crc5_state : std_logic_vector(4 DOWNTO 0);
begin
if rst = '1' then
count <= 0;
out_crc5 <= "11111";
stuffed_dataSig <= "00000000000";
ELSIF clk'EVENT AND clk = '1' THEN
IF count < 11 then
-- get the input data
stuffed_dataSig(count)<= din;
count <= count+1;
-- to verify that data is being stored
testout <= stuffed_dataSig;
ELSIF count = 11 THEN -- calculate crc
stuffed_data := stuffed_dataSig;
crc5_state := "11111";
for i in 0 to 10 loop
crc5_state(0) := stuffed_data(i)xor crc5_state(4);
crc5_state(1) := crc5_state(0);
crc5_state(2) := crc5_state(1)xor crc5_state(4)xor stuffed_data(i);
crc5_state(3) := crc5_state(2);
crc5_state(4) := crc5_state(3);
end loop;
out_crc5 <= NOT crc5_state;
end if;
end if;
end process;
Dear all,
I've written the following process to calculate the crc-5 of an 11 bit data for usb purpose. it takes one data at a clock cycle and stores to a signal, then at the 12 clock cycle will perform the calculation. however, for some unknown reason, quartus II keep synthesized away my registers, and i couldn't get the correct output.
btw, i've read from book that variables does not hold it's value as signals do, but I've seen codes with variables that can hold its value over clock edge just like signal does, how come?
Thanks for your help and advice.
the crc-5 code i'm working on:
SIGNAL stuffed_dataSig : std_logic_vector(10 DOWNTO 0);
process (clk, rst, din)
variable stuffed_data : std_logic_vector(10 DOWNTO 0);
variable crc5_state : std_logic_vector(4 DOWNTO 0);
begin
if rst = '1' then
count <= 0;
out_crc5 <= "11111";
stuffed_dataSig <= "00000000000";
ELSIF clk'EVENT AND clk = '1' THEN
IF count < 11 then
-- get the input data
stuffed_dataSig(count)<= din;
count <= count+1;
-- to verify that data is being stored
testout <= stuffed_dataSig;
ELSIF count = 11 THEN -- calculate crc
stuffed_data := stuffed_dataSig;
crc5_state := "11111";
for i in 0 to 10 loop
crc5_state(0) := stuffed_data(i)xor crc5_state(4);
crc5_state(1) := crc5_state(0);
crc5_state(2) := crc5_state(1)xor crc5_state(4)xor stuffed_data(i);
crc5_state(3) := crc5_state(2);
crc5_state(4) := crc5_state(3);
end loop;
out_crc5 <= NOT crc5_state;
end if;
end if;
end process;