EmbDev.net

Forum: FPGA, VHDL & Verilog 32 bits data_in and CRC7 VHDL code (*Urgent)


Author: Christopher Ang (chrisang)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi i would like to check if my code and waveform is correct for this

32 bits data_in
7 bits CRC
library ieee;
use ieee.std_logic_1164.all;

entity CRC7_32 is
port (data_in : in std_logic_vector (31 downto 0);
crc_en , rst, clk : in std_logic;
crc_out : out std_logic_vector (6 downto 0));

end CRC7_32;

architecture behavior of CRC7_32 is

signal crc_block: std_logic_vector (6 downto 0);
signal crc_next_state: std_logic_vector (6 downto 0);

begin

crc_out <= crc_block;

crc_next_state(0) <= crc_block(5) xor crc_block(6) xor data_in(0) xor data_in(4) xor data_in(7) xor data_in(8) xor data_in(12) xor data_in(14) xor data_in(15) xor data_in(16) xor data_in(18) xor data_in(20) xor data_in(21) xor data_in(23) xor data_in(24) xor data_in(30) xor data_in(31);
crc_next_state(1) <= crc_block(6) xor crc_block(0) xor data_in(1) xor data_in(5) xor data_in(8) xor data_in(9) xor data_in(13) xor data_in(15) xor data_in(16) xor data_in(17) xor data_in(19) xor data_in(21) xor data_in(22) xor data_in(24) xor data_in(25) xor data_in(31);
crc_next_state(2) <= crc_block(0) xor crc_block(1) xor data_in(2) xor data_in(6) xor data_in(9) xor data_in(10) xor data_in(14) xor data_in(16) xor data_in(17) xor data_in(18) xor data_in(20) xor data_in(22) xor data_in(23) xor data_in(25) xor data_in(26);
crc_next_state(3) <= crc_block(1) xor crc_block(2) xor crc_block(5) xor crc_block(6) xor data_in(0) xor data_in(3) xor data_in(4) xor data_in(8) xor data_in(10) xor data_in(11) xor data_in(12) xor data_in(14) xor data_in(16) xor data_in(17) xor data_in(19) xor data_in(20) xor data_in(26) xor data_in(27) xor data_in(30) xor data_in(31);
crc_next_state(4) <= crc_block(2) xor crc_block(3) xor crc_block(6) xor data_in(1) xor data_in(4) xor data_in(5) xor data_in(9) xor data_in(11) xor data_in(12) xor data_in(13) xor data_in(15) xor data_in(17) xor data_in(18) xor data_in(20) xor data_in(21) xor data_in(27) xor data_in(28) xor data_in(31);
crc_next_state(5) <= crc_block(3) xor crc_block(4) xor data_in(2) xor data_in(5) xor data_in(6) xor data_in(10) xor data_in(12) xor data_in(13) xor data_in(14) xor data_in(16) xor data_in(18) xor data_in(19) xor data_in(21) xor data_in(22) xor data_in(28) xor data_in(29);
crc_next_state(6) <= crc_block(4) xor crc_block(5) xor data_in(3) xor data_in(6) xor data_in(7) xor data_in(11) xor data_in(13) xor data_in(14) xor data_in(15) xor data_in(17) xor data_in(19) xor data_in(20) xor data_in(22) xor data_in(23) xor data_in(29) xor data_in(30);

process (clk,rst)

begin

if (rst = '1') then
crc_block <= b"0000000";
elsif (clk'EVENT and clk = '1') then
if (crc_en = '1') then
crc_block <= crc_next_state;
end if;
end if;
end process;
end architecture behavior;

Author: Omega (Guest)
Posted on:

Rate this post
0 useful
not useful
is ok

Author: Christopher Ang (chrisang)
Posted on:

Rate this post
0 useful
not useful
thank you. do you know the explanation on how does this code works? just 
a brief one

Author: do_your_work_yourself (Guest)
Posted on:

Rate this post
0 useful
not useful
no

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.