导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→硬件:关于CRC的VHDL实现疑问,请指点

* 14932: 硬件:关于CRC的VHDL实现疑问,请指点

   tuoniao35 
tuoniao35发表的帖子 

 硬件:关于CRC的VHDL实现疑问,请指点
    书上和BBS上有很多此类介绍,比如用移位寄存器.
   我也曾仿真实现过,后来发现.书上介绍的大多是针对数据高位进,而CRC也是
高位出的情况.
   现在我面临一个数据低位进,要求CRC也低位出的问题,可是我怎么也调不出来.
   以下是高位进,高位出的程序,那位兄台可以改成低位数据进,CRC也是低位出呢?
   --**************************************************
   --CRC生成多项式为P(x)= X5+X4+X2+1(即110101)
   --**************************************************
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
--**************************************************
entity crc_5 is
port(
     rst   :  in std_logic;
     clk   :  in std_logic;
     din   :  in std_logic;
     crc_en:  in std_logic;    --其高电平要一直持续到din输入完毕
     dout  :  out std_logic
     );
end crc_5;

--**************************************************
architecture a of crc_5 is
     signal shift_reg   : std_logic_vector(4 downto 0);
 
begin     
     process(rst,clk)
     begin
           if(rst='1') then
              shift_reg<=(others=>'0');
           elsif clk'event and clk='1' then
              if crc_en='1' then
                 shift_reg(0)<=shift_reg(4) xor din;
                 shift_reg(1)<=shift_reg(0);
                 shift_reg(2)<=shift_reg(4) xor din xor shift_reg(1);
                 shift_reg(3)<=shift_reg(2);
                 shift_reg(4)<=shift_reg(4) xor din xor shift_reg(3);
              else
                 shift_reg<=shift_reg(3 downto 0)&'0';
                 dout<=shift_reg(4);
              end if;
           end if;
     end process;
     
end a;
--**************************************************


发表时间:2002年11月25日12:53:00

  
回复该帖

本主题共有 1 帖,分页:>>>>>该主题的所有内容[1]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

[上一篇帖子]:初学者:请问是否可以通过写网卡的寄存器使网线输出高电平或者低电平
[下一篇帖子]:闲聊:请大家帮我估个价如果有这样一个项目让你开发你觉得多少钱比较合适呢?我们要做的工作是设计电路板和