In reply to dave_59:
In reply to nimitz_class:
It would help to show the declarations of all variables and include a set of example values you are expecting.
module computeK();
localparam real rterm_target = 45;
localparam real inductor_res = 7;
localparam real static_legs = 5;
localparam real target_res = 200;
real k, kfrac;
int kint;
task compute_k();
k = (rterm_target - inductor_res) * 8/(target_res - inductor_res);
kint = $rtoi(k);
kfrac = k - kint;
$display("Kint :: %d, Kfrac :: %f, K :: %f", kint, kfrac, k);
endtask
initial begin
compute_k();
end
endmodule
Sim result : Kint :: 1, Kfrac :: 0.575130, K :: 1.575130
I want to convert 0.575 to binary