Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Declaring constants

Reply
Thread Tools

Declaring constants

 
 
ALuPin@web.de
Guest
Posts: n/a
 
      05-29-2006
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é

 
Reply With Quote
 
 
 
 
Ajeetha
Guest
Posts: n/a
 
      05-30-2006
Any reason why you can't make that gloabl signal as a global constant
instead?

Ajeetha, CVC
www.noveldv.com

 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      05-30-2006
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

 
Reply With Quote
 
ALuPin@web.de
Guest
Posts: n/a
 
      05-31-2006

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

 
Reply With Quote
 
Marcus Harnisch
Guest
Posts: n/a
 
      05-31-2006
Hi André,

"(E-Mail Removed)" <(E-Mail Removed)> 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
 
Reply With Quote
 
ALuPin@web.de
Guest
Posts: n/a
 
      06-02-2006
Thanks to all.

I think Marcus idea is fine.

Rgds
Andre

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring constants within the scope of a class Generic Usenet Account C++ 5 03-15-2005 04:46 PM
declaring constants Troy Knight Perl 1 07-28-2004 11:58 AM
declaring signals depending on generic parameters valentin tihomirov VHDL 1 02-18-2004 02:17 PM
Declaring ports with a complicated array type Marius Vollmer VHDL 6 12-10-2003 07:48 PM
Defining/declaring constants in Python Sriram Chadalavada Python 2 07-29-2003 11:56 AM



Advertisments