Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - declaring signals depending on generic parameters

 
Thread Tools Search this Thread
Old 02-18-2004, 01:38 PM   #1
Default declaring signals depending on generic parameters


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
  Reply With Quote
Old 02-18-2004, 02:17 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: declaring signals depending on generic parameters
"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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46