dmgcpu

Форк
0
/
SeqCells.v 
257 строк · 3.7 Кб
1
// Elements of standard schematics ("kinda cells") used in the sequencer. Moved separately.
2

3
// Module Definitions [It is possible to wrap here on your primitives]
4

5
`timescale 1ns/1ns
6

7
// This module is essentially used to generate the #MREQ signal. Very cleverly twisted combined logic.
8
module seq_mreq ( a, b, c, d, x );
9

10
	input a;
11
	input b;	
12
	input c;
13
	input d;
14
	output x;
15

16
	assign x = d ? ~((~a & c) | ~(a|b)) : 1'b1;
17

18
endmodule // seq_mreq
19

20
// Regular posedge DFF (dual rails)
21
module seq_dff_posedge_comp ( d, clk, cclk, q );
22

23
	input d;	
24
	input clk;
25
	input cclk;
26
	output q;
27

28
	reg val;
29
	initial val = 1'bx;
30

31
	always @(posedge clk) begin
32
		val <= d;
33
	end
34

35
	assign q = val;
36

37
endmodule // seq_dff_posedge_comp
38

39
module seq_not ( a, x );
40

41
	input a;
42
	output x;
43

44
	assign x = ~a;
45

46
endmodule // seq_not
47

48
module seq_nor3 ( a, b, c, x );
49

50
	input a;
51
	input b;
52
	input c;
53
	output x;
54

55
	assign x = ~(a|b|c);
56

57
endmodule // seq_nor3
58

59
module seq_nor ( a, b, x );
60

61
	input a;
62
	input b;
63
	output x;
64

65
	assign x = ~(a|b);
66

67
endmodule // seq_nor
68

69
module seq_aoi_31 ( a0, a1, a2, b, x );
70

71
	input a0;
72
	input a1;
73
	input a2;
74
	input b;
75
	output x;
76

77
	assign x = ~( (a0&a1&a2) | b);
78

79
endmodule // seq_aoi_31
80

81
module seq_oai_21 ( a0, a1, b, x );
82

83
	input a0;	
84
	input a1;
85
	input b;	
86
	output x;
87

88
	assign x = ~( (a0|a1) & b );
89

90
endmodule // seq_oai_21
91

92
// This is essentially the same rs_latch, but with the inputs rearranged.
93
module seq_rs_latch2 ( nr, s, q );
94

95
	input nr;
96
	input s;
97
	output q;
98

99
	reg val;
100
	// Let's lower the difficulty level and use 0 here instead of `x`.
101
	initial val = 1'b0;
102

103
	// The module design is such that reset overrides set if both are set at the same time.
104
	always @(*) begin
105
		if (~nr)
106
			val = 1'b0;
107
		else if (s)
108
			val = 1'b1;
109
	end
110

111
	assign q = val;
112

113
endmodule // seq_rs_latch2
114

115
// rs_latch
116
module seq_rs_latch ( nr, s, q );
117

118
	input nr;
119
	input s;
120
	output q;
121

122
	reg val;
123
	// Let's lower the difficulty level and use 0 here instead of `x`.
124
	initial val = 1'b0;
125

126
	// The module design is such that reset overrides set if both are set at the same time.
127
	always @(*) begin
128
		if (~nr)
129
			val = 1'b0;
130
		else if (s)
131
			val = 1'b1;
132
	end
133

134
	assign q = val;
135

136
endmodule // seq_rs_latch
137

138
module seq_latchr_comp ( q, d, res, clk, cclk, ld, nld);
139

140
	output q;
141
	input d;
142
	input res;
143
	input clk;
144
	input cclk;
145
	input ld;
146
	input nld;
147

148
	reg val_in;
149
	reg val_out;
150
	initial val_in = 1'bx;
151
	initial val_out = 1'bx;
152

153
	always @(*) begin
154
		if (clk && ld)
155
			val_in = d;
156
		if (res)
157
			val_in = 1'b0;
158
	end
159

160
	always @(negedge ld) begin
161
		val_out <= val_in;
162
	end
163

164
	assign q = val_out;
165

166
endmodule // seq_latchr_comp
167

168
module seq_nand ( a, b, x );
169
	
170
	input a;
171
	input b;
172
	output x;
173

174
	assign x = ~(a&b);
175

176
endmodule // seq_nand
177

178
module seq_nand3 ( a, b, c, x );
179

180
	input a;
181
	input b;
182
	input c;
183
	output x;
184

185
	assign x = ~(a&b&c);
186

187
endmodule // seq_nand3
188

189
module seq_nor4 ( a, b, c, d, x );
190

191
	input a;
192
	input b;
193
	input c;
194
	input d;
195
	output x;
196

197
	assign x = ~(a|b|c|d);
198

199
endmodule // seq_nor4
200

201
module seq_aoi_21 ( a0, a1, b, x );
202

203
	input a0;
204
	input a1;
205
	input b;
206
	output x;
207

208
	assign x = ~( (a0&a1) | b);
209

210
endmodule // seq_aoi_21
211

212
// Regular transparent latch (dual rails)
213
module seq_latch_comp ( d, clk, cclk, nq );
214

215
	input d;
216
	input clk;
217
	input cclk;
218
	output nq;
219

220
	reg val;
221
	initial val = 1'b0;
222

223
	always @(*) begin
224
		if (clk)
225
			val = d;
226
	end
227

228
	assign nq = ~val;
229

230
endmodule // seq_latch_comp
231

232
module seq_aoi_22_dyn ( clk, a0, a1, b0, b1, x );
233

234
	input clk;
235
	input a0;
236
	input a1;
237
	input b0;
238
	input b1;
239
	output x;
240

241
	assign x = clk ? ~( (a0&a1) | (b0&b1) ) : 1'b1;
242

243
endmodule // seq_aoi_22_dyn
244

245
module seq_aoi_221_dyn ( clk, a0, a1, b0, b1, c, x );
246

247
	input clk;
248
	input a0;
249
	input a1;
250
	input b0;
251
	input b1;
252
	input c;
253
	output x;
254

255
	assign x = clk ? ~( (a0&a1) | (b0&b1) | c) : ~c;
256

257
endmodule // seq_aoi_221_dyn
258

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.