-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalu64bit.sv
47 lines (43 loc) · 839 Bytes
/
alu64bit.sv
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
42
43
44
45
46
47
// 64-bit ALU template
module alu64bit (
input logic [63:0] a, // Input bit a
input logic [63:0] b, // Input bit b
input logic cin, // Carry in
input logic [1:0] op, // Operation
output logic [63:0] s, // Output S
output logic cout // Carry out
);
logic [62:0] carry;
//first ALU
alu1bit alu_0 (
.a(a[0]),
.b(b[0]),
.cin(cin),
.op(op),
.s(s[0]),
.cout(carry[0])
);
//middle ALU
genvar i;
generate
for (i=1; i<63; i++)
begin
alu1bit alu_inst(
.a(a[i]),
.b(b[i]),
.cin(carry[i-1]),
.op(op),
.s(s[i]),
.cout(carry[i]));
end
endgenerate
//last ALU
alu1bit alu_63 (
.a(a[63]),
.b(b[63]),
.cin(carry[62]),
.op(op),
.s(s[63]),
.cout(cout)
);
endmodule