Declaring constants

Discussion in 'VHDL' started by ALuPin@web.de, May 29, 2006.

  1. Guest

    Hi VHDL people,

    I have declared the following global signals in a package:
    TYPE typeRES_1920x1200 IS
    RECORD
    X : integer;
    Y : integer;
    HTOTAL : integer;
    HFP : integer;
    HST : integer;
    HBP : integer;
    VTOTAL : integer;
    VFP : integer;
    VST : integer;
    VBP : integer;
    END RECORD;
    SIGNAL RES_1600x1200 : typeRES_1600x1200 :=
    (1600,1200,2160,64,192,304,1250,1,3,46);

    SIGNAL RES_XxY : typeRES_1920x1200 := (0,0,0,0,0,0,0,0,0,0);

    In my main testbench (use showed package)
    I make the following assignment:

    process
    begin
    if condition=... then
    RES_XxY <= RES_1600x1200;
    end if;
    wait until rising_edge(clock);
    -- NOW I call a procedure which is declared in a separate
    package
    generate_dvi_frame (....);
    wait;
    end process,

    In the procedure generate_dvi_frame I make the following assignments:

    PROCEDURE generate_dvi_frame
    ( SIGNAL pClock : std_logic;
    SIGNAL pHSyncPol : std_logic;
    SIGNAL pVSyncPol : std_logic;
    SIGNAL pOutScdt : OUT std_logic;
    SIGNAL pOutDe : OUT std_logic;
    SIGNAL pOutHSync : OUT std_logic;
    SIGNAL pOutVSync : OUT std_logic) IS
    CONSTANT X : integer := RES_XxY.X;
    CONSTANT Y : integer := RES_XxY.Y;
    CONSTANT HTOTAL : integer := RES_XxY.HTOTAL;
    CONSTANT HFP : integer := RES_XxY.HFP;
    CONSTANT HST : integer := RES_XxY.HST;
    CONSTANT HBP : integer := RES_XxY.HBP;
    CONSTANT VTOTAL : integer := RES_XxY.VTOTAL;
    CONSTANT VFP : integer := RES_XxY.VFP;
    CONSTANT VST : integer := RES_XxY.VST;
    CONSTANT VBP : integer := RES_XxY.VBP;
    .....

    Is that possible / legal to assign signals to constants ?
    I need the constants because I use loops in the procedure:

    for j in 0 to Y loop
    ...
    end loop;

    Thank you for your opinion.

    Rgds
    André
     
    , May 29, 2006
    #1
    1. Advertisements

  2. Ajeetha Guest

    Any reason why you can't make that gloabl signal as a global constant
    instead?

    Ajeetha, CVC
    www.noveldv.com
     
    Ajeetha, May 30, 2006
    #2
    1. Advertisements

  3. Andy Guest

    Constants must be given a static value, but signal values are not
    static.

    You can initialize the constant with a function call that returns the
    initial value, but it must be a static function (one that does not use
    signals).

    Andy
     
    Andy, May 30, 2006
    #3
  4. Guest

    Ajeetha schrieb:

    > Any reason why you can't make that gloabl signal as a global constant
    > instead?
    >
    > Ajeetha, CVC
    > www.noveldv.com


    Hi Ajeetha,

    because I want to make a choice out of constants.

    For example : (in main testbench)

    process
    begin
    if condition1=... then
    RES_XxY <= RES_1600x1200;
    ELSIF condition2= ... then
    RES_XxY <= ...
    end if;
    wait until rising_edge(clock);
    generate_dvi_frame (....);
    wait;
    end process,

    .... whereas if I declared a global constant I could not use
    if ... elsif ...else
     
    , May 31, 2006
    #4
  5. Hi André,

    "" <> writes:
    > I need the constants because I use loops in the procedure:
    >
    > for j in 0 to Y loop
    > ...
    > end loop;


    If that's the only reason you need constants, you might be successful
    using the following construct. Assuming you are looking for testbench
    code, that is. This requires you to add a parameter of type
    typeRES_1920x1200 to the procedure declaration.

    ,----[ deep inside generate_dvi_frame ]
    | -- you might want to use type natural for the record elements
    | for j in 0 to integer'high loop
    | -- are you sure the loop range includes res.Y?
    | if (j > res.Y) then exit; end if;
    |
    | assert (j <= res.Y) report "Shouldn't trigger!" severity error;
    | end loop;
    `----

    -- Marcus
     
    Marcus Harnisch, May 31, 2006
    #5
  6. Guest

    Thanks to all.

    I think Marcus idea is fine.

    Rgds
    Andre
     
    , Jun 2, 2006
    #6
    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. Marius Vollmer
    Replies:
    6
    Views:
    914
    Jim Lewis
    Dec 10, 2003
  2. valentin tihomirov
    Replies:
    1
    Views:
    638
    Jonathan Bromley
    Feb 18, 2004
  3. Troy Knight

    declaring constants

    Troy Knight, Jul 25, 2004, in forum: Perl
    Replies:
    1
    Views:
    568
  4. Generic Usenet Account

    Declaring constants within the scope of a class

    Generic Usenet Account, Mar 15, 2005, in forum: C++
    Replies:
    5
    Views:
    3,700
    Howard
    Mar 15, 2005
  5. Sriram Chadalavada

    Defining/declaring constants in Python

    Sriram Chadalavada, Jul 28, 2003, in forum: Python
    Replies:
    2
    Views:
    4,500
    Michael Hudson
    Jul 29, 2003
Loading...

Share This Page