S
shwetika
Guest
module real_sin(x_in,sin_out);
input [63:0]x_in;
output wire [63:0] sin_out;
real r;
assign x=x_in;
assign r=sin(x_in);
assign sin_out=$realtobits(r);
function real sin(input real x);
real x1,y,y2,y3,y5,y7,sum,sign;
begin
sign = 1.0;
x1 = x;
if (x1<0)
begin
x1 = -x1;
sign = -1.0;
end
while (x1 > 3.14159265/2.0)
begin
x1 = x1 - 3.14159265;
sign = -1.0*sign;
end
y = x1*2/3.14159265;
y2 = y*y;
y3 = y*y2;
y5 = y3*y2;
y7 = y5*y2;
sum = 1.570794*y - 0.645962*y3 +
0.079692*y5 - 0.004681712*y7;
sin = sign*sum;
end
endfunction
endmodule
this piece of code gives me the following error
ERROR:HDLCompilers:246 - "real_sin.v" line 28 Reference to real
variable 'r' is not a legal net lvalue
ERROR:HDLCompilers:53 - "real_sin.v" line 28 Illegal left hand side of
continuous assign
I dont know a way around htis problem because each time i try a
different permutation and combination..the errors just keep increasing
specially "unsupported real or time function" errors.
Some kind of help and insight to make this code synthesize without
errors would be great!
Thanks,
Shwetika
input [63:0]x_in;
output wire [63:0] sin_out;
real r;
assign x=x_in;
assign r=sin(x_in);
assign sin_out=$realtobits(r);
function real sin(input real x);
real x1,y,y2,y3,y5,y7,sum,sign;
begin
sign = 1.0;
x1 = x;
if (x1<0)
begin
x1 = -x1;
sign = -1.0;
end
while (x1 > 3.14159265/2.0)
begin
x1 = x1 - 3.14159265;
sign = -1.0*sign;
end
y = x1*2/3.14159265;
y2 = y*y;
y3 = y*y2;
y5 = y3*y2;
y7 = y5*y2;
sum = 1.570794*y - 0.645962*y3 +
0.079692*y5 - 0.004681712*y7;
sin = sign*sum;
end
endfunction
endmodule
this piece of code gives me the following error
ERROR:HDLCompilers:246 - "real_sin.v" line 28 Reference to real
variable 'r' is not a legal net lvalue
ERROR:HDLCompilers:53 - "real_sin.v" line 28 Illegal left hand side of
continuous assign
I dont know a way around htis problem because each time i try a
different permutation and combination..the errors just keep increasing
specially "unsupported real or time function" errors.
Some kind of help and insight to make this code synthesize without
errors would be great!
Thanks,
Shwetika