-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDLatch.v
More file actions
117 lines (94 loc) · 2.12 KB
/
DLatch.v
File metadata and controls
117 lines (94 loc) · 2.12 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright © 2024 Michal Schulz <michal.schulz@gmx.de>
// https://github.com/michalsc
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
//
// Latches module
// ==============
// The module provides several latches driven by high-speed clock domain and
// synchronized on the rising/falling edges of low-speed clock. Used to keep
// proper timings of Amiga-chipset relevant signals: AS, LDS, UDS, RnW
module DLatch(
input wire SET,
input wire RESET,
input wire CLK,
output reg OUT
);
always @(*) begin
if (RESET == 1)
OUT <= 1'b0;
else if (SET == 1)
OUT <= 1'b1;
end
endmodule
module FFLatch(
input wire SET,
input wire RESET,
input wire CLK,
output reg OUT
);
reg clear;
wire clocked_reset = RESET & clear;
always @(posedge CLK or posedge clocked_reset) begin
if (clocked_reset)
OUT <= 1'b0;
else if (CLK & SET)
OUT <= 1'b1;
end
always @(negedge CLK) begin
if (RESET)
clear <= 1'b1;
else
clear <= 1'b0;
end
endmodule
module FFLatchN(
input wire SET,
input wire RESET,
input wire CLK,
output reg OUT
);
reg clear;
wire clocked_reset = RESET & clear;
always @(posedge CLK or posedge clocked_reset) begin
if (clocked_reset)
OUT <= 1'b1;
else if (CLK & SET)
OUT <= 1'b0;
end
always @(negedge CLK) begin
if (RESET)
clear <= 1'b1;
else
clear <= 1'b0;
end
endmodule
module FFLatchPR(
input wire SET,
input wire RESET,
input wire CLK,
output reg OUT
);
always @(posedge CLK) begin
if (SET)
OUT <= 1'b1;
else if (RESET)
OUT <= 1'b0;
end
endmodule
module FFLatchNPR(
input wire SET,
input wire RESET,
input wire CLK,
output reg OUT
);
always @(posedge CLK) begin
if (SET)
OUT <= 1'b0;
else if (RESET)
OUT <= 1'b1;
end
endmodule