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 03-13-2007, 11:15 PM
Guest
 
Posts: n/a
Default Verilog generate

I have an issue with the verilog generate statement. Now my top level
block called top_module is instantiating the low level block module1
as below

module top_level(
.........
.........
parameter DBGATTN = 0;
....
...

block1 #(
.DBGATTN_WIDTH(DBGATTN),
.........
......
endmodule

------------------------------------------------------------------------------------



module block1(
....
.....

parameter DBGATTN_WIDTH = 32;

input [DBGATTN_WIDTH-1:0] dbgattn ; // input signal
input t_clk; // clock
input clr; // Debug
register clear bit
output dbgattn_out; // Debug
register status out

wire [DBGATTN_WIDTH-1:0] dbgattnsync;

genvar i;

generate
if (DBGATTN_WIDTH > 0) // generate the logic below only if
DBGATTN_WIDTH > 0
begin
for (i=0 ; i<DBGATTN_WIDTH; i=i+1)
begin :dbgattn
// 2 reg synchronizer used to synchronize i/p signal in tclk domain
one_synchronizer u_one_synch (
.clr_n (1'b1),
.d (dbgattn[i]),
.clk (t_clk),
.q (dbgattnsync[i])
);

// Output from one_synchronizer is fed to datalatch
datalatch u_datalatch(
.piclr (clr),
.pidatasync (dbgattnsync[i]),
.t_clk (t_clk),
.podata_r (dbgattn_r[i])
);
end
end
endgenerate

endmodule



The issue is, when I instantiate block1 with DBGATTN = 0 though I do
not expect any of the generate logic, but still synthesis tool is
generating 32 instances of the generate logic?? Is it because input
[DBGATTN_WIDTH-1:0] dbgattn, becomes input [-1:0] dbgattn when I
pass in DBGATTN_WIDTH as 0? But if thats the case I should get some
error. But synopsys synthesis tool doesn'y complain.

How to resolve this?


Thanks
Trescot

Reply With Quote
  #2 (permalink)  
Old 03-13-2007, 11:44 PM
John_H
Guest
 
Posts: n/a
Default Re: Verilog generate

I would expect the behavior would be to try to implement a block with no
logic (which should give an error because the output needs *something*): a
block with a 2-bit dbgattn input port with indicies -1 and 0.

Could it be that a module without any logic produces the module logic based
on the default parameter?

Note that your default is "parameter DBGATTN_WIDTH = 32;" giving the
possibility that the DBGATTN_WIDTH override didn't take for some reason or
other in your code.

What is your expected behavior for DBGATTN_WIDTH = 0 ? If you specify that
output behavior, you might see a difference in the result. Otherwise,
"don't do that."


<[email protected]> wrote in message
news:[email protected] ups.com...
>I have an issue with the verilog generate statement. Now my top level
> block called top_module is instantiating the low level block module1
> as below
>
> module top_level(
> ........
> ........
> parameter DBGATTN = 0;
> ...
> ..
>
> block1 #(
> .DBGATTN_WIDTH(DBGATTN),
> .........
> ......
> endmodule
>
> ------------------------------------------------------------------------------------
>
>
>
> module block1(
> ...
> ....
>
> parameter DBGATTN_WIDTH = 32;
>
> input [DBGATTN_WIDTH-1:0] dbgattn ; // input signal
> input t_clk; // clock
> input clr; // Debug
> register clear bit
> output dbgattn_out; // Debug
> register status out
>
> wire [DBGATTN_WIDTH-1:0] dbgattnsync;
>
> genvar i;
>
> generate
> if (DBGATTN_WIDTH > 0) // generate the logic below only if
> DBGATTN_WIDTH > 0
> begin
> for (i=0 ; i<DBGATTN_WIDTH; i=i+1)
> begin :dbgattn
> // 2 reg synchronizer used to synchronize i/p signal in tclk domain
> one_synchronizer u_one_synch (
> .clr_n (1'b1),
> .d (dbgattn[i]),
> .clk (t_clk),
> .q (dbgattnsync[i])
> );
>
> // Output from one_synchronizer is fed to datalatch
> datalatch u_datalatch(
> .piclr (clr),
> .pidatasync (dbgattnsync[i]),
> .t_clk (t_clk),
> .podata_r (dbgattn_r[i])
> );
> end
> end
> endgenerate
>
> endmodule
>
>
>
> The issue is, when I instantiate block1 with DBGATTN = 0 though I do
> not expect any of the generate logic, but still synthesis tool is
> generating 32 instances of the generate logic?? Is it because input
> [DBGATTN_WIDTH-1:0] dbgattn, becomes input [-1:0] dbgattn when I
> pass in DBGATTN_WIDTH as 0? But if thats the case I should get some
> error. But synopsys synthesis tool doesn'y complain.
>
> How to resolve this?
>
>
> Thanks
> Trescot
>



Reply With Quote
  #3 (permalink)  
Old 03-14-2007, 03:22 AM
Guest
 
Posts: n/a
Default Re: Verilog generate

On Mar 13, 5:44 pm, "John_H" <[email protected]> wrote:
> I would expect the behavior would be to try to implement a block with no
> logic (which should give an error because the output needs *something*): a
> block with a 2-bit dbgattn input port with indicies -1 and 0.
>
> Could it be that a module without any logic produces the module logic based
> on the default parameter?
>
> Note that your default is "parameter DBGATTN_WIDTH = 32;" giving the
> possibility that the DBGATTN_WIDTH override didn't take for some reason or
> other in your code.
>
> What is your expected behavior for DBGATTN_WIDTH = 0 ? If you specify that
> output behavior, you might see a difference in the result. Otherwise,
> "don't do that."
>
> <[email protected]> wrote in message
>
> news:[email protected] ups.com...
>
>
>
> >I have an issue with the verilog generate statement. Now my top level
> > block called top_module is instantiating the low level block module1
> > as below

>
> > module top_level(
> > ........
> > ........
> > parameter DBGATTN = 0;
> > ...
> > ..

>
> > block1 #(
> > .DBGATTN_WIDTH(DBGATTN),
> > .........
> > ......
> > endmodule

>
> > ---------------------------------------------------------------------------*---------

>
> > module block1(
> > ...
> > ....

>
> > parameter DBGATTN_WIDTH = 32;

>
> > input [DBGATTN_WIDTH-1:0] dbgattn ; // input signal
> > input t_clk; // clock
> > input clr; // Debug
> > register clear bit
> > output dbgattn_out; // Debug
> > register status out

>
> > wire [DBGATTN_WIDTH-1:0] dbgattnsync;

>
> > genvar i;

>
> > generate
> > if (DBGATTN_WIDTH > 0) // generate the logic below only if
> > DBGATTN_WIDTH > 0
> > begin
> > for (i=0 ; i<DBGATTN_WIDTH; i=i+1)
> > begin :dbgattn
> > // 2 reg synchronizer used to synchronize i/p signal in tclk domain
> > one_synchronizer u_one_synch (
> > .clr_n (1'b1),
> > .d (dbgattn[i]),
> > .clk (t_clk),
> > .q (dbgattnsync[i])
> > );

>
> > // Output from one_synchronizer is fed to datalatch
> > datalatch u_datalatch(
> > .piclr (clr),
> > .pidatasync (dbgattnsync[i]),
> > .t_clk (t_clk),
> > .podata_r (dbgattn_r[i])
> > );
> > end
> > end
> > endgenerate

>
> > endmodule

>
> > The issue is, when I instantiate block1 with DBGATTN = 0 though I do
> > not expect any of the generate logic, but still synthesis tool is
> > generating 32 instances of the generate logic?? Is it because input
> > [DBGATTN_WIDTH-1:0] dbgattn, becomes input [-1:0] dbgattn when I
> > pass in DBGATTN_WIDTH as 0? But if thats the case I should get some
> > error. But synopsys synthesis tool doesn'y complain.

>
> > How to resolve this?

>
> > Thanks
> > Trescot- Hide quoted text -

>
> - Show quoted text -



Thanks John for the reply. Actually I missed my output assignment.

assign dbgattn_out = (DBGATTN_WIDTH > 0) ? |podata_r : 1'b0;

Since this is an IP, I should have the provision of not to create any
extra logic when my DBGATTN_WIDTH is 0.

Reply With Quote
  #4 (permalink)  
Old 03-14-2007, 02:27 PM
John_H
Guest
 
Posts: n/a
Default Re: Verilog generate

[email protected] wrote:
> I have an issue with the verilog generate statement. Now my top level
> block called top_module is instantiating the low level block module1
> as below


<snip>

> module block1(
> ...
> ....
>
> parameter DBGATTN_WIDTH = 32;

<snip>

> The issue is, when I instantiate block1 with DBGATTN = 0 though I do
> not expect any of the generate logic, but still synthesis tool is
> generating 32 instances of the generate logic?? Is it because input
> [DBGATTN_WIDTH-1:0] dbgattn, becomes input [-1:0] dbgattn when I
> pass in DBGATTN_WIDTH as 0? But if thats the case I should get some
> error. But synopsys synthesis tool doesn'y complain.
>
> How to resolve this?
>
>
> Thanks
> Trescot


You can get rid of the symptome without identifying the true cause:

change your default parameter definition to 0.

Suddenly it works.
Reply With Quote
Reply

Bookmarks


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to generate sine or cosine waves in Verilog HDL mike83 Verilog 1 02-14-2007 09:13 AM
How to generate gaussian random numbers using Verilog? lindberg Verilog 2 08-22-2005 05:56 AM
How to random generate packet for Ethernet MAC(802.3) with verilog in testbench? sarah Verilog 0 05-28-2004 04:21 PM
Newbie Verilog ques: generate/endgenerate Steven Sharp Verilog 0 09-18-2003 10:52 PM
Newbie Verilog ques: generate/endgenerate Sumanta Guha Verilog 5 09-18-2003 07:36 PM


All times are GMT +1. The time now is 11:49 AM.


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