EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL - Johnson Counter - Simulation Output with 'U's


von burami s. (Company: none) (bur85x)


Attached files:

Rate this post
0 useful
not useful
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
entity johnson is
6
generic (n : natural := 4);
7
port (clk, enable : in std_logic;
8
      count : out std_logic_vector (n-1 downto 0));
9
end johnson;
10
11
architecture behavioural of johnson is
12
signal reg_john, nxt_john : std_logic_vector (n-1 downto 0);
13
begin
14
   process (clk)
15
   begin
16
      if (clk'event and clk='1') then
17
         if (enable='1') then
18
            reg_john<=nxt_john;
19
         end if;
20
      end if;
21
   end process;
22
   process (reg_john)
23
   begin
24
      nxt_john<=reg_john (n-2 downto 0) & not reg_john (n-1);
25
   end process;
26
   count<=reg_john;
27
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.

von Klaus (Guest)


Rate this post
0 useful
not useful
'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.

von burami s. (Company: none) (bur85x)


Rate this post
0 useful
not useful
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.

von Lothar M. (lkmiller) (Moderator)


Rate this post
0 useful
not useful
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...

von burami s. (Company: none) (bur85x)


Rate this post
0 useful
not useful
Thank you very much, Lothar, you're right.

I'm going to try it and see what happens. :)

von burami s. (Company: none) (bur85x)


Attached files:

Rate this post
0 useful
not useful
Here's the fixed Johnson Counter.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.