0

I emulated this VHDL code using GHDL in terminal, no errors occured, but when I imported .vcd file into GTKWAVE no signal shown up.

SCREENSHOT OF GTKWAVE

Desing Code:

Library ieee; Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;

entity EXO is
port (CLK, EN: in bit; SORTIE: out bit);
end entity;

architecture EXXO of EXO is

signal compt : integer range 0 to 7 ;
signal etat : bit;

begin

    process (CLK)
    begin
        if CLK'event and CLK = '1' then
            if EN = '1' then
                compt <= compt + 1;
                case etat is
                    when '0' => if compt = 3 then compt <= 0; SORTIE <= '1'; etat <= '1'; end if;
                    when '1' => if compt = 2 then compt <= 0; SORTIE <= '0'; etat <= '0'; end if;
                end case;
            end if;
        end if;
    end process;

end architecture;

EDIT: I am new to VHDL, so please bear with me.

I am required to complete this chronogram. The design code is given. I tried to create a Test bench for it, and here is the result: GTKWAVE Screenshot 2 Which is obviously an utter failure (Failed to show compt, etat, SORTIE).

Test Bench:

Library ieee; Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;

entity EXOtb is
end entity;

architecture EXXOtb of EXOtb is
    component EXO
    port (CLK, EN: in bit; SORTIE: out bit);
    end component;
    signal CLKtb, ENtb: bit;
    signal SORTIEtb: bit;


begin
    DUT: EXO port map (CLK => CLKtb, EN => ENtb, SORTIE => SORTIEtb ); 
    STIMULUS: process 
    
    begin
    CLKtb <= '0'; ENtb <= '0'; wait for 10 ns; 
    CLKtb <= '0'; ENtb <= '1'; wait for 10 ns; 
    CLKtb <= '1'; ENtb <= '1'; wait for 10 ns; 
    CLKtb <= '1'; ENtb <= '1'; wait for 10 ns; 


    assert false report "Reached End of test";
    wait;
    end process;

end architecture;

EDIT 3: Thanks to @user1155120's detailed answer, I believe I have solved the problem.

  • Instead of declaring CLK values manually, I have created a proper function for it.
  • For some reason, in order to show internal signals in GTKWAVE, You need to declare them as well in the test bench, honestly I don't know why.
  • By looking carefully into the design code, the input EN seems to refer to some enabling property, and the code runs only if EN is true, so in the test bench I gave it the value of 1. Also, that if EN = '1' then seems to be redundant and there is no need for since EN is always 1. I kept it as it is though.

The new Design Code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity EX is
    Port ( CLK : in  STD_LOGIC;
           EN : in  STD_LOGIC;
           SORTIE : out  STD_LOGIC);
end EX;

architecture Behavioral of EX is

signal compt : integer range 0 to 7 ;
signal etat : bit;

begin    -- Stimulus process
    process (CLK)
    begin
        if CLK'event and CLK = '1' then
            if EN = '1' then
                compt <= compt + 1;
                case etat is
                    when '0' => if compt = 3 then compt <= 0; SORTIE <= '1'; etat <= '1'; end if;
                    when '1' => if compt = 2 then compt <= 0; SORTIE <= '0'; etat <= '0'; end if;
                end case;
            end if;
        end if;
    end process;
end Behavioral;

Test Bench:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 

 
ENTITY EXTB IS
END EXTB;
 
ARCHITECTURE behavior OF EXTB IS 
 
    -- Component Declaration for the Unit Under Test (UUT)

    COMPONENT EX
    PORT(
         CLK : IN  std_logic;
         EN : IN  std_logic;
         SORTIE : OUT  std_logic
        );
    END COMPONENT;
        

    --Inputs
    signal CLK : std_logic := '0';
    signal EN : std_logic := '1';

    -- Inner
    signal compt : integer range 0 to 7 ;
    signal etat : bit;

    --Outputs
    signal SORTIE : std_logic;

    -- Clock period definitions
     constant CLK_period : time := 10 ns;
 
BEGIN
 
    -- Instantiate the Unit Under Test (UUT)
    uut: EX PORT MAP (
          CLK => CLK,
          EN => EN,
          SORTIE => SORTIE
        );

    -- Clock process definitions
    CLK_process :process
    begin
        CLK <= '0';
        wait for CLK_period/2;
        CLK <= '1';
        wait for CLK_period/2;
    end process;
     

    -- Stimulus process
    process (CLK)
    begin
        if CLK'event and CLK = '1' then
        if EN = '1' then
            compt <= compt + 1;
            case etat is
            when '0' => if compt = 3 then compt <= 0; SORTIE <= '1'; etat <= '1'; end if;
            when '1' => if compt = 2 then compt <= 0; SORTIE <= '0'; etat <= '0'; end if;
        end case;
        end if;
    end if;
    end process;

END;

GTKWAVE result (All signals are shown as required in the homework)

  • 1
    where's your testbench? How long did you run the simulation? (GTKwave shows from 0s to 0s so it's not surprising there's no data). Add the exact GHDL run command to the question (and mention the version of GHDL too) –  Feb 26 '21 at 16:01
  • @BrianDrummond I have edited the question Sir, please take a look at it. – Ali Bastami Feb 26 '21 at 16:53
  • That's progress ... you are running the simulation for a finite time now and seeing all the signals in the TB architecture. You just need to add the signals in the DUT architecture to the VCD dump too. Assuming you're using a recent ghdl (you still haven't told us) see https://ghdl.readthedocs.io/en/latest/using/Simulation.html#simulation-options –  Feb 26 '21 at 18:01
  • Now that you've completely changed your post your question is only found in the title. However we see this is a homework problem and you haven't specified what difficulty you're having producing the inputs from your testbench found in the [chronogram](https://i.stack.imgur.com/afZVH.png) [nor what doing so would mean](https://i.stack.imgur.com/feG6Y.png). Ask a specific question that will help you finish your assignment. –  Feb 26 '21 at 18:11
  • It's a struggle to describe what to do without doing it for you. Wait for half the clock period and assign clk the value of not clk. VHDL provides an impure function `now` with no parameter that returns the current simulation time followed by an if statement with three conditions (if/elsif/elsif) the first for the rising edge of en, the second for the falling edge of en, the third to stop the simulation executing wait with no timeout clause after the assertion. The return value of now is compared to projected times of events in a granularity of half clock periods in the three conditions. –  Feb 26 '21 at 18:50
  • As long as the third condition isn't met the process will loop, with a wait for half a clock period. This will cause the clock to transition every half clock period. These two comments describe one of many ways to produced stimuli for your device under test. –  Feb 26 '21 at 18:52
  • @user1155120 Thank you very much sir for your detailed answer, I was able to show all signals (_I really appreciate the fact that you didn't do the home work for me_), Now there are a couple of weird things going on: this `compt`signal shape almost looks like a chain instead of wave. Also, why do I have to duplicate the design code in the test-bench in order for it to run? isn't enough to declare `CLK` stimulus only? – Ali Bastami Feb 27 '21 at 10:51
  • It's not necessary or desirable here to duplicate your DUT process in the testbench. Your stimulus and clock processes are nothing like the single process I described by circumlocution. `The design code is given.` - don't modify it. You changed signal types to std_logic so you could a copy of the process in the testbench and drive from there as well as the DUT. The two drivers get resolved. Type bit doesn't allow multiple drivers. Undo the change and drive just CLK and EN from the testbench to match the chronogram. –  Feb 27 '21 at 17:57

0 Answers0