[SOLVED] Verilog synthesis problem!Please Help

Status
Not open for further replies.

UFK

Member level 3
Joined
Mar 8, 2010
Messages
60
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Pakistan
Activity points
1,728
Dear Verilog users

Please help me synthesize a simple Verilog program which calculates the log base 2 of a value.

My code is


The testbench is

module Log_max_tb;

// Inputs
reg [31:0] v;

// Outputs
wire [31:0] n_var;
wire [31:0] T;


// Instantiate the Unit Under Test (UUT)
Log_max uut (
.v(v),
.n_var(n_var),
.T(T)
);

initial begin
v = 2614;

end



endmodule

If i use the datatype reg for variable 'i' the program synthesizes but does not give results. Please help me synthesize this code.

Thankyou
 

Hi UFK,
Any "for-loop" which is intended to be Synthesizable, should be "fixed" number. Here your input "Depth" is directly assigning to the "i" value.
If you need to get synthesised output either do parameterise the "i" value or assign a known value to "i". Typically synthesis tools will optimize the for loop which is not fixed increment.
I didnt synthesize, only first cut analysis.

-paulki
 
Hi paulki

Thanks for your help. I tried what u suggested and my code calculates the value correctly but it still does not synthesize. I gave a constant value to the variable 'i'. It gives me the same error which is

ERROR:Xst:2634 - "Log_max.v" line 37: For loop stop condition should depend on loop variable or be static.

Please suggest what i can do to synthesize it.

Thankyou
 

I think you're missing the 'begin' and 'end' keywords that should enclose the code inside the for loop. Try that and see if that helps.

--Rohit
 

To detect the highest 1-bit in a vector of width 32, you have to set up a loop with a fixed number of 32 iterations. You can exit it, when the scan is finished. You missed to give reg i the required width, by the way.

I think you're missing the 'begin' and 'end' keywords that should enclose the code inside the for loop.
Similar to C {} brackets, begin .. end is needed with more than on instructions in the loop. In this case it isn't.
 

Thanks Fvm.
I understand what you suggested and i tried it in my code. It gives correct results and synthesizes too. But it just gives a 96% Bonded IO result and 0% slice utilization which leads me to think there is a problem which the simulator cant comprehend.
Im posting my code and testbench. Please suggest what i can do to get it working.



And the testbench


Thanks alot for your suggestion.
 

The new code doesn't calculate anything because the output doesn't depend on input data.

The original code most likely works if you replace reg i by integer i;
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…