- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am trying to design a counter from 0 to 3 using integers. The code that I used is belowlibrary IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Counter is
Port ( C : out integer range 0 to 3;
clk : in STD_LOGIC;
Reset : in STD_LOGIC;
end Counter;
architecture Behavioral of Counter is
signal count : integer range 0 to 3;
begin
process(Reset, clk)
begin
if Reset = '1' then
count <=0;
elsif Rising_edge(clk) then
if count < 3 then
count <= count +1;
else
count <= 0;
end if;
end if;
end process;
c <= count;
end Behavioral;
I want the output 'c' to display 0,1,2,3 but when I simulate it the 'c' gives 0,1,10,11. I am declaring 'c' right or do I need to use another type? Any advice is welcome, thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simulate in what? Modelsim? If so, select the trace, right-click, select format, and then decimal.
Cheers, Dave- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using ISE Project Navigator, it has it's own sim called ISim.
--- Quote Start --- Simulate in what? Modelsim? If so, select the trace, right-click, select format, and then decimal. Cheers, Dave --- Quote End ---- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Select 'c' in the wave window, right click it and you will have option to change the display format like decimal, unsigned, Hexadecimal. you can choose there.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page