Following is the code: The intent of the code is to calculate the number of leading zero's from one of the register. I just want to calculate the leading zero's from the register significand just once. I have to use an always block for this. Now I have initially assigned a as 1'b1 and later on I have changed it to 1'b0, so that the block gets executed once. If I try to simulate the code. The always block doesn't executes. However If I later assign a as 0'b1 (which doesn't make any sense). The code simulates properly in the Simulator. But if I synthesize the code on the FPGA kit, It gives some erraneous result. Please help me
integer count,index;
wire a;
assign a=1'b1;
always@(a)
begin
for(count=0;count<7;count=count+1) begin
index=4*count;
if((significand[index ]==1'b0) && (significand[index+1]==1'b0) &&
(significand[index+2]==1'b0) && (significand[index+3]==1'b0))
lzero=lzero+1;
end
end
assign a=1'b0;
// If I use assign a=0'b1, it simulates properly,
// but 0'b1 doesn't make any sense, also If I keep 0'b1,
// I dont get proper result in actual synthesis onto the board.
Actually my intent of asking the question was, as to how I should be able to use a " always " block. Since I just wanted to execute this block only once, so I need not set "posedge clk" or " negedge clock " with always. So what should I do ?? Please Help because my project demands me High usage of for loop if else loops