Hi all,
I have read through similar posts on this topic however have been unable to find an answer...
I am trying to implement an 8 bit by 8 bit divider without the use of the "/" symbol in verilog. The code I have written compiles, however will only generate the correct answer when the loop iterator is below 60. The code I have written is:
always@(num1,num2)
begin
temp_answer = 8'b0;
k = 0;
temp_num1 = num1;
temp_num2 = num2;
while(k<100)
begin
if(temp_num1>temp_num2)
begin
temp_num1 = temp_num1 - temp_num2;
temp_answer = temp_answer + 1;
end
k=k+1;
end
answer = temp_answer;
end
endmodule
Num1 and num2, are two signed numbers (in two's complement form) entered (on the altera DE2 board) by the user. The code compiles with any k value, however only generates the right answer in the waveform simulator when k < 60. This is a problem as the largest value that can be output is 128 (128/1), therefore i need the loop to perform 128 iterations. I know this isn't efficient at all, however I need to get it working.
Any help would be appreciated,
Thanks