crc.vhd

来自「很多仪器都输出同步时钟」· VHDL 代码 · 共 37 行

VHD
37
字号
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity crc is
   port (
   clk: in std_logic;
   reset_n:in std_logic;
   din: in std_logic;
   dout: out std_logic_vector(3 downto 0)
   );
end crc;

architecture crc_arch of crc is
signal d1,d2:std_logic;
signal d:std_logic_vector(3 downto 0):=(others =>'0');


begin
    d1 <= d(0) xor din;
    d2 <= d(3) xor '1';    
process(clk ,reset_n)
begin
    
    if (clk'event and clk ='1') then
      if (reset_n ='0') then -- 同步复位
         d <= (others => '0');-- CRC 码置零
      else
         if (d1 = '1') then
              d <= d1&d2&d(2 downto 1);
          elsif (d1 = '0') then
              d <= d1&d(3 downto 1);
          end if ;
      end if ;
      dout <=d;
 end if ;
end process ;
end crc_arch;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?