详细说明时报告抛出类型不匹配错误

时间:2020-10-06 08:51:01

标签: vhdl

我正在尝试调试一些导致宽度可变不匹配问题的错误(下面的添加阶段)。

为此,我想使用report语句输出一些在这些变量宽度的计算中使用的变量。

但是,由于某种原因,即使是最简单的报告语句:

report "this is a message";

抛出此错误:

报告附近的语法错误

错误类型void与字符串文字不匹配

有什么想法会导致这种情况吗?


我在Xilinx Vivado中使用VHDL2008。

供参考的整个源文件:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.All;
use IEEE.math_real.all;
use work.functions.all;


entity averager is
    generic
    (
        buffer_len: positive := 32; -- MUST BE A POWER OF 2
        input_max: positive := integer'high / buffer_len -- Maximum value of one data input
    );
    port 
    (
        clk : in STD_LOGIC;
        tri : in STD_LOGIC; 
        reset: in std_logic;       
        data_in : in unsigned (get_min_counter_width(input_max) - 1 downto 0);
        avg_out : out unsigned (get_min_counter_width(input_max) - 1 downto 0)
     );
end averager;

architecture behavioral of averager is
    
    -- TODO - Add assert that buffer_len is power of 2


    constant input_width: positive := get_min_counter_width(input_max);
    constant accum_width: positive := get_min_counter_width(input_width * buffer_len); -- Done at synthesis time, perfomance non-critical
    constant avg_bitshift: positive := integer(ceil(log2(real(buffer_len)))); -- How much bitshift is needed for fast divide
    
    signal last_tri: std_logic := '0';
    
    subtype in_val is unsigned(input_width - 1 downto 0);
    type acc_buffer is array(buffer_len - 1 downto 0) of in_val;
    
    constant in_zero: in_val := to_unsigned(0,input_width);
    signal in_buffer: acc_buffer; -- Initialised in reset

    type state is (rst, idle, adding, writing);
    signal current_state: state := rst;
    signal next_state: state := rst;
    
    constant accum_zero: unsigned(accum_width - 1 downto 0) := to_unsigned(0,accum_width);
    signal accumulator: unsigned(accum_width - 1 downto 0) := accum_zero;
    

begin


    sync_proc: process(clk)
    begin
       if (rising_edge(clk)) then
           if (reset = '1') then
               last_tri <= '0';
                current_state <= rst;
            else
                last_tri <= tri;
                current_state <= next_state;
                if (last_tri = '0' and tri = '1') then
                    in_buffer <= in_buffer(in_buffer'high downto in_buffer'low + 1) & in_val(data_in);
                end if;
            end if;
        end if;
    end process;
    
    next_state_decode: process(current_state, tri)
    begin
       next_state <= current_state;
       case(current_state) is
           when rst =>
               next_state <= idle;
           when idle => 
               if (last_tri = '0' and tri = '1') then
                   next_state <= adding;
               end if;
           when adding =>
                   next_state <= writing;
           when writing =>
                   next_state <= idle;     
       end case;
    end process;
    
    output_decode: process(current_state)
    begin
       next_state <= current_state;
       case(current_state) is
           when rst =>
               next_state <= idle;
               for i in in_buffer'high downto 0 loop
                    in_buffer(i) <= in_zero;
               end loop;
           when idle => 

           when adding =>
               for i in in_buffer'high downto 0 loop
                    accumulator <= unsigned(accumulator) + resize(unsigned(in_buffer(i)),accum_width);
               end loop;
           when writing =>
                   avg_out <= accumulator(accumulator'high downto accumulator'low + avg_bitshift);     
       end case;
    end process;
    
    
    report "this is a message";
    


end behavioral;

1 个答案:

答案 0 :(得分:1)

report语句是一个顺序语句,只能在顺序块中使用。

您不能在体系结构代码中使用report语句,该语句仅用于并发语句。

report语句本身就是一个顺序语句。

assert语句可以在并发块中使用。如果断言为假,则将打印断言的report子句中的消息。

VHDL具有布尔类型的常量false,其值为False。因此,如果使用assert false,则将始终打印report子句中的消息。

因此,如果要在并发块中打印消息,也可以使用assert false report "your message";