![]() |
|
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
Any reason why you can't make that gloabl signal as a global constant
instead? Ajeetha, CVC www.noveldv.com Ajeetha |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
Thanks to all.
I think Marcus idea is fine. Rgds Andre ALuPin@web.de |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |