新闻中心

EEPW首页>嵌入式系统>设计应用> 循环冗余校验码的单片机及CPLD实现

循环冗余校验码的单片机及CPLD实现

作者: 时间:2012-03-20 来源:网络 收藏

4冗余码的

冗余码的硬件,其速度更快,性能更好,而且只占用极少的内的资源。本人用Xilinx公司的XCV9536芯片,基于以下VHDL 代码,了8位CRC码生成电路。代码下VHDL代码,实现了8位CRC码生成电路。代码中,s_in为输入串行数据,q为输出CRC码,d_new为当前CRC码。
Library IEEE;
use IEEE.std_logic_1164.all;
entity crc is
port(clk,s_in,reset:in STD_LOGIC,q:out STD_LOGIC_VECTOR (7 downto 0));
end crc;
architecture crc_arch of crc is
signal t1,t2,t3:std_logic;
signal d_new:std_logic_vector(7 downto 0);
begin
t1=d_new(0)xor s_in; --t1为最低位与输入异或值
t2=d_new(4)xor '1';
t3=d_new(3)xor'1';
process(clk,reset)
begin
if clk event and clk='1'then
if reset='1'then
d_new=x0; --复位时,CRC码置零
elsif t1='1'then
d_new=t1d_new(7 downto 5)t2t3td_new(2 downto 1);--t1为1时的新CRC码
elsif t1='0'then
d_new=t1d_new(7 downto 1); --t1为0时的新CRC码
end if;
end if;
end process;
q=d_new;--输出CRC码
end crc_arch;

5 总结

基于以上介绍的8位冗余码的软件及硬件实现方法,可以设计各种类型的循环冗余校检方法。由上述例程可以看出,循环冗余码校验是一种可靠性高、易于实现的校验方法。


上一页 1 2 下一页

评论


相关推荐

技术专区

关闭