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

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

  
楼 主:tuoniao35 2002年11月25日12:53
 硬件:关于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;
--**************************************************


>>>>>>对该主题发表你的看法

本主题贴数1,分页: [第1页]


[上一篇主题]:初学者:请问是否可以通过写网卡的寄存器使网线输出高电平或者低电平

[下一篇主题]:闲聊:请大家帮我估个价