crc-16串行实现程序.txt

来自「这是一个编码器的实现的程序」· 文本 代码 · 共 28 行

TXT
28
字号
library ieee;
use ieee.std_logic_1164.all;
entity crc is
port(clk,s_in,reset:in std_logic;
       q:out std_logic_vector(15 downto 0));
end crc;
architecture crc_arch of crc is
signal t1,t2,t3:std_logic;
signal d_new:std_logic_vector(15 downto 0);
begin
t1<=d_new(0) xor s_in;
t2<=d_new(11) xor '1';
t3<=d_new(4) xor '1';
process(clk,reset)
begin
if clk'event and clk='1'then
if reset='1'then
d_new<="0000000000000000";
elsif t1='1'then
d_new<=t1&d_new(15 downto 12)&t2&d_new(10 downto 5)&t3&d_new(3 downto 1);
elsif t1='0'then
d_new<=t1&d_new(15 downto 1);
end if;
end if;
end process;
q<=d_new;
end crc_arch;
crc读数时q从小到大读数,因为移位存储器结构所致

⌨️ 快捷键说明

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