I'm going straight to specifics.
I'm using Ubuntu 14.04LTS, GHDL compiler and GTKWave for simulation.
I have two files for simulating a simple 2-multiplexer: mux2.vhd and mux2_testbench.vhd
This is the code for mux2.vhd
-- Libraries
library ieee;
use ieee.std_logic_1164.all;
-- Entity declaration
entity mux2 is
port(
e0, e1 : in std_logic;
c : in std_logic;
output : out std_logic
);
end mux2;
-- Architecture declaration
architecture mux2_arch of mux2 is
begin
process (e0, e1, c)
begin
if c = '0' then
output <= e0;
else
output <= e1;
end if;
end process;
end mux2_arch;
Code for the testbench
--Libraries
library ieee;
use ieee.std_logic_1164.all;
--Empty entity for simulation
entity mux2_testbench is
end mux2_testbench;
architecture testbench_arch of mux2_testbench is
component test is
port(
c : in std_logic;
e0, e1 : in std_logic;
output : out std_logic
);
end component;
signal c: std_logic;
constant clk: time:=50 ns;
signal e0: std_logic;
signal e1: std_logic;
signal output: std_logic;
begin
lab: test
port map(
c => c,
e0 => e0,
e1 => e1,
output => output
);
process
begin
--Case 1: Control signal is low
c <= '0';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
wait for 100 ns;
--Case 2: Control signal is high
c <= '1';
e0 <= '0';
e1 <= '0';
wait for 100 ns;
e0 <= '0';
e0 <= '1';
wait for 100 ns;
e0 <= '1';
e0 <= '0';
wait for 100 ns;
e0 <= '1';
e0 <= '1';
end process;
end testbench_arch;
Things I'm doing:
I'm compiling via terminal without errors with: ghdl -a mux2.vhd and ghdl -a mux2_testbench.vhd
Then, I create the executable for the testbench: ghdl -e mux2_testbench
Finally, I create the vcd file I need to use gtkwave: ghdl -r mux2_testbench --vcd=test.vcd &
Simulation: gtkwave test.vcd
I have two problems with this code: 1. Even though I'm writing different values in signals e0 and e1, e1 shows nothing in the simulation. It's always '0'.
- Output signal shows value "U" in the simulation, I'm not even sure what this means and wasn't able to find anything clear in Google.
Thank you all in advance, pals.