I am learning VHDL for a University course.
My code:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity operations is
Port (x : in STD_LOGIC_VECTOR ( 2 downto 0) ;s : in STD_LOGIC_VECTOR (1 downto 0) ;
F : out STD_LOGIC_VECTOR (5 downto 0));
end operations;
architecture dataflow of operations is
begin
F(5)<= x(2)and x(1) and s(1) and (not s(0));
F(4)<= (x(2) and (not x(1)) and x(0) and (not s(0))) or (x(2) and x(0)and s(1) and (not s(0))) or ( x(2)and x(1) and s(1) and s(0));
F(3)<= (x(2) and (not x(1)) and x(0) and s(1)) or (x(2) and x(0)and s(1) and s(0)) or ((not x(2)) and x(1) and x(0) and s(1) and (not s(0)));
F(2)<= (x(2) and (not x(1)) and s(0)) or (x(2) and(not s(1)) and (not s(0))) or ((not x(2)) and x(1) and x(0) and s(0));
F(1)<= (x(2) and(not s(1)) and (not s(0))) or (x(1) and x(0)and (not s(1)) and ( not s(0))) or
((not x(2)) and (not x(1)) and x(0) and(not s(1)) and s(0)) or ((not x(2)) and x(1) and (not x(0)) and s(0))
or (x(1) and (not x(1)) and (not s(1)) and s(0)) ;
F(0)<= (x(2) and(not s(1)) and (not s(0))) or ((not X(0))and s(1) ) or (x(1) and (not s(0)) and (not x(0)))
or ((not x(2)) and (not x(1)) and x(0) and s(0));
end dataflow;
Test bench:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity testbench is
-- Port ( );
end testbench;
architecture Behavioral of testbench is
component operations
Port (x : in STD_LOGIC_VECTOR ( 2 downto 0) ;s : in STD_LOGIC_VECTOR (1 downto 0) ;
F : out STD_LOGIC_VECTOR (5 downto 0));
end component;
--INPUTS
signal x: std_logic_vector ( 2 downto 0);
signal s: std_logic_vector ( 1 downto 0);
signal F: std_logic_vector(5 downto 0);
begin
uut: operations port map(x=>x,s=>s,F=>F);
Stim_proc: process
begin
x<= "001";s<="00"; wait for 100ns;
end process;
END;
The x, s, and F values are U constantly.