我是新来的VHDL和试图使测试平台进行多路复用器与5条选线,但它给我的错误(代码是很长,所以我只是复制,其中包括错误的部分)VHDL多路复用器测试台误差
的代码:
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;
错误:
** Error: E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(70): (vcom-1581) No feasible entries for infix operator '='.
** Error: E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(70): Type error resolving infix expression "=" as type std.STANDARD.BOOLEAN.
错误指向我与断言字线。
而且我得到这个错误的代码结束
代码:
when others =>
assert true;
end case;
end process;
end tb;
错误:
** Error: E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(229): VHDL Compiler exiting
错误指向我的最后一行在这里。
为什么你有'assert true'?这是无用的,它永远不会显示。也许这是编译器错误的原因? – Staszek
'assert(F =>“000”)'是一个错误,F是一个std_logic对象,没有'=>'操作符将它与字符串“000”比较为兼容数组类型的值。删除多余的圆括号,您可能会收到更有意义的错误消息。该修复似乎是针对'0'的关系测试(相等),注意多路复用器的“F”输出端口std_logic_vector与其std_logic输入端口不一致。那么它又是一个多路复用器吗?您不提供[最小,完整和可验证示例](https://stackoverflow.com/help/mcve)。信号“F”的声明可能有误。 – user1155120
有一个涉及'F'的语义错误。它被声明为std_logic对象,不能与“000”进行比较。没有看到他为'Mux_4_to_1'编写代码,读者不知道'F'应该是什么,在它的组件端口声明中它是一个std_logic_vector。将信号'F'声明更改为'signal F:std_logic_vector(2 downto 0);'显示'mapping'参数存在问题,缺少'clock'正式关联,缺少输出('F')错误。使用命名关联。添加时钟关联。修正断言条件(例如'> ='not'=>')。 – user1155120