-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder.v
More file actions
40 lines (34 loc) · 710 Bytes
/
Copy pathdecoder.v
File metadata and controls
40 lines (34 loc) · 710 Bytes
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
`timescale 1ns/1ps
module decoder(
input btnl,
input btnc,
input btnr,
output [3:0] alu_op
);
//internal nets
wire w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11;
//alu_op[0]
not(w1, btnr);
and(w2, w1, btnl);
xor(w3, btnl, btnc);
and(w4, w3, btnr);
or(alu_op[0], w4, w2);
//alu_op[1]
and(w5, btnr, btnl);
not(w6, btnl);
not(w7, btnc);
and(w8, w6, w7);
or(alu_op[1], w5, w8);
//alu_op[2]
//and(w5, btnr, btnl) exists and is w5
xor(w9, btnr, btnl);
or(w10, w9, w5);
//not(w7, btnc) exists and is w7
and(alu_op[2], w10, w7);
//alu_op[3]
//not(w1, btnr) exists and is w1
and(w11, w1, btnc);
xnor(w12, btnr, btnc);
or(w13, w11, w12);
and(alu_op[3], w13, btnl);
endmodule