FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-12-2003, 12:36 PM
Douglas Maxwell
Guest
 
Posts: n/a
Default Nested generate statement problems

Hi all,
Does anyone know where I can find information on nested generate
statements? The follow code will not synthesise with Synplify 7.3.1
which supports generate constructs.
-------------------------------------------

module gl_op_select (n_reset_i, clk_i, n_wait_flag_i, select_i,
operand_i, operand_o);

parameter sel_bits = 1,
op_sources = 2,
op_bits = 8;

input n_reset_i;
input clk_i;
input n_wait_flag_i;
input [sel_bits -1 :0] select_i;
input [(op_sources*op_bits) -1 :0] operand_i;
output [op_bits -1 :0] operand_o;

reg [op_bits -1 :0] operand_o;
reg [sel_bits -1 :0] select_int;

genvar i;

generate
if (op_sources > 1)
[email protected](posedge clk_i or negedge n_reset_i)
if (!n_reset_i)
select_int <= 0;
else
if (n_wait_flag_i)
select_int <= select_i;
endgenerate


generate
for (i = 0; i < op_bits; i = i + 1)
begin:multiple_generates

generate
case (op_sources)
0,1:
[email protected](operand_i)
operand_o[i] <= operand_i[i];
2 :
[email protected](select_int or operand_i or i)
if (select_int)
operand_o[i] <= operand_i[i + op_bits];
else
operand_o[i] <= operand_i[i];
3 :
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
default : operand_o[i] <= operand_i[i + (op_bits*2)];
endcase
4:
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
2 : operand_o[i] <= operand_i[i + (op_bits*2)];
default : operand_o[i] <= operand_i[i + (op_bits*3)];
endcase
5:
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
2 : operand_o[i] <= operand_i[i + (op_bits*2)];
3 : operand_o[i] <= operand_i[i + (op_bits*3)];
default : operand_o[i] <= operand_i[i + (op_bits*4)];
endcase
6:
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
2 : operand_o[i] <= operand_i[i + (op_bits*2)];
3 : operand_o[i] <= operand_i[i + (op_bits*3)];
4 : operand_o[i] <= operand_i[i + (op_bits*4)];
default : operand_o[i] <= operand_i[i + (op_bits*5)];
endcase
7:
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
2 : operand_o[i] <= operand_i[i + (op_bits*2)];
3 : operand_o[i] <= operand_i[i + (op_bits*3)];
4 : operand_o[i] <= operand_i[i + (op_bits*4)];
5 : operand_o[i] <= operand_i[i + (op_bits*5)];
default : operand_o[i] <= operand_i[i + (op_bits*6)];
endcase
8:
[email protected](select_int or operand_i)
case (select_int)
0 : operand_o[i] <= operand_i[i];
1 : operand_o[i] <= operand_i[i + op_bits];
2 : operand_o[i] <= operand_i[i + (op_bits*2)];
3 : operand_o[i] <= operand_i[i + (op_bits*3)];
4 : operand_o[i] <= operand_i[i + (op_bits*4)];
5 : operand_o[i] <= operand_i[i + (op_bits*5)];
6 : operand_o[i] <= operand_i[i + (op_bits*6)];
default : operand_o[i] <= operand_i[i + (op_bits*7)];
endcase
endcase
endgenerate

end
endgenerate

endmodule
Reply With Quote
  #2 (permalink)  
Old 08-12-2003, 01:21 PM
Jonathan Bromley
Guest
 
Posts: n/a
Default Re: Nested generate statement problems


"Douglas Maxwell" <[email protected]> wrote in
message news:[email protected] om...
> Hi all,
> Does anyone know where I can find information on nested generate
> statements?


IEEE Standard 1364-2001?

> The follow code will not synthesise with Synplify 7.3.1
> which supports generate constructs.

[...]

Take out the nested generate. In summary, what you need is...

generate
for (i=0;...) begin: multiple_generate
...
case (selector) // this is an inner generate..case
...
endcase
...
end // for..multiple_generate
endgenerate

The syntax does not allow nested generate...endgenerate blocks.
Any case, if or for statement inside a generate...endgenerate
is treated as a generate construct. You can nest these as
deeply as you like, until you go into a procedural
(always/initial) block. Inside procedural blocks,
if/for/case go back to their usual meanings.

I haven't checked everything else in your code, but it looks
sensible.
--

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: [email protected]
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.



Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On



All times are GMT +1. The time now is 12:49 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved