dean07
Newbie level 4
Hi.....i'm new to this verilog coding....so how i wonder if anyone can help me with this....
i'm trying to translate this arithmatic into verilo code:
verilog=x -( x3/3) + (x5/15)
here what i've done but it did'nt work!!
module top (a,product);
input [15:0] a;
output[15:0]product;
reg [15:0]power;
reg a_width;
reg [15:0]x,y,b,c;
reg [15:0]product;
initial begin
a_width = 1;
power=a;
end
always@(power) begin
if(a_width <= 3)
begin
power=power*power;
a_width=a_width+1;
x=power;
end
else if (a_width >3 && a_width<=5)
begin
power=power*power;
a_width=a_width+1;
y=power;
end
b=x;
c=y;
product=(a-x)+y;
end
endmodule
TQ
i'm trying to translate this arithmatic into verilo code:
verilog=x -( x3/3) + (x5/15)
here what i've done but it did'nt work!!
module top (a,product);
input [15:0] a;
output[15:0]product;
reg [15:0]power;
reg a_width;
reg [15:0]x,y,b,c;
reg [15:0]product;
initial begin
a_width = 1;
power=a;
end
always@(power) begin
if(a_width <= 3)
begin
power=power*power;
a_width=a_width+1;
x=power;
end
else if (a_width >3 && a_width<=5)
begin
power=power*power;
a_width=a_width+1;
y=power;
end
b=x;
c=y;
product=(a-x)+y;
end
endmodule
TQ