conversion: natural -> time

Discussion in 'VHDL' started by Simone Winkler, Apr 1, 2004.

  1. 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 Winkler, Apr 1, 2004
    #1
    1. Advertisements

  2. Simone Winkler

    Jim Lewis Guest

    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:
    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;
    >
    >
     
    Jim Lewis, Apr 1, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    16,420
  2. engsol
    Replies:
    2
    Views:
    1,175
    Dan Bishop
    Jan 26, 2004
  3. Replies:
    8
    Views:
    761
    Magnus Lycka
    Aug 5, 2005
  4. flamesrock
    Replies:
    8
    Views:
    806
    Hendrik van Rooyen
    Nov 24, 2006
  5. Ro
    Replies:
    3
    Views:
    482
    Lawrence Kirby
    Jan 26, 2005
  6. Summu82
    Replies:
    5
    Views:
    1,127
    Richard Heathfield
    Jun 7, 2006
  7. Replies:
    1
    Views:
    1,011
    Paul Boddie
    Mar 11, 2007
  8. Replies:
    2
    Views:
    636
Loading...