T
trescot@gmail.com
Guest
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),
.clk (t_clk),
.q (dbgattnsync)
);
// Output from one_synchronizer is fed to datalatch
datalatch u_datalatch(
.piclr (clr),
.pidatasync (dbgattnsync),
.t_clk (t_clk),
.podata_r (dbgattn_r)
);
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
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),
.clk (t_clk),
.q (dbgattnsync)
);
// Output from one_synchronizer is fed to datalatch
datalatch u_datalatch(
.piclr (clr),
.pidatasync (dbgattnsync),
.t_clk (t_clk),
.podata_r (dbgattn_r)
);
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