NEHA12345
Newbie level 1
I have coded following verilog code for getting e to the power x. but I am getting only integers. I want answer in real number.How to get it.
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 //Expo program //Expo program module expo(power,ans,acc); input [7:0]power; input [7:0]acc; output [15:0]ans; real [15:0]anstemp; real [15:0]temp; real [7:0]i; always@* begin anstemp=1; temp=1; for(i=1;i<=acc;i=i+1) begin temp=(temp*power)/i; anstemp=anstemp+temp; end end assign ans=anstemp; endmodule its testbench is as follows. module expotb; reg [7:0]power; reg [7:0]acc; wire [15:0]ans; expo A1(power,ans,acc); initial begin power=5; acc=10000; end always @(ans) $display( "time =%0t \t output value ans =%d ",$time,ans); endmodule