forked from TimRudy/ice-chips-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7473.v
46 lines (40 loc) · 1.04 KB
/
7473.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
42
43
44
45
46
// Dual J-K flip-flop with clear; negative-edge-triggered
module ttl_7473 #(parameter BLOCKS = 2, DELAY_RISE = 0, DELAY_FALL = 0)
(
input [BLOCKS-1:0] Clear_bar,
input [BLOCKS-1:0] J,
input [BLOCKS-1:0] K,
input [BLOCKS-1:0] Clk,
output [BLOCKS-1:0] Q,
output [BLOCKS-1:0] Q_bar
);
//------------------------------------------------//
reg [BLOCKS-1:0] Q_current;
wire [BLOCKS-1:0] Q_next;
genvar i;
assign Q_next = Q_current;
generate
for (i = 0; i < BLOCKS; i = i + 1)
begin
always @(negedge Clk[i] or negedge Clear_bar[i])
begin
if (!Clear_bar[i])
begin
Q_current[i] <= 1'b0;
end
else if (!Clk[i])
begin
if (J[i] && !K[i] || !J[i] && K[i])
Q_current[i] <= J[i];
else if (J[i] && K[i])
Q_current[i] <= !Q_next[i];
else
Q_current[i] <= Q_next[i];
end
end
end
endgenerate
//------------------------------------------------//
assign #(DELAY_RISE, DELAY_FALL) Q = Q_current;
assign #(DELAY_RISE, DELAY_FALL) Q_bar = ~Q_current;
endmodule