2016-04-18 27 views
-1
library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 

entity conv_enc is 
    Port (clk : in STD_LOGIC; 
      rst : in STD_LOGIC; 
      inp : in STD_LOGIC; 
      outp : out STD_LOGIC_VECTOR(3 DOWN TO 0)); 
end conv_enc; 

architecture Behavioral of conv_enc is 
begin 
process 
variable ff:std_logic_vector(3 down to 0); 
    begin 
    wait until rising_edge (clk) 
    if rst='1' then 
     ff<="0000"; 
    else 
     for i in 2 down to 0 loop 
     ff(i)<=ff(i+1); 
     end loop; 
     ff(3)<=inp; 
    end if; 
end process; 
outp(0) <= inp xor ff(1) xor ff(0) ; 
outp(1) <= inp xor ff(3) xor ff(2) xor ff(1) ; 
outp(2) <= inp xor ff(3) xor ff(2) xor ff(1) xor ff(0); 
end Behavioral; 

的错误说下面的VHDL代码帮助: HDLParsers:3481 - 图书馆工作没有单位。没有保存参考文件“xst/work/hdllib.ref”。 请帮助需要你在赛灵思工具

+1

您不应该使用'STD_LOGIC_UNSIGNED'或'STD_LOGIC_ARITH';你的代码不会执行任何算术运算,即使这样做了,你也可以使用'numeric_std'包。 –

回答

0

ff(3)<=inp;必须在else之后。

3

玛丽亚和scary_jeff给出部分解决方案存在几个误区:

你宣布在三个地方一系列down to,而不是downto

您错过了在该过程中终止等待语句的分号。

您试图读取进程之外的变量(在其范围之外)。

以下是你的代码纠正这些,特别是使FF的信号:

library ieee; 
use ieee.std_logic_1164.all; 
-- use IEEE.STD_LOGIC_ARITH.ALL; 
-- use IEEE.STD_LOGIC_UNSIGNED.ALL; 

entity conv_enc is 
    port (
     clk: in std_logic; 
     rst: in std_logic; 
     inp: in std_logic; 
     outp: out std_logic_vector(3 downto 0) -- WAS DOWN TO 
    ); 
end entity conv_enc; 

architecture behavioral of conv_enc is 
    signal ff: std_logic_vector(3 downto 0); -- variable used outside process 
begin 
    process 
     -- variable ff: std_logic_vector(3 downto 0); -- was down to 
    begin 
     wait until rising_edge (clk); -- was miaaing terminating semicolon 
     if rst = '1' then 
      ff <= "0000"; 
     else 
      for i in 2 downto 0 loop -- was down to 
       ff(i) <= ff(i + 1); 
      end loop; 
      ff(3) <= inp; 
     end if; 
    end process; 

    outp(0) <= inp xor ff(1) xor ff(0); 
    outp(1) <= inp xor ff(3) xor ff(2) xor ff(1); 
    outp(2) <= inp xor ff(3) xor ff(2) xor ff(1) xor ff(0); 

end architecture behavioral; 

注意未使用Synopsys的包被注释掉。

然后您的代码进行分析。

请注意,没有分配给outp(3)。

你的convolutionally encoder看起来不太正确,但那可能就是我。

没有提供刺激和预期结果的测试台,功能无法验证。