VHDL顺序条件信号赋值语句错误

时间:2016-02-14 05:17:25

标签: vhdl quartus

在我的VHDL代码中,我在sig_out_real <= X"00" & sig_in when sig_in(7)='0' else X"ff" & sig_in;中有错误。

我认为这不是语法错误。但Quartus在那时显示错误。

我不明白为什么这是一个错误。

任何人都可以提供信息:

- 错误 -

  

错误(10500):S8BT16B.vhd(35)处文本“when”附近的VHDL语法错误;期待“;”

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
use ieee.std_logic_arith.all;
use work.fft_package.all;

entity S8BT16B is
port( 
    clk_50 : in std_logic;
    clk_baud : in std_logic;
    main_reset : in std_logic;
    enable : in std_logic;
    sig_in : in signed (7 downto 0);
    sig_out : out complex;
    valid_output : out std_logic
  );
end S8BT16B; 

architecture Behavioral of S8BT16B is
type state is (idle,start);
signal state_reg, next_state_reg : state;
signal sig_out_real : signed(15 downto 0);  
begin           
state_change : process(clk_50, main_reset)
begin
    if (main_reset = '1' or enable = '0') then
        state_reg <= idle;
    elsif (main_reset ='0' and enable = '1') then
        state_reg <= next_state_reg;
    end if;
end process;

S8BT16B_active : process(clk_baud, state_reg)
begin       
    if (state_reg = idle) then
        sig_out_real <="0000000000000000";
        sig_out <=(sig_out_real,"0000000000000000");
        next_state_reg <= start;
        valid_output <= '0';
    elsif (state_reg = start and enable = '1') then         
        sig_out_real <= X"00" & sig_in when sig_in(7)='0' else X"ff" & sig_in;
        sig_out <= (signed_converted_input, "0000000000000000");
        next_state_reg <= idle;
        valid_output <= '1';
    end if;     
end process;
end Behavioral; 

1 个答案:

答案 0 :(得分:2)

您的代码不会显示Minimal, Complete, and Verifiable example

软件包fft_package可能包含complex的类型声明。

signed_converted_input的声明也不存在。

顺序条件信号赋值语句仅在VHDL-2008中可用。

有一个很好的论据,即Synopsys软件包std_logic_arith和std_logic_signed与IEEE Std 1076-2008定义的软件包std_logic_1164不兼容。它们可能已被重新编写以适应std_logic_vector和std_ulogic向量的新定义,但如果它们在没有-2008兼容性的情况下工作则没有,而ALDEC没有一些严重的自动化。

如果传递-2008兼容性标志不能解决问题,那么您可以做的最简单的事情就是在if语句中用两个简单的信号赋值语句替换顺序条件信号赋值语句:

library ieee;
use ieee.std_logic_1164.all;
-- use ieee.numeric_std.all;
use ieee.std_logic_arith.all;

package fft_package is
    type complex is record
        sig_real:       signed (15 downto 0);
        sig_imaginary:  signed (15 downto 0);
    end record;
    constant signed_converted_input:    signed (15 downto 0) := (others => '0');
end package;

library ieee;
use ieee.std_logic_1164.all;
-- use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
use work.fft_package.all;

entity S8BT16B is
port( 
    clk_50:      in  std_logic;
    clk_baud:    in  std_logic;
    main_reset:  in  std_logic;
    enable:      in  std_logic;
    sig_in:      in  signed (7 downto 0);
    sig_out:     out complex;
    valid_output:  out std_logic
  );
end S8BT16B; 

architecture Behavioral of S8BT16B is
    type state is (idle,start);
    signal state_reg, next_state_reg:   state;
    signal sig_out_real:                signed(15 downto 0);  
begin  

state_change:  
process(clk_50, main_reset)
    begin
        if (main_reset = '1' or enable = '0') then
            state_reg <= idle;
        elsif (main_reset ='0' and enable = '1') then
            state_reg <= next_state_reg;
        end if;
    end process;

S8BT16B_active:  
    process(clk_baud, state_reg)
    begin       
        if state_reg = idle then
            sig_out_real <= "0000000000000000";
            sig_out <=(sig_out_real,"0000000000000000");
            next_state_reg <= start;
            valid_output <= '0';
        elsif state_reg = start and enable = '1' then         
            -- sig_out_real <= X"00" & sig_in when sig_in(7)='0' else
            --                 X"ff" & sig_in;
            if sig_in(7) = '0' then
                sig_out_real <= X"00" & sig_in;
            else 
                sig_out_real <= X"ff" & sig_in;
            end if;

            sig_out <= (signed_converted_input, "0000000000000000");
            next_state_reg <= idle;
            valid_output <= '1';
        end if;     
    end process;
end Behavioral; 

此代码分析,详细说明和模拟(显示没有长度不匹配而不考虑sig_in(7) = '0'),而未对其进行任何声明。长度在sig_out_real的分配中正确。

当然,如果没有看到你的包fft_package的实际内容声明语法和语义有效性不能绝对做出(虚假包和你修改过的代码彼此一致)。

相关问题