VHDL - Johnson Counter - Simulation Output with 'U's

OP (Company: none) #2951180
Hello all. I've been coding a Johnson Counter like the following:

1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5

6
entity johnson is
7
generic (n : natural := 4);
8
port (clk, enable : in std_logic;
9
      count : out std_logic_vector (n-1 downto 0));
10
end johnson;
11

12
architecture behavioural of johnson is
13
signal reg_john, nxt_john : std_logic_vector (n-1 downto 0);
14
begin
15
   process (clk)
16
   begin
17
      if (clk'event and clk='1') then
18
         if (enable='1') then
19
            reg_john<=nxt_john;
20
         end if;
21
      end if;
22
   end process;
23
   process (reg_john)
24
   begin
25
      nxt_john<=reg_john (n-2 downto 0) & not reg_john (n-1);
26
   end process;
27
   count<=reg_john;
28
end behavioural;


The synthetization was OK. The thing is when I tried to simulate the 
code, all the outputs from the count were having the letter 'U'.

Please, take a look at the attached screenshot.

Note that "habilitacion" = "enable" and "cuenta" = "count".

What are those 'U's? How can I fix the simulation in order to work?

Thanks a lot.
Attached files:
Guest #2951216
'U'  is the value for "uninitialized". Think about, at which value your 
counter starts. You can't determine is from the source code? So the 
simulator can't either! ;-)

For the synthesiser, there is no value like 'U', only '0' and '1'. So it 
has to choose a value. Most likely it will use 0.
OP (Company: none) #2951231
Thanks Klaus, and I've also realized that the Xilinx Simulator has two 
kinds of options to simulate: "Behavioural Simulation" and "Post-Route 
Simulation", so I tried the last one in this case and it seemed to work.
Moderator (Company: Titel) #2951256
Both types of simulation will "work", if you just initialize the 
counters signal with  (others =>'0')
Don't work around some problem! Try to understand what's going on...

Reply

A question of your own? This thread is over 13 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.