implementing equations

Status
Not open for further replies.

arunssn

Newbie level 2
Joined
Feb 10, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
how to implement equations in verilog that are synthesisable.
for eg |p0 - q0| etc.
 

if p0 and p1 are 1 bit wires...

wire out;

assign out = p0 + p1; // assigns to out their sum
assign out = p0 - p1; // difference
assign out = p0 ^ p1; // ^ means xor ,
// this is equal to |p0 - q0|

assign out = p0 && p1; // logical AND
assign out = p0 || p1; // logical OR
 

Code:
module eg(q0,q1,out);
parameter BW = 8;
input [BW-1:0] q0;
input [BW-1:0] q1;
output [BW-1:0] out;
assign out = (q0>q1)? (q0-q1) : (q1-q0);
enmodule
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…