I am new to vhdl and trying to make testbench for multiplexer with 5 select lines but it gives me errors (the code is very long so I just copied the part which include the errors )
The code:
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:
** 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.
The error point me to the line with the assert word.
Also i get this error at the end of the code
code:
when others =>
assert true;
end case;
end process;
end tb;
Error:
** Error: E:\OneDrive\Engineering\Digital Circuit Design\TestBench.vhd(229): VHDL Compiler exiting
The error point me to the last line here.
assert true
? It's useless, it will never show. Maybe it is the reason for compiler error? – Staszekassert(F => "000")
is an error, F is a std_logic object there is no=>
operator to compare it to string"000"
as a value of a compatible array type. Remove the superfluous parentheses and you may get a more meaningful error message. The fix appears to be relational testing (equality) against '0' noting theF
output port std_logic_vector of the mux is inconsistent with it's std_logic input ports. Then again is it really a mux? You don't provide an Minimal, Complete and Verifiable example. The declaration of signalF
may be in error. – user1155120F
. It's declared as a std_logic object and can't be compared to "000". Without seeing he code forMux_4_to_1
a reader can't tell whatF
is supposed to be, in it's component port declaration it is a std_logic_vector. Changing the signalF
declaration tosignal F: std_logic_vector (2 downto 0);
shows a problem in the parameters formapping
, it's missing aclock
formal association, missing outputs (F
) aren't errors. Use named association. Add a clock association. Fix the assertion condition (e.g.>=
not=>
). – user1155120