-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaXorB.sv
46 lines (32 loc) · 950 Bytes
/
aXorB.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
`timescale 1ns / 10ps
//determines logic for out = A ^ B
module aXorB (A, B, out, zero, overflow, carryOut, negative);
input logic [63:0] A, B;
output logic [63:0] out;
output logic zero, overflow, carryOut, negative;
assign overflow = 1'b0;
assign carryOut = 1'b0;
//creates 64 xor gates
generate
for (genvar x = 0; x < 64; x++) begin
xor #0.05 xorGate (out[x], A[x], B[x]);
end
endgenerate
//determines if out is negative or zero
assign negative = out[63];
zeroCase orZero (.out(zero), .inputs(out));
endmodule
module aXorB_testbench();
logic [63:0] A, B;
logic [63:0] out;
logic zero, overflow, carryOut, negative;
aXorB dut (.A, .B, .out, .zero, .overflow, .carryOut, .negative);
initial begin
A = 0; B = 0; #10;
A = 0; B = 1; #10;
A = 1; B = 0; #10;
A = 1; B = 1; #10;
A = 15; B = 15; #10;
A = 255; B = 256; #10;
end
endmodule