You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing around with passing packages into entities and came up with the following.
packagegeneric_complexisgeneric (
typet ;
-- default subprogramsfunction"+"(l, r : t) return t is<> ;
functionto_string(x : t) returnstringis<>
) ;
-- cute way of making an array of type t with indices for re and im partstypecomplex_partsis (re, im) ;
typecomplexisarray(re to im) of t ;
-- complex summing operationfunction"+"(l, r : complex) returncomplex ;
-- string representationfunctionto_string(x : complex) returnstring ;
endpackage ;
packagebodygeneric_complexisfunction"+"(l, r : complex) returncomplexisbeginreturn (re => l(re)+r(re), im => l(im)+r(im)) ;
endfunction ;
functionto_string(x : complex) returnstringisbeginreturn"("& to_string(x(re)) &","& to_string(x(im)) &")" ;
endfunction ;
endpackagebody ;
entitypipelined_complex_sumisgeneric (
package complex_pkg isnew work.generic_complex genericmap(<>)
) ;
port (
clock : inbit ;
a : in complex_pkg.complex ;
b : in complex_pkg.complex ;
c : out complex_pkg.complex
) ;
endentity ;
architecturearchofpipelined_complex_sumisuse complex_pkg.all ;
beginprocess(clock)
beginif( rising_edge(clock) ) then
c <= a + b ;
endif ;
endprocess ;
endarchitecture ;
-- create the two different complex packagespackagecomplex_intisnew work.generic_complex genericmap (t =>integer) ;
package complex_real isnew work.generic_complex genericmap (t =>real) ;
use work.complex_real.all ;
use work.complex_int.all ;
entity test isendentity ;
architecturearchoftestis-- signals for real summersignal ar : work.complex_real.complex ;
signal br : work.complex_real.complex ;
signal cr : work.complex_real.complex ;
-- signals for int summersignal ai : work.complex_int.complex ;
signal bi : work.complex_int.complex ;
signal ci : work.complex_int.complex ;
-- clocksignal clock : bit ;
begin
clock <=not clock after1ns ;
U_real_summer : entitywork.pipelined_complex_sumgenericmap (
complex_pkg => work.complex_real
) portmap (
clock => clock,
a => ar,
b => br,
c => cr
) ;
U_int_summer : entitywork.pipelined_complex_sumgenericmap (
complex_pkg => work.complex_int
) portmap (
clock => clock,
a => ai,
b => bi,
c => ci
) ;
tb : processvariable val : work.complex_int.complex ;
beginfor i in1to100loop
val := (i, 42*i) ;
ai <= val ;
ar <= (real(val(re)), real(val(im))) ;
val := (-7*i, 100*i) ;
bi <= val ;
br <= (real(val(re)), real(val(im))) ;
waituntilrising_edge(clock) ;
endloop ;
std.env.stop ;
endprocess ;
endarchitecture ;
The snippet works with Questa and Riviera, but nvc errors during analysis with:
** Error: type of actual COMPLEX does not match type COMPLEX of formal port A
... for all the complex input ports.
Unsure where the type mismatch is happening, so I am thinking it's a bug.
The text was updated successfully, but these errors were encountered:
I was playing around with passing packages into entities and came up with the following.
The snippet works with Questa and Riviera, but nvc errors during analysis with:
... for all the complex input ports.
Unsure where the type mismatch is happening, so I am thinking it's a bug.
The text was updated successfully, but these errors were encountered: