Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Question about conditional generate

Reply
Thread Tools

Question about conditional generate

 
 
cathy
Guest
Posts: n/a
 
      11-27-2006
Hello, All.

I have a question about the conditional generate statement.
For my code:

constant C_BankNumBits : Natural :=1;
constant C_BankNum :Natural := 2**(C_BankNumBits);

G_RegBank1 : if(C_BankNumBits=0) generate
G_RegBank : for i in 0 to (C_BankNum-1) generate
RegBank : brb8
port map (
clka => clk, dina => dina(i), addra => addra,
wea => wea, douta => douta(i),
clkb => clk, dinb => dinb(i), addrb => addrb,
web => web, doutb => doutb(i));
end generate G_RegBank;
end generate G_RegBank1;

....... other generate statement......
(here, I want to use different memory size if different bank number is
used)

I defined addra as std_logic_vector(11-C_BankNumBits downto 0).
Addra in the component brb8 is (11 downto 0).
In this case, I think the above generate statement won't work because
it doesn't satisfy the conidtion: if(C_BankNumBits=0). But the ISE give
me the following error when I check the syntax:
"Width mismatch. Expected width 12, Actual width is 11 for dimension 1
of addra."

Can anybody explains this to me?

Thanks a lot,
Cathy

 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      11-27-2006
You assume that c_banknumbits is 0 in the first assumption, yet it is
defined as 1.

Even though the generate statement is not elaborated, the width
checking is done at analysis (compile) time, which means that it must
be valid even if the generate statement turns out not to be elaborated.

Andy


cathy wrote:
> Hello, All.
>
> I have a question about the conditional generate statement.
> For my code:
>
> constant C_BankNumBits : Natural :=1;
> constant C_BankNum :Natural := 2**(C_BankNumBits);
>
> G_RegBank1 : if(C_BankNumBits=0) generate
> G_RegBank : for i in 0 to (C_BankNum-1) generate
> RegBank : brb8
> port map (
> clka => clk, dina => dina(i), addra => addra,
> wea => wea, douta => douta(i),
> clkb => clk, dinb => dinb(i), addrb => addrb,
> web => web, doutb => doutb(i));
> end generate G_RegBank;
> end generate G_RegBank1;
>
> ...... other generate statement......
> (here, I want to use different memory size if different bank number is
> used)
>
> I defined addra as std_logic_vector(11-C_BankNumBits downto 0).
> Addra in the component brb8 is (11 downto 0).
> In this case, I think the above generate statement won't work because
> it doesn't satisfy the conidtion: if(C_BankNumBits=0). But the ISE give
> me the following error when I check the syntax:
> "Width mismatch. Expected width 12, Actual width is 11 for dimension 1
> of addra."
>
> Can anybody explains this to me?
>
> Thanks a lot,
> Cathy


 
Reply With Quote
 
 
 
 
cathy
Guest
Posts: n/a
 
      11-28-2006
Thank you very much for your help,
Cathy

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
generate statement inside a process (conditional variable declaration) Nicolas Matringe VHDL 5 04-19-2007 07:38 PM
Question about conditional generate cathy VHDL 0 11-27-2006 09:38 PM
Problems with modelsim and conditional generate statement ArAgost VHDL 0 06-21-2006 09:55 AM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
Conditional statement to generate HTML? Erica Perl 3 07-18-2004 08:56 AM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57