Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16558 Discussions

Help with a ssimple 0 to 3 counter using integers

Altera_Forum
Honored Contributor II
1,012 Views

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.

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
263 Views

Simulate in what? Modelsim? If so, select the trace, right-click, select format, and then decimal. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
263 Views

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 ---  

0 Kudos
Altera_Forum
Honored Contributor II
263 Views

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.

0 Kudos
Reply