Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Declaring constants

 
Thread Tools Search this Thread
Old 05-29-2006, 02:54 PM   #1
Default Declaring constants


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é



ALuPin@web.de
  Reply With Quote
Old 05-30-2006, 05:26 PM   #2
Ajeetha
 
Posts: n/a
Default Re: Declaring constants
Any reason why you can't make that gloabl signal as a global constant
instead?

Ajeetha, CVC
www.noveldv.com



Ajeetha
  Reply With Quote
Old 05-30-2006, 07:01 PM   #3
Andy
 
Posts: n/a
Default Re: Declaring constants
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
  Reply With Quote
Old 05-31-2006, 07:47 AM   #4
ALuPin@web.de
 
Posts: n/a
Default Re: Declaring constants

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



ALuPin@web.de
  Reply With Quote
Old 05-31-2006, 12:12 PM   #5
Marcus Harnisch
 
Posts: n/a
Default Re: Declaring constants
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
  Reply With Quote
Old 06-02-2006, 09:27 AM   #6
ALuPin@web.de
 
Posts: n/a
Default Re: Declaring constants
Thanks to all.

I think Marcus idea is fine.

Rgds
Andre



ALuPin@web.de
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46