4

How can this error be fixed? PlanAhead 14.7 is able to synthesize but not simulate correctly for this simple counter. The instance "dut : countr port map" remains with a red question mark in the sources tab. I've made sure that all signals are instantiated correctly;tried re-adding sources;tried creating a new project. Working with IP cores can generate this problem apparently but I don't think I am.

Design source:

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity countr is
Port (clk : in std_logic;
      reset : in std_logic;
      output: out std_logic_vector(4 downto 0)
 );
end countr;

architecture Behavioral of countr is
signal count : std_logic_vector(4 downto 0);
BEGIN

proc_1: process(clk, reset)
begin
    if reset = '1' then
        count <= (others => '0');
    elsif rising_edge(clk) then
        count <= std_logic_vector(unsigned(count) + 1);
    end if;
end process;
output <= count;
END Behavioral;

Simulation source:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity cntr_TB is end cntr_TB;
architecture Behavioral of cntr_TB is
component countr is
port(clk  : in std_logic;
    reset : in std_logic;
    output: out std_logic_vector(4 downto 0)
 );
end component;
signal clk : std_logic := '0';
signal reset : std_logic := '1';
signal output : std_logic_vector(4 downto 0) := "00000";
signal endOfSim : boolean := false;      
constant period : time := 20 ns;
BEGIN
dut: countr port map (clk => clk, reset => reset, output => output);
clkStimulus: process(clk)
begin
    if endOfSim = false then
        clk <= not clk after period/2;
    end if;
end process;
stim: process
begin
wait for 40 ns;
reset <= '0';
wait;
end process;
END Behavioral;
chilipepper
  • 105
  • 1
  • 10
  • The code is fine and simulates in Modelsim. You might try starting a simulation directly on the `countr` entity to ensure it loads into ISIM properly without the testbench. – Kevin Thibedeau Apr 15 '14 at 19:10
  • The last `wait;` simulates forever in ISIM. Think of replacing it with a wait time. – N8TRO Apr 15 '14 at 19:17
  • 2
    @N8TRO. The final wait causes the stim process to stop running which is normally desirable. What is missing is an assignment `endOfSim <= true;` to stop the clock but it isn't the cause of the problem. If that is done then a `wait for` is needed to let more cycles pass before the clock stops. – Kevin Thibedeau Apr 15 '14 at 21:45
  • Have you tried removing your `component` and using direct instantiation - you might get more helpful error messages – Martin Thompson Apr 16 '14 at 10:40
  • @Martin Thompson : does this mean using a package to define `countr`? – chilipepper Apr 17 '14 at 09:09
  • No, you don't have a `component` statement at all, and then you write `dut: entity work.countr port map (...etc);` (see here: http://www.people.vcu.edu/~rhklenke/tutorials/vhdl/modules/m11_23/sld018.htm) – Martin Thompson Apr 17 '14 at 09:18
  • Okay, I've no component in the testbench. I've placed `library work; use work.countr.all;` & `dut: entity work.countr port map (clk => clk,reset => reset,output => output);` into the testbench. I received an error : `Cannot find in library . Please ensure that the library was compiled, and that a library and a use clause are present in the VHDL file.` – chilipepper Apr 17 '14 at 10:42

1 Answers1

2

I deleted and re-added design & simulation sources, which still left the black-box. I opened a new project and added the sources before the project was created and the simulation ran without a problem.

chilipepper
  • 105
  • 1
  • 10