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.

How to express this equation using "assign" in verilog

Status
Not open for further replies.

nbuzs

Junior Member level 2
Joined
Jul 20, 2006
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,404
Any suggestion on the expression using verilog will be thankful.


Input Data is D[3:0], encoded output Z[6:0]

Z = (D mod 15) + (8-1)*(2n-1)

listed in below table

D[3:0] n Z[6:0]
---------------------
0 0 0
1 1 8
2 1 9
3 2 24
4 2 25
5 2 26
6 2 27
7 3 58
8 3 57
9 3 58
10 3 59
11 3 60
12 3 61
13 3 62
14 3 63
15 0 0
 

You can use hard coding:
assign Z =
D==4'h0 & n=2'h0 ? 6'h0 :
D==4'h1 & n=2'h1 ? 6'h8 :
...
Synthesis tool will optimize this logic.

Another way:
assign Z = D + 7*(1<<n - 1);
 

thanks for kornukhin reply.

I'm try to writing in this way
___________________________________________________________________________
wire [3:0] incd3;
wire [3:0] exp3;

assign incd3 = D + 1;
assign exp3 = {incd3[3], ~incd3[3] & incd3[2], ~incd3[3] & ~incd3[2] & incd3[1], 1'b0};

assign Z = (D % 15) + (8-1)* (exp3 - |exp3);
____________________________________________________________________________
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top