-
Notifications
You must be signed in to change notification settings - Fork 0
/
alu.v
41 lines (33 loc) · 1.03 KB
/
alu.v
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
41
module alu(A, B, OP, Y, C, V, N, Z);
input [7:0] A;
input [7:0] B;
input [2:0] OP;
output [7:0] Y;
output C;
output V;
output N;
output Z;
wire CISEL;
wire BSEL;
wire [1:0] OSEL;
wire SHIFT_LA;
wire SHIFT_LR;
wire LOP;
wire [7:0] LOPY;
wire [7:0] SHIFTY;
wire SHIFTC;
wire CIn;
wire [7:0] ADDY;
wire COut;
wire VOut;
// ADD YOUR CODE BELOW THIS LINE
control freak(.OP(OP),.CISEL(CISEL),.BSEL(BSEL),.OSEL(OSEL),.SHIFT_LA(SHIFT_LA),.SHIFT_LR(SHIFT_LR),.LOGICAL_OP(LOP));
logical paradox(.A(A),.B(B),.OP(LOP),.Y(LOPY));
shifter iDontGiveAShift(.A(A),.LA(SHIFT_LA),.LR(SHIFT_LR),.Y(SHIFTY),.C(SHIFTC));
adder add(.A(A),.B(BSEL ? ~B : B),.CIn(CISEL ? 1'b1 : 1'b0),.Y(ADDY),.COut(COut),.V(VOut));
assign Y = OSEL[1] ? LOPY : (OSEL[0] ? SHIFTY : ADDY);
assign V = OSEL[1] ? 1'b0 : (OSEL[0] ? 1'b0 : VOut);
assign C = OSEL[1] ? 1'b0 : (OSEL[0] ? SHIFTC : COut);
assign Z = (Y == 8'd0) ? 1'b1 : 1'b0;
assign N = Y[7];
endmodule