K
Konx
Guest
Hi all!
Today, I'm facing a new problem.
I have a 4 bit LFSR counter. Then, I read out the content of the
registers and I need to decode (or better, to convert) this content to
the "real" value.
To do this in the testbench I used to simulate the logic, I was using
a function:
//4 bit decoding function
function [3:0] decode_4bits;
input [3:0] code;
reg [3:0] k;
reg [3:0] m;
begin
k[3:0] = 4'b1111;
m[3:0] = 4'b0000;
if(code[3:0]==4'b0000)
decode_4bits[3:0]=4'b1111; //impossible value = 15!
else
begin
while(code[3:0]!=k[3:0])
begin
k[3:0]= {k[1]^k[0],k[3:1]};
m[3:0]=m[3:0]+1;
end
decode_4bits[3:0]=m[3:0];
end
end
endfunction
The problem is this function cannot be synthesized because of the
while loop (for reference: I receive an error from Xilinx ISE: Xst:
1312 - Loop has iterated 64 times. Use "set -loop_iteration_limit XX"
to iterate more....I've tried to solve this problem in the way Xilin
suggest, but it doesn't work).
At the beginning I thought to change it in a for loop and use the
"break" instruction, but this command doesn't exist in Verilog (at
least, to obtain synthesizeable code).
I think that this problem should be quite common, but maybe I haven't
look in the right places...
thanks for any help
Francesco.
Today, I'm facing a new problem.
I have a 4 bit LFSR counter. Then, I read out the content of the
registers and I need to decode (or better, to convert) this content to
the "real" value.
To do this in the testbench I used to simulate the logic, I was using
a function:
//4 bit decoding function
function [3:0] decode_4bits;
input [3:0] code;
reg [3:0] k;
reg [3:0] m;
begin
k[3:0] = 4'b1111;
m[3:0] = 4'b0000;
if(code[3:0]==4'b0000)
decode_4bits[3:0]=4'b1111; //impossible value = 15!
else
begin
while(code[3:0]!=k[3:0])
begin
k[3:0]= {k[1]^k[0],k[3:1]};
m[3:0]=m[3:0]+1;
end
decode_4bits[3:0]=m[3:0];
end
end
endfunction
The problem is this function cannot be synthesized because of the
while loop (for reference: I receive an error from Xilinx ISE: Xst:
1312 - Loop has iterated 64 times. Use "set -loop_iteration_limit XX"
to iterate more....I've tried to solve this problem in the way Xilin
suggest, but it doesn't work).
At the beginning I thought to change it in a for loop and use the
"break" instruction, but this command doesn't exist in Verilog (at
least, to obtain synthesizeable code).
I think that this problem should be quite common, but maybe I haven't
look in the right places...
thanks for any help
Francesco.