forked from TimRudy/ice-chips-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7486.v
28 lines (23 loc) · 816 Bytes
/
7486.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
// Quad 2-input XOR gate
module ttl_7486 #(parameter BLOCKS = 4, WIDTH_IN = 2, DELAY_RISE = 0, DELAY_FALL = 0)
(
input [BLOCKS*WIDTH_IN-1:0] A_2D,
output [BLOCKS-1:0] Y
);
//------------------------------------------------//
wire [BLOCKS-1:0] A [0:WIDTH_IN-1];
reg [BLOCKS-1:0] computed;
integer i;
always @(*)
begin
// Note: For WIDTH_IN > 2, this is the "parity checker" interpretation of multi-input XOR
// - follows the precedent of 3-input XOR gate 741G386
// - conforms to chaining of XOR to create arbitrary wider input, e.g. "(A XOR B) XOR C"
computed = {BLOCKS{1'b0}};
for (i = 0; i < WIDTH_IN; i++)
computed = computed ^ A[i];
end
//------------------------------------------------//
`ASSIGN_UNPACK(BLOCKS, WIDTH_IN, A, A_2D)
assign #(DELAY_RISE, DELAY_FALL) Y = computed;
endmodule