I saw an example beblow (people.tamu.edu/~ehsanrohani/ECEN248/lab5.ppt, Page39) about synthesis in verilog.
module count1sC ( bit_cnt, data, clk, rst );
parameter data_width = 4; parameter cnt_width = 3;
output [cnt_width-1:0] bit_cnt;
input [data_width-1:0] data; input clk, rst;
reg [cnt_width-1:0] cnt, bit_cnt, i; reg [data_width-1:0] tmp;
always @ ( posedge clk )
if ( rst ) begin cnt = 0; bit_cnt = 0; end
else begin
cnt = 0; tmp = data;
for ( i = 0; tmp; i = i + 1 )
begin if ( tmp[0] ) cnt = cnt + 1;
tmp = tmp >> 1; end
bit_cnt = cnt;
end
endmodule
Actually, this is an example for Not Synthesizable, but it seems like a synthesizable case, at least through Design compiler. Maybe the data_width has only 4 bits. If I change the data_width to 5, it will fail (out of iteration limits).
Can anybody explain this for me? Thanks in advance!