forked from TimRudy/ice-chips-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7474.v
36 lines (31 loc) · 906 Bytes
/
7474.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
// Dual D flip-flop with set and clear; positive-edge-triggered
module ttl_7474 #(parameter BLOCKS = 2, DELAY_RISE = 0, DELAY_FALL = 0)
(
input [BLOCKS-1:0] Preset_bar,
input [BLOCKS-1:0] Clear_bar,
input [BLOCKS-1:0] D,
input [BLOCKS-1:0] Clk,
output [BLOCKS-1:0] Q,
output [BLOCKS-1:0] Q_bar
);
//------------------------------------------------//
reg [BLOCKS-1:0] Q_current;
genvar i;
generate
for (i = 0; i < BLOCKS; i = i + 1)
begin
always @(posedge Clk[i] or negedge Preset_bar[i] or negedge Clear_bar[i])
begin
if (!Preset_bar[i])
Q_current[i] <= 1'b1;
else if (!Clear_bar[i])
Q_current[i] <= 1'b0;
else if (Clk[i])
Q_current[i] <= D[i];
end
end
endgenerate
//------------------------------------------------//
assign #(DELAY_RISE, DELAY_FALL) Q = Q_current;
assign #(DELAY_RISE, DELAY_FALL) Q_bar = ~Q_current;
endmodule