VHDL语法错误:With-Select语句

时间:2016-02-23 09:16:33

标签: vhdl modelsim

我正在尝试编译以下代码,

--data output
with counter select
    --select DATA_IN between 0 <= counter <= 55 select DATA_IN
    DATA_OUT    <=  DATA_IN     when ("000000" <= counter <= "110111"), 
    --select parity_reg(0) between 56<= counter <= 63 select parity
                parity_reg(0)   when ("111000" <= counter <= "111111"), 
                '0'     when others;

--busy output
with counter select
    --between 0 <= counter <= 63 assert BUSY_OUT 
    BUSY_OUT    <=  '1' when ("000000" <= counter <= "111111"), 
                '0' when others;

结束架构编码;

注意:我使用的是IEEE库,以及std_logic_1164和numeric_std包。 with-select语句不在进程内。

模拟Sim在编译期间显示的错误是

  

vhdl(61):near&#34;&lt; =&#34;:(vcom-1576)期待&#39;)&#39;。
  vhdl(69):near&#34;&lt; =&#34;:(vcom-1576)期待&#39;)&#39;。

有没有解决这个问题围绕着选择的construt本身?除了必须选择另一个并行语句,例如进程

2 个答案:

答案 0 :(得分:2)

直接的连续条件分配将完成这项工作:

--data output
--select DATA_IN between 0 <= counter <= 55 select DATA_IN
DATA_OUT    <=  DATA_IN         when (counter <= "110111") else 
--select parity_reg(0) between 56<= counter <= 63 select parity
                parity_reg(0)   when ("111000" <= counter) and (counter <= "111111") else
                '0';

--busy output
--between 0 <= counter <= 63 assert BUSY_OUT 
BUSY_OUT    <=  '1' when "000000" <= counter and counter <= "111111" else
                '0';

http://www.edaplayground.com/x/GH3

我已更改为条件连续分配,因为您的select语句不适用于此。即使你的表达式像

"000000" <= counter <= "111111"

是合法的VHDL,他们会评估为TRUE或FALSE,而您试图查看计数器是否在一定范围内。 (即计数器是它的任何类型,而表达式将计算为布尔值)。

如果你真的想使用select语句,那么无论“计数器”类型是什么,它都是不合适的,因为它是一个数组类型而不是标量。计数器必须是这项工作的标量类型,例如自然:

entity encode is
  port ( counter    : in  natural;

给了我们:

--data output
with counter select
--select DATA_IN between 0 <= counter <= 55 select DATA_IN
DATA_OUT    <=  DATA_IN         when 0 to 55, 
--select parity_reg(0) between 56<= counter <= 63 select parity
                parity_reg(0)   when 56 to 63, 
                '0'             when others;

--busy output
with counter select
--between 0 <= counter <= 63 assert BUSY_OUT 
BUSY_OUT    <=  '1' when 0 to 63, 
                '0' when others;                

http://www.edaplayground.com/x/5ED

这样,您就可以在select语句中使用范围。这将是非法的:

when "000000" to "110111",

答案 1 :(得分:1)

范围比较

("000000" <= counter <= "110111")
VHDL不支持

。您必须将范围比较分为2部分,

(("000000" <= counter) and (counter <= "110111"))