Declaring constants

A

ALuPin

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é
 
A

Andy

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
 
A

ALuPin

Ajeetha said:
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
 
M

Marcus Harnisch

Hi André,

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top