conversion: natural -> time

S

Simone Winkler

Guest
Hello!

I've got a simple question: I have to model a key with debounce. So I've got
to assign a value of type natural to a time in milliseconds.
My formular would be:

bounce_wait = nr_of_bounces/bounce_frequ * 1 ms;

I've got the code I did below, but it doesn't compile in the line where the
natural-time conversion is done. Also my resolution setting of modelsim is
ok - I'm using modelsim SE 5.5f.

The critical line is:
constant bounce_wait : time := nr_of_bounces/bounce_frequ * 1 ms;

Can you help me?

Thank you!!

____________________________________

library ieee;
use ieee.std_logic_1164.all;
use work.basic_pkg.all;

entity key is
generic(
bounce_frequ: natural;
nr_of_bounces: natural);
port(
in_terminal: in std_logic;
out_terminal: out std_logic;
key_status: in key_action
);
end entity key;

architecture behavioural of key is

signal out_terminal_sig: std_logic;
constant bounce_wait : time := nr_of_bounces/bounce_frequ * 1 ms;

begin

out_terminal <= '1' after bounce_wait when (in_terminal='1' and
key_status=pressed) else out_terminal_sig <= 'Z';


end architecture behavioural;
 
Simone,
I got it to compile. I did not find any issues with
bounce_wait. I did need to fix the syntax of the
assignment to out_terminal:

out_terminal <=
'1' after bounce_wait when (in_terminal='1' and key_status=pressed)
else 'Z'; -- note removed: "out_terminal_sig <="

If you still have problems with your constant, either upgrade
to a newer version of the tool or perhaps try adding parentheses:
constant bounce_wait : time := (nr_of_bounces/bounce_frequ) * 1 ms;
^ ^

Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:Jim@SynthWorks.com
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Simone Winkler wrote:

Hello!

I've got a simple question: I have to model a key with debounce. So I've got
to assign a value of type natural to a time in milliseconds.
My formular would be:

bounce_wait = nr_of_bounces/bounce_frequ * 1 ms;

I've got the code I did below, but it doesn't compile in the line where the
natural-time conversion is done. Also my resolution setting of modelsim is
ok - I'm using modelsim SE 5.5f.

The critical line is:
constant bounce_wait : time := nr_of_bounces/bounce_frequ * 1 ms;

Can you help me?

Thank you!!

____________________________________

library ieee;
use ieee.std_logic_1164.all;
use work.basic_pkg.all;

entity key is
generic(
bounce_frequ: natural;
nr_of_bounces: natural);
port(
in_terminal: in std_logic;
out_terminal: out std_logic;
key_status: in key_action
);
end entity key;

architecture behavioural of key is

signal out_terminal_sig: std_logic;
constant bounce_wait : time := nr_of_bounces/bounce_frequ * 1 ms;

begin

out_terminal <= '1' after bounce_wait when (in_terminal='1' and
key_status=pressed) else out_terminal_sig <= 'Z';


end architecture behavioural;
 

Welcome to EDABoard.com

Sponsor

Back
Top