-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path7474.v
43 lines (37 loc) · 1.21 KB
/
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
37
38
39
40
41
42
43
// Dual D flip-flop with set and clear; positive-edge-triggered
// Note: Preset_bar is synchronous, not asynchronous as specified in datasheet for this device,
// in order to meet requirements for FPGA circuit design (see IceChips Technical Notes)
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;
reg [BLOCKS-1:0] Preset_bar_previous;
generate
genvar i;
for (i = 0; i < BLOCKS; i = i + 1)
begin: gen_blocks
always @(posedge Clk[i] or negedge Clear_bar[i])
begin
if (!Clear_bar[i])
Q_current[i] <= 1'b0;
else if (!Preset_bar[i] && Preset_bar_previous[i]) // falling edge has occurred
Q_current[i] <= 1'b1;
else
begin
Q_current[i] <= D[i];
Preset_bar_previous[i] <= Preset_bar[i];
end
end
end
endgenerate
//------------------------------------------------//
assign #(DELAY_RISE, DELAY_FALL) Q = Q_current;
assign #(DELAY_RISE, DELAY_FALL) Q_bar = ~Q_current;
endmodule