【发布时间】:2017-05-08 05:01:11
【问题描述】:
我是 vhdl 的新手,并试图用 5 条选择线为多路复用器制作测试台,但它给了我错误(代码很长,所以我只是复制了包含错误的部分)
代码:
library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity Mux_4_to_1_tb is
end Mux_4_to_1_tb;
architecture tb of Mux_4_to_1_tb is
component Mux_4_to_1 is
port( clock : in std_logic;
D0, D1, D2, D3 : in std_logic; -- the data lines D0=A0 D1=A1 D2=B0 D3=B1
S0, S1, S2, S3, S4 : in std_logic; -- the selector switches
F : out std_logic_vector(2 downto 0)
);-- the output
end component;
constant clockperiod : time := 20 ns;
signal D0, D1, D2, D3, S0, S1 , S2, S3, S4 , F : std_logic;
signal selectors : std_logic_vector(4 downto 0);
begin
mapping: Mux_4_to_1 port map(D0, D1, D2, D3, S0, S1, S2, S3, S4, F );
--Concurrent processes
process
begin
S0 <= '0'; S1 <= '0'; S2 <= '0'; S3 <= '0'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '0'; S3 <= '0'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '0'; S3 <= '1'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '0'; S3 <= '1'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '1'; S3 <= '0'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '1'; S3 <= '0'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '1'; S3 <= '1'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '0'; S2 <= '1'; S3 <= '1'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '0'; S3 <= '0'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '0'; S3 <= '0'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '0'; S3 <= '1'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '0'; S3 <= '1'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '1'; S3 <= '0'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '1'; S3 <= '0'; S4 <= '1';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '1'; S3 <= '1'; S4 <= '0';wait for clockperiod;
S0 <= '0'; S1 <= '1'; S2 <= '1'; S3 <= '1'; S4 <= '1';wait for clockperiod;
S0 <= '1'; S1 <= '0'; S2 <= '0'; S3 <= '0'; S4 <= '0';wait for clockperiod;
end process;
process(S4, S3, S2, S1, S0)
begin
selectors <= S0&S1&S2&S3&S4;
end process;
process
begin
--The "assert" keyword allows you to test certain
--conditions. In other words, the point of assertion is
--to allow you to inspect what you expect.
--Two test cases are presented here. Feel free
--to add your own cases.
--TEST 1
D0 <= '0';
D1 <= '1';
D2 <= '0';
D3 <= '1';
wait for clockperiod;
case selectors is
when "00000" =>
assert(F => "000") report "Error 1: 00000" severity error;
错误:
** 错误:E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(70): (vcom-1581) 中缀运算符“=”没有可行的条目。
** 错误:E:\ OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(70):类型错误将中缀表达式“=”解析为类型 std.STANDARD.BOOLEAN。
错误将我指向带有断言字的行。
我在代码末尾也收到此错误
代码:
when others =>
assert true;
end case;
end process;
end tb;
错误:
** 错误:E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(229):VHDL 编译器退出
错误将我指向此处的最后一行。
【问题讨论】:
-
你为什么有
assert true?它没用,它永远不会显示。也许是编译器错误的原因? -
assert(F => "000")是一个错误,F 是一个 std_logic 对象,没有=>运算符将其与字符串"000"作为兼容数组类型的值进行比较。删除多余的括号,您可能会收到更有意义的错误消息。修复似乎是针对“0”的关系测试(相等),注意到多路复用器的F输出端口 std_logic_vector 与其 std_logic 输入端口不一致。那么它真的是多路复用器吗?您没有提供Minimal, Complete and Verifiable example。信号F的声明可能有误。 -
存在涉及
F的语义错误。它被声明为 std_logic 对象,不能与“000”进行比较。如果没有看到Mux_4_to_1的代码,读者无法判断F应该是什么,在它的组件端口声明中它是一个std_logic_vector。将信号F声明更改为signal F: std_logic_vector (2 downto 0);表明mapping的参数存在问题,它缺少clock正式关联,缺少输出(F)不是错误。使用命名关联。添加时钟关联。修复断言条件(例如>=不是=>)。
标签: vhdl