集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1541|回复: 3

关于VHDL状态机的几个问题

[复制链接]
aky450 发表于 2012-5-18 23:25:48 | 显示全部楼层 |阅读模式
最近要做一个(15,7)BCH码的编译码的仿真,要求用VHDL 实现,自己编的时候遇到了几个问题,望各位大侠帮帮忙,指导一下,我编的程序在下边。
问题(1):因为编译码分两个状态,编码和译码,条件是en=0时进行编码,en=1是进行译码,我遇到的问题就是不知道怎样用VHDL语言实现状态的转换;
问题(2):译码时,因为不知道接收码组是否正确,所以要求出接收码组的校正子S。又因为校正子S与错误样本E从在一一对应的关系,所以我的思路是将所有可能出现的错误样本E通过数学运算得到校正子S,然后与接收码组求得的校正子S对比,从而得到接收码组的错误样本,然后接收码组减去错误样本就是正确的编码。我遇到的问题就是接收码组计算得到校正子S如何从所有可能的S中取出对应的错误样本。
***********************************************************

library ieee;
use ieee.std_logic_1164.all;
entity scsbch is
port
                (   en : in std_logic;
                   clk : in std_logic;
                 input : in std_logic_vector(14 downto 0);
                output : out std_logic_vector(14 downto 0);
                     s : out std_logic_vector(7 downto 0));
end ;

architecture bhv of scsbch is
type states is (st0, st1);
signal encode_state,decode_state: state:
signal oe : std_logic_vector(14 downto 0);
signal od : std_logic_vector(14 downto 0);

begin
process(clk,en) begin
  if en = '0' then encode_state <= st0;
  elsif clk'event and clk = '1' then
    decode_state <= encode_state;
   end if;
end process;

com : process(encode_state,input)
begin
case encode_state is
when st0 => en <= '0';
oe(14 downto 8)<=input(6 downto 0);
oe(7)<=input(6) xor input(2) xor input(0);
oe(6)<=input(6) xor input(5) xor input(2) xor input(1) xor input(0);
oe(5)<=input(6) xor input(5) xor input(4) xor input(2) xor input(1);
oe(4)<=input(5) xor input(4) xor input(3) xor input(1) xor input(0);
oe(3)<=input(6) xor input(4) xor input(3);
oe(2)<=input(5) xor input(3) xor input(2);
oe(1)<=input(4) xor input(2) xor input(1);
oe(0)<=input(3) xor input(1) xor input(0);          --编码
when st1 => en <='1';
s(7)<=input(7) xor input(8)  xor input(10) xor input(14) ;
s(6)<=input(6) xor input(8)  xor input(9)  xor input(10) xor input(13) xor input(14);
s(5)<=input(5) xor input(9)  xor input(10) xor input(12) xor input(13) xor input(14);
s(4)<=input(4) xor input(8)  xor input(9)  xor input(11) xor input(12) xor input(13);
s(3)<=input(3) xor input(11) xor input(12) xor input(14) ;
s(2)<=input(2) xor input(10) xor input(11) xor input(13) ;
s(1)<=input(1) xor input(9)  xor input(10) xor input(12) ;
s(0)<=input(0) xor input(8)  xor input(9)  xor input(11) ;

od(14 downto 0)<=
    "000000000000000"WHEN S="00000000" ELSE
        "000000000000001"WHEN S="00000001" ELSE
        "000000000000010"WHEN S="00000010" ELSE
        "000000000000100"WHEN S="00000100" ELSE
        "000000000001000"WHEN S="00001000" ELSE
        "000000000010000"WHEN S="00010000" ELSE
        "000000000100000"WHEN S="00100000" ELSE
        "000000001000000"WHEN S="01000000" ELSE
        "000000010000000"WHEN S="10000000" ELSE
        "000000100000000"WHEN S="11010001" ELSE
        "000001000000000"WHEN S="01110011" ELSE
        "000010000000000"WHEN S="11100110" ELSE
        "000100000000000"WHEN S="00011101" ELSE
        "001000000000000"WHEN S="00111010" ELSE
        "010000000000000"WHEN S="01110100" ELSE
        "100000000000000"WHEN S="11101000" ELSE    --解码
        output<=input-od
end bhv;
yoyo_note 发表于 2012-5-18 23:30:56 | 显示全部楼层
编码:B 译码:Y

把B和Y都独立开来,en只做select,
两边的模块都调用同一个B和Y,同时看对方的s信号
 楼主| aky450 发表于 2012-5-18 23:43:00 | 显示全部楼层
这个我知道啊,我不知道的是用如何用VHDL语言表述出来
yoyo_note 发表于 2012-5-18 23:56:08 | 显示全部楼层
分几个层次
lvl 1 tb top
    Lvl 2 node1 node2
       Lvl3 ey ey

调用参考 vhdl port map
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-25 21:06 , Processed in 0.073198 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表