![]() |
|
|
|||||||
![]() |
VHDL - declaring signals depending on generic parameters |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
entity E is
SIZE: integer; B : boolean; end E; The idea is to declare variable-length vector. Is wrapping the only solution in VHDL? architecture A of E is signal S : std_logic_vector(B ? SIZE - 1: SIZE downto 0); -- C-like ternary operators not supported begin ... valentin tihomirov |
|
|
|
|
#2 |
|
Posts: n/a
|
"valentin tihomirov" <> wrote in
message news:c0vps9$1blik4$... > entity E is > SIZE: integer; > B : boolean; > end E; > > > The idea is to declare variable-length vector. Is wrapping the only solution > in VHDL? > > architecture A of E is > signal S : std_logic_vector(B ? SIZE - 1: SIZE downto 0); -- C-like > ternary operators not supported Don't forget that you can use any function to initialise a constant. I'm assuming that SIZE and B are generics. It would be crazy if they were ports, of course. architecture A of E is function bit_extended_size(N: integer; B: boolean) return integer is begin if B then return N-1; else return N; end if; end; constant W : integer := bit_extended_size(SIZE, B); signal S: std_logic_vector(W downto 0); -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 mail: Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. Jonathan Bromley |
|