tags:

views:

132

answers:

3

Hi

I have the following code to count till 59. It starts off fine but after 31, starts to show ASCII characters like '(', '$', '#' etc., instead of numbers. Any idea where I'm going wrong?

LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;

entity counter is 
    port(clk: IN STD_LOGIC;
      secs:OUT INTEGER RANGE 0 to 59);
end counter;

architecture counter_behav of counter is
signal countSVal: INTEGER RANGE 0 to 59:=0;
begin

process(clk)
begin
if(rising_edge(clk)) then
    if(countSVal>=59) then
     countSVal <= 0;  
    else
     countSVal <= countSVal + 1;  
    end if;
    secs <= countSVal;
end if;
end process;
end counter_behav;
+1  A: 

I've no idea what vhdl is, however, it seems most likely that what ever you are using to observe the output is not showing you ASCII characters prior to 32 because those would be control characters, so it just compromises and shows you their values. Since 32 and over are printable characters it switches to using those because thats what the tool thinks the values are.

AnthonyWJones
VHDL is used to define hardware. It is used by chip designers.
Brian Carlton
+1  A: 

Since you aren't printing anything, I assume you are looking at this in a waveform viewer. Set the type shown to integer, you may have it as ASCII as AnthonyWJones said.

Brian Carlton
A: 

Insert additional signal:

signal my_char: character;

Then do the conversion from integer to character:

my_char <= character'val(countSVal);

Check my_char signal under debugger or in waveform viewer and you will see ASCII characters. I've checked it with Aldec Active-HDL 6.1.

Vova