Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

activation function-taylor series in verilog

Status
Not open for further replies.

dean07

Newbie level 4
Joined
Mar 15, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
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
 

Your code has too many bugs. What is always@(power)?
 

try to use structural verilog... make code for multiplier first then connect all like this,,, :


module multiplier_fn(inp1,inp2,product);

input [31:0] inp1,inp2;
output [31:0] product;

assign product = inp1 * inp2;

endmodule



module activation_fn_2 (inp1,inp2,inp3,cin_low,cout1,out);


input [31:0] inp1;
input [31:0] inp2; //inp3=1/3
input [31:0] inp3; //inp3=1/15
input cin_low;

output [9:0] out;
output cout1,cout2;

wire [31:0] x1,x2,x3,x4;
wire [31:0] y1,y2,y3;

multiplier_fn G1 (.inp1(inp1),.inp2(inp1),.product(x1));
multiplier_fn G2 (.inp1(x1),.inp2(inp1),.product(x2));
multiplier_fn G3 (.inp1(x2),.inp2(inp2),.product(y1));
multiplier_fn G4 (.inp1(x2),.inp2(x1),.product(x4));
multiplier_fn G5 (.inp1(x4),.inp2(inp3),.product(y2));

full_subs_10bit G6 (.A(inp1),.B(y1),.cin1(cin_low),.c_out(cout1),.sum(y3)); // full substractor
rca_top G7 (.A(y3),.B(y2),.cin1(cin_low),.c_out(cout2),.sum(out)); //ripple carry adder

//im not sure how to feed inp2=1/3 and inp3=1/15,, maybe by use fixed point number for the testbench, please tell me then.
//please correct me if i do mistakes,,, thanks <faiz.omaq@gmail.com>
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top