@mchp-mcc/scf-pic8-clc-v1 4.0.13 → 4.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +9 -0
- package/Readme.md +9 -0
- package/output/autoCreator.js +167 -3
- package/output/autoCreator.js.map +1 -1
- package/output/autoProcessor.js +167 -3
- package/output/autoProcessor.js.map +1 -1
- package/output/creator.js +167 -3
- package/output/creator.js.map +1 -1
- package/output/processor.js +167 -3
- package/output/processor.js.map +1 -1
- package/output/reducer.js +1 -1
- package/output/view.js +1 -1
- package/package.json +6 -8
- package/src/App.tsx +0 -101
- package/src/Constants.ts +0 -181
- package/src/CreatorFunctions.ts +0 -44
- package/src/DerivedData.test.tsx +0 -285
- package/src/DerivedData.ts +0 -444
- package/src/GeneratorModel.test.ts +0 -57
- package/src/GeneratorModel.ts +0 -60
- package/src/InputStateCalculator.test.ts +0 -64
- package/src/InputStateCalculator.ts +0 -50
- package/src/PinsLogic.test.ts +0 -514
- package/src/PinsLogic.ts +0 -164
- package/src/SettingNameCalculator.test.ts +0 -21
- package/src/SettingNameCalculator.ts +0 -28
- package/src/actions.ts +0 -22
- package/src/catalog.json +0 -24
- package/src/components/CLCView.tsx +0 -141
- package/src/components/Canvas.tsx +0 -757
- package/src/components/InputSource.tsx +0 -24
- package/src/components/InputStage.tsx +0 -55
- package/src/components/MX.ts +0 -12
- package/src/gates/ALogicGate.ts +0 -221
- package/src/gates/AndGate.ts +0 -36
- package/src/gates/GateInputState.ts +0 -1
- package/src/gates/Latch.ts +0 -93
- package/src/gates/NotGate.ts +0 -37
- package/src/gates/OrGate.ts +0 -134
- package/src/gates/XorGate.ts +0 -12
- package/src/index.tsx +0 -51
- package/src/interfaces/cla-clc-stacked.test.ts +0 -61
- package/src/interfaces/cla-clc-stacked.ts +0 -181
- package/src/interfaces/clc-connections.tsx +0 -62
- package/src/interfaces/signal-source.ts +0 -78
- package/src/interfaces/trigger-source.ts +0 -78
- package/src/moduleConfig.json +0 -882
- package/src/pinsdata.json +0 -151
- package/src/reducer.test.tsx +0 -118
- package/src/reducer.tsx +0 -80
|
@@ -1,757 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Dispatch } from "redux";
|
|
3
|
-
import ReactDOM from "react-dom";
|
|
4
|
-
import MX from "./MX";
|
|
5
|
-
import { OrGate } from "../gates/OrGate";
|
|
6
|
-
import { NotGate } from "../gates/NotGate";
|
|
7
|
-
import { AndGate } from "../gates/AndGate";
|
|
8
|
-
import { ALogicGate } from "../gates/ALogicGate";
|
|
9
|
-
import { XorGate } from "../gates/XorGate";
|
|
10
|
-
import { Latch } from "../gates/Latch";
|
|
11
|
-
import { InputStateCalculator } from "../InputStateCalculator";
|
|
12
|
-
import { CANVAS_WIDTH, CANVAS_HEIGHT } from "../Constants";
|
|
13
|
-
|
|
14
|
-
const myGraph = MX;
|
|
15
|
-
|
|
16
|
-
const mxGraph = myGraph.mxGraph;
|
|
17
|
-
const mxEvent = myGraph.mxEvent;
|
|
18
|
-
const mxUtils = myGraph.mxUtils;
|
|
19
|
-
const mxClient = myGraph.mxClient;
|
|
20
|
-
const mxShape = myGraph.mxShape;
|
|
21
|
-
const mxCellRenderer = myGraph.mxCellRenderer;
|
|
22
|
-
|
|
23
|
-
// Defines a custom stencil via the canvas API as defined here:
|
|
24
|
-
// http://jgraph.github.io/mxgraph/docs/js-api/files/util/mxXmlCanvas2D-js.html
|
|
25
|
-
function CLCDrawingCanvas(): any {
|
|
26
|
-
mxShape.call(this);
|
|
27
|
-
}
|
|
28
|
-
mxUtils.extend(CLCDrawingCanvas, mxShape);
|
|
29
|
-
mxCellRenderer.registerShape("CLCDrawingCanvas", CLCDrawingCanvas);
|
|
30
|
-
|
|
31
|
-
type CLCMode =
|
|
32
|
-
| "AND-OR"
|
|
33
|
-
| "OR-XOR"
|
|
34
|
-
| "4-input AND"
|
|
35
|
-
| "SR latch"
|
|
36
|
-
| "1-input D flip-flop with S and R"
|
|
37
|
-
| "2-input D flip-flop with R"
|
|
38
|
-
| "JK flip-flop with R"
|
|
39
|
-
| "1-input transparent latch with S and R";
|
|
40
|
-
|
|
41
|
-
interface Hardware {
|
|
42
|
-
lcmodeClccon?: string;
|
|
43
|
-
lcenClccon?: boolean;
|
|
44
|
-
lcg1polClcpol?: string;
|
|
45
|
-
lcg2polClcpol?: string;
|
|
46
|
-
lcg3polClcpol?: string;
|
|
47
|
-
lcg4polClcpol?: string;
|
|
48
|
-
lcpolClcpol?: string;
|
|
49
|
-
lcd1sClcsel0?: string;
|
|
50
|
-
lcd2sClcsel1?: string;
|
|
51
|
-
lcd3sClcsel2?: string;
|
|
52
|
-
lcd4sClcsel3?: string;
|
|
53
|
-
lcg1d1nClcgls0?: boolean;
|
|
54
|
-
lcg1d1tClcgls0?: boolean;
|
|
55
|
-
lcg1d2nClcgls0?: boolean;
|
|
56
|
-
lcg1d2tClcgls0?: boolean;
|
|
57
|
-
lcg1d3nClcgls0?: boolean;
|
|
58
|
-
lcg1d3tClcgls0?: boolean;
|
|
59
|
-
lcg1d4nClcgls0?: boolean;
|
|
60
|
-
lcg1d4tClcgls0?: boolean;
|
|
61
|
-
lcg2d1nClcgls1?: boolean;
|
|
62
|
-
lcg2d1tClcgls1?: boolean;
|
|
63
|
-
lcg2d2nClcgls1?: boolean;
|
|
64
|
-
lcg2d2tClcgls1?: boolean;
|
|
65
|
-
lcg2d3nClcgls1?: boolean;
|
|
66
|
-
lcg2d3tClcgls1?: boolean;
|
|
67
|
-
lcg2d4nClcgls1?: boolean;
|
|
68
|
-
lcg2d4tClcgls1?: boolean;
|
|
69
|
-
lcg3d1nClcgls2?: boolean;
|
|
70
|
-
lcg3d1tClcgls2?: boolean;
|
|
71
|
-
lcg3d2nClcgls2?: boolean;
|
|
72
|
-
lcg3d2tClcgls2?: boolean;
|
|
73
|
-
lcg3d3nClcgls2?: boolean;
|
|
74
|
-
lcg3d3tClcgls2?: boolean;
|
|
75
|
-
lcg3d4nClcgls2?: boolean;
|
|
76
|
-
lcg3d4tClcgls2?: boolean;
|
|
77
|
-
lcg4d1nClcgls3?: boolean;
|
|
78
|
-
lcg4d1tClcgls3?: boolean;
|
|
79
|
-
lcg4d2nClcgls3?: boolean;
|
|
80
|
-
lcg4d2tClcgls3?: boolean;
|
|
81
|
-
lcg4d3nClcgls3?: boolean;
|
|
82
|
-
lcg4d3tClcgls3?: boolean;
|
|
83
|
-
lcg4d4nClcgls3?: boolean;
|
|
84
|
-
lcg4d4tClcgls3?: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface Props {
|
|
88
|
-
hardware?: Hardware;
|
|
89
|
-
dispatch: Dispatch;
|
|
90
|
-
onGateOutputClick: (gate: string) => void;
|
|
91
|
-
onGateInputClick: (gate: string, input: string) => void;
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class Canvas extends React.Component<Props> {
|
|
96
|
-
private graph: any;
|
|
97
|
-
private canvas: any;
|
|
98
|
-
private container: Element;
|
|
99
|
-
private gate1: ALogicGate;
|
|
100
|
-
private gate2: ALogicGate;
|
|
101
|
-
private gate3: ALogicGate;
|
|
102
|
-
private gate4: ALogicGate;
|
|
103
|
-
private gate5: ALogicGate;
|
|
104
|
-
|
|
105
|
-
constructor(props: Props) {
|
|
106
|
-
super(props);
|
|
107
|
-
this.LoadGraph = this.LoadGraph.bind(this);
|
|
108
|
-
this.paint = this.paint.bind(this);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
componentDidMount(): void {
|
|
112
|
-
this.initializeGates();
|
|
113
|
-
this.LoadGraph();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
componentDidUpdate(): void {
|
|
117
|
-
this.initializeGates();
|
|
118
|
-
this.updateGraph();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
componentWillUnmount(): void {
|
|
122
|
-
this.graph.destroy();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private initializeGates(): void {
|
|
126
|
-
const hw = this.props.hardware;
|
|
127
|
-
const isInverted = (polarity?: string): boolean => polarity === "inverted";
|
|
128
|
-
const getInputState = (t = false, n = false): any =>
|
|
129
|
-
InputStateCalculator.getInputState(t, n);
|
|
130
|
-
|
|
131
|
-
this.gate1 = new OrGate(420, 150, isInverted(hw?.lcg1polClcpol), {
|
|
132
|
-
gateInput1State: getInputState(hw?.lcg1d1tClcgls0, hw?.lcg1d1nClcgls0),
|
|
133
|
-
gateInput2State: getInputState(hw?.lcg1d2tClcgls0, hw?.lcg1d2nClcgls0),
|
|
134
|
-
gateInput3State: getInputState(hw?.lcg1d3tClcgls0, hw?.lcg1d3nClcgls0),
|
|
135
|
-
gateInput4State: getInputState(hw?.lcg1d4tClcgls0, hw?.lcg1d4nClcgls0),
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
this.gate2 = new OrGate(420, 250, isInverted(hw?.lcg2polClcpol), {
|
|
139
|
-
gateInput1State: getInputState(hw?.lcg2d1tClcgls1, hw?.lcg2d1nClcgls1),
|
|
140
|
-
gateInput2State: getInputState(hw?.lcg2d2tClcgls1, hw?.lcg2d2nClcgls1),
|
|
141
|
-
gateInput3State: getInputState(hw?.lcg2d3tClcgls1, hw?.lcg2d3nClcgls1),
|
|
142
|
-
gateInput4State: getInputState(hw?.lcg2d4tClcgls1, hw?.lcg2d4nClcgls1),
|
|
143
|
-
});
|
|
144
|
-
this.gate3 = new OrGate(420, 350, isInverted(hw?.lcg3polClcpol), {
|
|
145
|
-
gateInput1State: getInputState(hw?.lcg3d1tClcgls2, hw?.lcg3d1nClcgls2),
|
|
146
|
-
gateInput2State: getInputState(hw?.lcg3d2tClcgls2, hw?.lcg3d2nClcgls2),
|
|
147
|
-
gateInput3State: getInputState(hw?.lcg3d3tClcgls2, hw?.lcg3d3nClcgls2),
|
|
148
|
-
gateInput4State: getInputState(hw?.lcg3d4tClcgls2, hw?.lcg3d4nClcgls2),
|
|
149
|
-
});
|
|
150
|
-
this.gate4 = new OrGate(420, 450, isInverted(hw?.lcg4polClcpol), {
|
|
151
|
-
gateInput1State: getInputState(hw?.lcg4d1tClcgls3, hw?.lcg4d1nClcgls3),
|
|
152
|
-
gateInput2State: getInputState(hw?.lcg4d2tClcgls3, hw?.lcg4d2nClcgls3),
|
|
153
|
-
gateInput3State: getInputState(hw?.lcg4d3tClcgls3, hw?.lcg4d3nClcgls3),
|
|
154
|
-
gateInput4State: getInputState(hw?.lcg4d4tClcgls3, hw?.lcg4d4nClcgls3),
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
this.gate5 = new NotGate(1000, 300, isInverted(hw?.lcpolClcpol));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
LoadGraph(): void {
|
|
161
|
-
// Checks if the browser is supported
|
|
162
|
-
if (!mxClient.isBrowserSupported()) {
|
|
163
|
-
// Displays an error message if the browser is not supported.
|
|
164
|
-
mxUtils.error("Browser is not supported!", 200, false);
|
|
165
|
-
} else {
|
|
166
|
-
// eslint-disable-next-line react/no-find-dom-node, react/no-string-refs
|
|
167
|
-
this.container = ReactDOM.findDOMNode(this.refs.divGraph) as Element;
|
|
168
|
-
|
|
169
|
-
// Disables the built-in context menu
|
|
170
|
-
mxEvent.disableContextMenu(this.container);
|
|
171
|
-
|
|
172
|
-
// Creates the graph inside the given container
|
|
173
|
-
this.graph = new mxGraph(this.container);
|
|
174
|
-
const graph = this.graph;
|
|
175
|
-
graph.setEnabled(false);
|
|
176
|
-
|
|
177
|
-
const strokeWidth = 2;
|
|
178
|
-
const fontColor = "#000000";
|
|
179
|
-
const strokeColor = "#000000";
|
|
180
|
-
|
|
181
|
-
const style = graph.getStylesheet().getDefaultVertexStyle();
|
|
182
|
-
style["strokeColor"] = strokeColor;
|
|
183
|
-
style["fontColor"] = fontColor;
|
|
184
|
-
style["strokeWidth"] = strokeWidth;
|
|
185
|
-
|
|
186
|
-
// Override default paintBackground. Renders it once
|
|
187
|
-
CLCDrawingCanvas.prototype.paintBackground = this.paint;
|
|
188
|
-
|
|
189
|
-
graph.addListener(mxEvent.CLICK, (sender, evt) => {
|
|
190
|
-
const id: string = evt.getProperty("cell")?.id;
|
|
191
|
-
|
|
192
|
-
const outputMatch = id?.match(/^gate(\d)$/);
|
|
193
|
-
if (outputMatch) {
|
|
194
|
-
const num = outputMatch[1];
|
|
195
|
-
this.props.onGateOutputClick(num);
|
|
196
|
-
evt.consume();
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const inputMatch = id?.match(/^gate(\d)in(\d)$/);
|
|
201
|
-
if (inputMatch) {
|
|
202
|
-
const gate = inputMatch[1];
|
|
203
|
-
const input = inputMatch[2];
|
|
204
|
-
this.props.onGateInputClick(gate, input);
|
|
205
|
-
evt.consume();
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Gets the default parent for inserting new cells. This is normally the first
|
|
211
|
-
// child of the root (ie. layer 0).
|
|
212
|
-
const parent = graph.getDefaultParent();
|
|
213
|
-
|
|
214
|
-
graph.getModel().beginUpdate();
|
|
215
|
-
try {
|
|
216
|
-
const getOutputTarget = (gate: ALogicGate, id: string): any => {
|
|
217
|
-
return gate.getOutputTarget(graph, parent, id);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const getInputTarget = (gate: ALogicGate, i: number, id: string): any => {
|
|
221
|
-
return gate.getInputTarget(i, graph, parent, id);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const targets = [
|
|
225
|
-
getOutputTarget(this.gate1, "gate1"),
|
|
226
|
-
getOutputTarget(this.gate2, "gate2"),
|
|
227
|
-
getOutputTarget(this.gate3, "gate3"),
|
|
228
|
-
getOutputTarget(this.gate4, "gate4"),
|
|
229
|
-
getOutputTarget(this.gate5, "gate5"),
|
|
230
|
-
getInputTarget(this.gate1, 1, "gate1in1"),
|
|
231
|
-
getInputTarget(this.gate1, 2, "gate1in2"),
|
|
232
|
-
getInputTarget(this.gate1, 3, "gate1in3"),
|
|
233
|
-
getInputTarget(this.gate1, 4, "gate1in4"),
|
|
234
|
-
getInputTarget(this.gate2, 1, "gate2in1"),
|
|
235
|
-
getInputTarget(this.gate2, 2, "gate2in2"),
|
|
236
|
-
getInputTarget(this.gate2, 3, "gate2in3"),
|
|
237
|
-
getInputTarget(this.gate2, 4, "gate2in4"),
|
|
238
|
-
getInputTarget(this.gate3, 1, "gate3in1"),
|
|
239
|
-
getInputTarget(this.gate3, 2, "gate3in2"),
|
|
240
|
-
getInputTarget(this.gate3, 3, "gate3in3"),
|
|
241
|
-
getInputTarget(this.gate3, 4, "gate3in4"),
|
|
242
|
-
getInputTarget(this.gate4, 1, "gate4in1"),
|
|
243
|
-
getInputTarget(this.gate4, 2, "gate4in2"),
|
|
244
|
-
getInputTarget(this.gate4, 3, "gate4in3"),
|
|
245
|
-
getInputTarget(this.gate4, 4, "gate4in4"),
|
|
246
|
-
];
|
|
247
|
-
|
|
248
|
-
targets.forEach((target) => graph.addCell(target, parent));
|
|
249
|
-
|
|
250
|
-
graph.getCursorForCell = function (cell: any): any {
|
|
251
|
-
if (targets.indexOf(cell) !== -1) {
|
|
252
|
-
return "pointer";
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
};
|
|
256
|
-
} finally {
|
|
257
|
-
// Updates the display
|
|
258
|
-
graph.getModel().endUpdate();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private drawCanvas(graph: any, parent: any): any {
|
|
264
|
-
this.canvas = graph.insertVertex(
|
|
265
|
-
parent,
|
|
266
|
-
null,
|
|
267
|
-
null,
|
|
268
|
-
0,
|
|
269
|
-
0,
|
|
270
|
-
CANVAS_WIDTH,
|
|
271
|
-
CANVAS_HEIGHT,
|
|
272
|
-
"shape=CLCDrawingCanvas",
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
// Move canvas to the back so the targets are easily clickable
|
|
276
|
-
graph.cellsOrdered([this.canvas], true);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
private updateGraph(): void {
|
|
280
|
-
const graph = this.graph;
|
|
281
|
-
const parent = graph.getDefaultParent();
|
|
282
|
-
|
|
283
|
-
graph.getModel().beginUpdate();
|
|
284
|
-
try {
|
|
285
|
-
graph.removeCells([this.canvas]);
|
|
286
|
-
this.drawCanvas(graph, parent);
|
|
287
|
-
} finally {
|
|
288
|
-
// Updates the display
|
|
289
|
-
graph.getModel().endUpdate();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private paint(c, x, y, w, h): void {
|
|
294
|
-
c.begin();
|
|
295
|
-
|
|
296
|
-
this.gate1.draw(c);
|
|
297
|
-
this.gate2.draw(c);
|
|
298
|
-
this.gate3.draw(c);
|
|
299
|
-
this.gate4.draw(c);
|
|
300
|
-
this.gate5.draw(c);
|
|
301
|
-
|
|
302
|
-
c.text(425, 147, 0, 0, "1");
|
|
303
|
-
c.text(425, 247, 0, 0, "2");
|
|
304
|
-
c.text(425, 347, 0, 0, "3");
|
|
305
|
-
c.text(425, 447, 0, 0, "4");
|
|
306
|
-
|
|
307
|
-
const line = (x1: number, y1: number, x2: number, y2: number): void => {
|
|
308
|
-
c.moveTo(x1, y1);
|
|
309
|
-
c.lineTo(x2, y2);
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
line(220, this.gate4.getYInput1(), 220, this.gate1.getYInput1());
|
|
313
|
-
line(250, this.gate4.getYInput2(), 250, this.gate1.getYInput2());
|
|
314
|
-
line(280, this.gate4.getYInput3(), 280, this.gate1.getYInput3());
|
|
315
|
-
line(310, this.gate4.getYInput4(), 310, this.gate1.getYInput4());
|
|
316
|
-
|
|
317
|
-
const drawConnectingDots = (x: number, y: number): void => {
|
|
318
|
-
c.stroke();
|
|
319
|
-
c.begin();
|
|
320
|
-
c.setFillColor(0);
|
|
321
|
-
c.ellipse(x, y, 10, 10);
|
|
322
|
-
c.fillAndStroke();
|
|
323
|
-
c.begin();
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
drawConnectingDots(220 - 5, this.gate1.getYInput1() - 5);
|
|
327
|
-
drawConnectingDots(220 - 5, this.gate2.getYInput1() - 5);
|
|
328
|
-
drawConnectingDots(220 - 5, this.gate3.getYInput1() - 5);
|
|
329
|
-
drawConnectingDots(250 - 5, this.gate2.getYInput2() - 5);
|
|
330
|
-
drawConnectingDots(250 - 5, this.gate3.getYInput2() - 5);
|
|
331
|
-
drawConnectingDots(280 - 5, this.gate2.getYInput3() - 5);
|
|
332
|
-
drawConnectingDots(280 - 5, this.gate3.getYInput3() - 5);
|
|
333
|
-
drawConnectingDots(310 - 5, this.gate2.getYInput4() - 5);
|
|
334
|
-
drawConnectingDots(310 - 5, this.gate3.getYInput4() - 5);
|
|
335
|
-
drawConnectingDots(310 - 5, this.gate4.getYInput4() - 5);
|
|
336
|
-
|
|
337
|
-
this.gate1.drawGateOutput(c, 561);
|
|
338
|
-
this.gate2.drawGateOutput(c, 561);
|
|
339
|
-
this.gate3.drawGateOutput(c, 561);
|
|
340
|
-
this.gate4.drawGateOutput(c, 561);
|
|
341
|
-
this.gate5.drawGateOutput(c, 1100);
|
|
342
|
-
|
|
343
|
-
this.gate1.drawGateOutput(c, 561);
|
|
344
|
-
this.gate2.drawGateOutput(c, 561);
|
|
345
|
-
this.gate3.drawGateOutput(c, 561);
|
|
346
|
-
this.gate4.drawGateOutput(c, 561);
|
|
347
|
-
this.gate5.drawGateOutput(c, 1100);
|
|
348
|
-
|
|
349
|
-
this.gate1.drawGateInput(c, 1, 170);
|
|
350
|
-
this.gate1.drawGateInput(c, 2, 250);
|
|
351
|
-
this.gate1.drawGateInput(c, 3, 280);
|
|
352
|
-
this.gate1.drawGateInput(c, 4, 310);
|
|
353
|
-
|
|
354
|
-
this.gate2.drawGateInput(c, 1, 220);
|
|
355
|
-
this.gate2.drawGateInput(c, 2, 170);
|
|
356
|
-
this.gate2.drawGateInput(c, 3, 280);
|
|
357
|
-
this.gate2.drawGateInput(c, 4, 310);
|
|
358
|
-
|
|
359
|
-
this.gate3.drawGateInput(c, 1, 220);
|
|
360
|
-
this.gate3.drawGateInput(c, 2, 250);
|
|
361
|
-
this.gate3.drawGateInput(c, 3, 170);
|
|
362
|
-
this.gate3.drawGateInput(c, 4, 310);
|
|
363
|
-
|
|
364
|
-
this.gate4.drawGateInput(c, 1, 220);
|
|
365
|
-
this.gate4.drawGateInput(c, 2, 250);
|
|
366
|
-
this.gate4.drawGateInput(c, 3, 280);
|
|
367
|
-
this.gate4.drawGateInput(c, 4, 170);
|
|
368
|
-
|
|
369
|
-
this.gate5.drawGateInput(c, 1, 950);
|
|
370
|
-
|
|
371
|
-
switch (this.props.hardware?.lcmodeClccon as CLCMode) {
|
|
372
|
-
case "AND-OR":
|
|
373
|
-
drawAndOr();
|
|
374
|
-
break;
|
|
375
|
-
case "OR-XOR":
|
|
376
|
-
drawOrXor();
|
|
377
|
-
break;
|
|
378
|
-
case "4-input AND":
|
|
379
|
-
draw4InputAnd();
|
|
380
|
-
break;
|
|
381
|
-
case "SR latch":
|
|
382
|
-
drawSRLatch();
|
|
383
|
-
break;
|
|
384
|
-
case "1-input D flip-flop with S and R":
|
|
385
|
-
drawDFlop();
|
|
386
|
-
break;
|
|
387
|
-
case "2-input D flip-flop with R":
|
|
388
|
-
drawOrDLatch();
|
|
389
|
-
break;
|
|
390
|
-
case "JK flip-flop with R":
|
|
391
|
-
drawJKFlop();
|
|
392
|
-
break;
|
|
393
|
-
case "1-input transparent latch with S and R":
|
|
394
|
-
drawDLatch();
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
c.stroke();
|
|
399
|
-
|
|
400
|
-
function drawAndOr(): void {
|
|
401
|
-
c.translate(561, 43);
|
|
402
|
-
|
|
403
|
-
const srGate1: ALogicGate = new AndGate(100, 200);
|
|
404
|
-
const srGate2: ALogicGate = new AndGate(100, 312);
|
|
405
|
-
const srGate3: ALogicGate = new OrGate(300, 257);
|
|
406
|
-
|
|
407
|
-
srGate1.draw(c);
|
|
408
|
-
srGate2.draw(c);
|
|
409
|
-
srGate3.draw(c);
|
|
410
|
-
|
|
411
|
-
srGate3.drawGateInput(c, 1, 200);
|
|
412
|
-
line(200, srGate3.getYInput1(), 200, srGate1.getYOutput());
|
|
413
|
-
line(200, srGate1.getYOutput(), srGate1.getXOutput(), srGate1.getYOutput());
|
|
414
|
-
|
|
415
|
-
srGate3.drawGateInput(c, 4, 200);
|
|
416
|
-
line(200, srGate3.getYInput4(), 200, srGate2.getYOutput());
|
|
417
|
-
line(200, srGate2.getYOutput(), srGate2.getXOutput(), srGate2.getYOutput());
|
|
418
|
-
|
|
419
|
-
// Output connection
|
|
420
|
-
line(
|
|
421
|
-
srGate3.getXOutput(),
|
|
422
|
-
srGate3.getYOutput(),
|
|
423
|
-
srGate3.getXOutput() + 50,
|
|
424
|
-
srGate3.getYOutput(),
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
// 4 inputs
|
|
428
|
-
line(0, 107, 20, 107);
|
|
429
|
-
line(20, 107, 20, srGate1.getYInput1());
|
|
430
|
-
line(20, srGate1.getYInput1(), srGate1.getXInput1(), srGate1.getYInput1());
|
|
431
|
-
|
|
432
|
-
line(0, 207, 20, 207);
|
|
433
|
-
line(20, 207, 20, srGate1.getYInput4());
|
|
434
|
-
line(20, srGate1.getYInput4(), srGate1.getXInput4(), srGate1.getYInput4());
|
|
435
|
-
|
|
436
|
-
line(0, 307, 20, 307);
|
|
437
|
-
line(20, 307, 20, srGate2.getYInput1());
|
|
438
|
-
line(20, srGate2.getYInput1(), srGate2.getXInput1(), srGate2.getYInput1());
|
|
439
|
-
|
|
440
|
-
line(0, 407, 20, 407);
|
|
441
|
-
line(20, 407, 20, srGate2.getYInput4());
|
|
442
|
-
line(20, srGate2.getYInput4(), srGate2.getXInput4(), srGate2.getYInput4());
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
function drawOrXor(): void {
|
|
446
|
-
c.translate(561, 43);
|
|
447
|
-
|
|
448
|
-
const srGate1: ALogicGate = new OrGate(100, 200);
|
|
449
|
-
const srGate2: ALogicGate = new OrGate(100, 312);
|
|
450
|
-
const srGate3: ALogicGate = new XorGate(300, 257);
|
|
451
|
-
|
|
452
|
-
srGate1.draw(c);
|
|
453
|
-
srGate2.draw(c);
|
|
454
|
-
srGate3.draw(c);
|
|
455
|
-
|
|
456
|
-
srGate3.drawGateInput(c, 1, 200);
|
|
457
|
-
line(200, srGate3.getYInput1(), 200, srGate1.getYOutput());
|
|
458
|
-
line(200, srGate1.getYOutput(), srGate1.getXOutput(), srGate1.getYOutput());
|
|
459
|
-
|
|
460
|
-
srGate3.drawGateInput(c, 4, 200);
|
|
461
|
-
line(200, srGate3.getYInput4(), 200, srGate2.getYOutput());
|
|
462
|
-
line(200, srGate2.getYOutput(), srGate2.getXOutput(), srGate2.getYOutput());
|
|
463
|
-
|
|
464
|
-
// Output connection
|
|
465
|
-
line(
|
|
466
|
-
srGate3.getXOutput(),
|
|
467
|
-
srGate3.getYOutput(),
|
|
468
|
-
srGate3.getXOutput() + 50,
|
|
469
|
-
srGate3.getYOutput(),
|
|
470
|
-
);
|
|
471
|
-
|
|
472
|
-
// 4 inputs
|
|
473
|
-
line(0, 107, 20, 107);
|
|
474
|
-
line(20, 107, 20, srGate1.getYInput1());
|
|
475
|
-
line(20, srGate1.getYInput1(), srGate1.getXInput1(), srGate1.getYInput1());
|
|
476
|
-
|
|
477
|
-
line(0, 207, 20, 207);
|
|
478
|
-
line(20, 207, 20, srGate1.getYInput4());
|
|
479
|
-
line(20, srGate1.getYInput4(), srGate1.getXInput4(), srGate1.getYInput4());
|
|
480
|
-
|
|
481
|
-
line(0, 307, 20, 307);
|
|
482
|
-
line(20, 307, 20, srGate2.getYInput1());
|
|
483
|
-
line(20, srGate2.getYInput1(), srGate2.getXInput1(), srGate2.getYInput1());
|
|
484
|
-
|
|
485
|
-
line(0, 407, 20, 407);
|
|
486
|
-
line(20, 407, 20, srGate2.getYInput4());
|
|
487
|
-
line(20, srGate2.getYInput4(), srGate2.getXInput4(), srGate2.getYInput4());
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function draw4InputAnd(): void {
|
|
491
|
-
c.translate(561, 43);
|
|
492
|
-
|
|
493
|
-
const gate: ALogicGate = new AndGate(300, 257);
|
|
494
|
-
|
|
495
|
-
gate.draw(c);
|
|
496
|
-
|
|
497
|
-
// Output connection
|
|
498
|
-
line(
|
|
499
|
-
gate.getXOutput(),
|
|
500
|
-
gate.getYOutput(),
|
|
501
|
-
gate.getXOutput() + 50,
|
|
502
|
-
gate.getYOutput(),
|
|
503
|
-
);
|
|
504
|
-
|
|
505
|
-
// 4 inputs
|
|
506
|
-
line(0, 107, 170, 107);
|
|
507
|
-
line(170, 107, 170, gate.getYInput1());
|
|
508
|
-
line(170, gate.getYInput1(), gate.getXInput1(), gate.getYInput1());
|
|
509
|
-
|
|
510
|
-
line(0, 207, 120, 207);
|
|
511
|
-
line(120, 207, 120, gate.getYInput2());
|
|
512
|
-
line(120, gate.getYInput2(), gate.getXInput2(), gate.getYInput2());
|
|
513
|
-
|
|
514
|
-
line(0, 307, 120, 307);
|
|
515
|
-
line(120, 307, 120, gate.getYInput3());
|
|
516
|
-
line(120, gate.getYInput3(), gate.getXInput3(), gate.getYInput3());
|
|
517
|
-
|
|
518
|
-
line(0, 407, 170, 407);
|
|
519
|
-
line(170, 407, 170, gate.getYInput4());
|
|
520
|
-
line(170, gate.getYInput4(), gate.getXInput4(), gate.getYInput4());
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function drawSRLatch(): void {
|
|
524
|
-
c.translate(561, 43);
|
|
525
|
-
|
|
526
|
-
const g1: ALogicGate = new OrGate(100, 200);
|
|
527
|
-
const g2: ALogicGate = new OrGate(100, 312);
|
|
528
|
-
const sr: Latch = new Latch({
|
|
529
|
-
x: 220,
|
|
530
|
-
y: 160,
|
|
531
|
-
textLeftTop: "S",
|
|
532
|
-
textLeftBottom: "R",
|
|
533
|
-
textRightTop: "Q",
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
g1.draw(c);
|
|
537
|
-
g2.draw(c);
|
|
538
|
-
sr.draw(c);
|
|
539
|
-
|
|
540
|
-
// 4 inputs
|
|
541
|
-
line(0, 107, 20, 107);
|
|
542
|
-
line(20, 107, 20, g1.getYInput1());
|
|
543
|
-
line(20, g1.getYInput1(), g1.getXInput1(), g1.getYInput1());
|
|
544
|
-
|
|
545
|
-
line(0, 207, 20, 207);
|
|
546
|
-
line(20, 207, 20, g1.getYInput4());
|
|
547
|
-
line(20, g1.getYInput4(), g1.getXInput4(), g1.getYInput4());
|
|
548
|
-
|
|
549
|
-
line(0, 307, 20, 307);
|
|
550
|
-
line(20, 307, 20, g2.getYInput1());
|
|
551
|
-
line(20, g2.getYInput1(), g2.getXInput1(), g2.getYInput1());
|
|
552
|
-
|
|
553
|
-
line(0, 407, 20, 407);
|
|
554
|
-
line(20, 407, 20, g2.getYInput4());
|
|
555
|
-
line(20, g2.getYInput4(), g2.getXInput4(), g2.getYInput4());
|
|
556
|
-
|
|
557
|
-
// Latch Inputs
|
|
558
|
-
line(g1.getXOutput(), g1.getYOutput(), sr.getXInput1(), sr.getYInput1());
|
|
559
|
-
line(g2.getXOutput(), g2.getYOutput(), sr.getXInput2(), sr.getYInput2());
|
|
560
|
-
|
|
561
|
-
// Latch Output
|
|
562
|
-
line(350, 200, 388, 200);
|
|
563
|
-
line(388, 200, 388, 257);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function drawDFlop(): void {
|
|
567
|
-
c.translate(561, 43);
|
|
568
|
-
const df: Latch = new Latch({
|
|
569
|
-
x: 150,
|
|
570
|
-
y: 167,
|
|
571
|
-
textLeftTop: "D",
|
|
572
|
-
textTop: "S",
|
|
573
|
-
textBottom: "R",
|
|
574
|
-
textRightTop: "Q",
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
df.draw(c);
|
|
578
|
-
|
|
579
|
-
// 4 inputs
|
|
580
|
-
line(0, 107, 100, 107);
|
|
581
|
-
line(100, 107, 100, df.getYInput2());
|
|
582
|
-
line(100, df.getYInput2(), df.getXInput2(), df.getYInput2());
|
|
583
|
-
|
|
584
|
-
line(0, 207, 100, 207);
|
|
585
|
-
line(100, 207, 100, df.getYInput1());
|
|
586
|
-
line(100, df.getYInput1(), df.getXInput2(), df.getYInput1());
|
|
587
|
-
|
|
588
|
-
line(0, 307, 51, 307);
|
|
589
|
-
line(51, 307, 51, 380);
|
|
590
|
-
line(51, 380, df.getXInput3(), 380);
|
|
591
|
-
line(df.getXInput3(), 380, df.getXInput3(), df.getYInput3());
|
|
592
|
-
|
|
593
|
-
line(0, 407, 2, 407);
|
|
594
|
-
line(2, 407, 2, 137);
|
|
595
|
-
line(2, 137, df.getXInput4(), 137);
|
|
596
|
-
line(df.getXInput4(), 137, df.getXInput4(), df.getYInput4());
|
|
597
|
-
|
|
598
|
-
// Draw Clock Input
|
|
599
|
-
line(
|
|
600
|
-
df.getXInput2(),
|
|
601
|
-
df.getYInput2() - 10,
|
|
602
|
-
df.getXInput2() + 20,
|
|
603
|
-
df.getYInput2(),
|
|
604
|
-
);
|
|
605
|
-
line(
|
|
606
|
-
df.getXInput2(),
|
|
607
|
-
df.getYInput2() + 10,
|
|
608
|
-
df.getXInput2() + 20,
|
|
609
|
-
df.getYInput2(),
|
|
610
|
-
);
|
|
611
|
-
|
|
612
|
-
// Latch Output
|
|
613
|
-
line(df.getXOutput1(), df.getYOutput1(), 388, df.getYOutput1());
|
|
614
|
-
line(388, df.getYOutput1(), 388, 257);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function drawOrDLatch(): void {
|
|
618
|
-
c.translate(561, 43);
|
|
619
|
-
|
|
620
|
-
const df: Latch = new Latch({
|
|
621
|
-
x: 220,
|
|
622
|
-
y: 160,
|
|
623
|
-
textLeftTop: "D",
|
|
624
|
-
textBottom: "R",
|
|
625
|
-
textRightTop: "Q",
|
|
626
|
-
});
|
|
627
|
-
const g1: ALogicGate = new OrGate(100, df.getYInput1());
|
|
628
|
-
|
|
629
|
-
g1.draw(c);
|
|
630
|
-
df.draw(c);
|
|
631
|
-
|
|
632
|
-
// 4 inputs
|
|
633
|
-
line(0, 107, 195, 107);
|
|
634
|
-
line(195, 107, 195, df.getYInput2());
|
|
635
|
-
line(195, df.getYInput2(), df.getXInput2(), df.getYInput2());
|
|
636
|
-
|
|
637
|
-
line(0, 207, 2, 207);
|
|
638
|
-
line(2, 207, 2, g1.getYInput1());
|
|
639
|
-
line(2, g1.getYInput1(), g1.getXInput1(), g1.getYInput1());
|
|
640
|
-
|
|
641
|
-
line(0, 307, 100, 307);
|
|
642
|
-
line(100, 307, 100, df.getYInput3() + 50);
|
|
643
|
-
line(100, df.getYInput3() + 50, df.getXInput3(), df.getYInput3() + 50);
|
|
644
|
-
line(df.getXInput3(), df.getYInput3() + 50, df.getXInput3(), df.getYInput3());
|
|
645
|
-
|
|
646
|
-
line(0, 407, 35, 407);
|
|
647
|
-
line(35, 407, 35, g1.getYInput4());
|
|
648
|
-
line(35, g1.getYInput4(), g1.getXInput4(), g1.getYInput4());
|
|
649
|
-
|
|
650
|
-
// Draw Clock Input
|
|
651
|
-
line(
|
|
652
|
-
df.getXInput2(),
|
|
653
|
-
df.getYInput2() - 10,
|
|
654
|
-
df.getXInput2() + 20,
|
|
655
|
-
df.getYInput2(),
|
|
656
|
-
);
|
|
657
|
-
line(
|
|
658
|
-
df.getXInput2(),
|
|
659
|
-
df.getYInput2() + 10,
|
|
660
|
-
df.getXInput2() + 20,
|
|
661
|
-
df.getYInput2(),
|
|
662
|
-
);
|
|
663
|
-
|
|
664
|
-
// Latch Inputs
|
|
665
|
-
line(g1.getXOutput(), g1.getYOutput(), df.getXInput1(), df.getYInput1());
|
|
666
|
-
|
|
667
|
-
// Latch Output
|
|
668
|
-
line(df.getXOutput1(), df.getYOutput1(), 388, df.getYOutput1());
|
|
669
|
-
line(388, df.getYOutput1(), 388, 257);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function drawJKFlop(): void {
|
|
673
|
-
c.translate(561, 43);
|
|
674
|
-
|
|
675
|
-
const jk: Latch = new Latch({
|
|
676
|
-
x: 150,
|
|
677
|
-
y: 167,
|
|
678
|
-
textLeftTop: "J",
|
|
679
|
-
textLeftBottom: "K",
|
|
680
|
-
textRightTop: "Q",
|
|
681
|
-
textBottom: "R",
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
jk.draw(c);
|
|
685
|
-
|
|
686
|
-
// 4 inputs
|
|
687
|
-
line(0, 107, 100, 107);
|
|
688
|
-
line(100, 107, 100, 262);
|
|
689
|
-
line(100, 262, jk.getXInput2(), 262);
|
|
690
|
-
|
|
691
|
-
line(0, 207, 100, 207);
|
|
692
|
-
line(100, 207, 100, jk.getYInput1());
|
|
693
|
-
line(100, jk.getYInput1(), jk.getXInput2(), jk.getYInput1());
|
|
694
|
-
|
|
695
|
-
line(0, 307, 51, 307);
|
|
696
|
-
line(51, 307, 51, 380);
|
|
697
|
-
line(51, 380, jk.getXInput3(), 380);
|
|
698
|
-
line(jk.getXInput3(), 380, jk.getXInput3(), jk.getYInput3());
|
|
699
|
-
|
|
700
|
-
line(0, 407, 100, 407);
|
|
701
|
-
line(100, 407, 100, jk.getYInput2());
|
|
702
|
-
line(100, jk.getYInput2(), jk.getXInput2(), jk.getYInput2());
|
|
703
|
-
|
|
704
|
-
// Draw Clock Input
|
|
705
|
-
line(jk.getXInput2(), 262 - 10, jk.getXInput2() + 20, 262);
|
|
706
|
-
line(jk.getXInput2(), 262 + 10, jk.getXInput2() + 20, 262);
|
|
707
|
-
|
|
708
|
-
// Latch Output
|
|
709
|
-
line(jk.getXOutput1(), jk.getYOutput1(), 388, jk.getYOutput1());
|
|
710
|
-
line(388, jk.getYOutput1(), 388, 257);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
function drawDLatch(): void {
|
|
714
|
-
c.translate(561, 43);
|
|
715
|
-
|
|
716
|
-
const dl: Latch = new Latch({
|
|
717
|
-
x: 150,
|
|
718
|
-
y: 167,
|
|
719
|
-
textLeftTop: "D",
|
|
720
|
-
textLeftBottom: "LE",
|
|
721
|
-
textTop: "S",
|
|
722
|
-
textRightTop: "Q",
|
|
723
|
-
textBottom: "R",
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
dl.draw(c);
|
|
727
|
-
|
|
728
|
-
// 4 inputs
|
|
729
|
-
line(0, 107, 100, 107);
|
|
730
|
-
line(100, 107, 100, dl.getYInput2());
|
|
731
|
-
line(100, dl.getYInput2(), dl.getXInput2(), dl.getYInput2());
|
|
732
|
-
|
|
733
|
-
line(0, 207, 100, 207);
|
|
734
|
-
line(100, 207, 100, dl.getYInput1());
|
|
735
|
-
line(100, dl.getYInput1(), dl.getXInput2(), dl.getYInput1());
|
|
736
|
-
|
|
737
|
-
line(0, 307, 51, 307);
|
|
738
|
-
line(51, 307, 51, 380);
|
|
739
|
-
line(51, 380, dl.getXInput3(), 380);
|
|
740
|
-
line(dl.getXInput3(), 380, dl.getXInput3(), dl.getYInput3());
|
|
741
|
-
|
|
742
|
-
line(0, 407, 2, 407);
|
|
743
|
-
line(2, 407, 2, 137);
|
|
744
|
-
line(2, 137, dl.getXInput4(), 137);
|
|
745
|
-
line(dl.getXInput4(), 137, dl.getXInput4(), dl.getYInput4());
|
|
746
|
-
|
|
747
|
-
// Latch Output
|
|
748
|
-
line(dl.getXOutput1(), dl.getYOutput1(), 388, dl.getYOutput1());
|
|
749
|
-
line(388, dl.getYOutput1(), 388, 257);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
render(): JSX.Element {
|
|
754
|
-
// eslint-disable-next-line react/no-string-refs
|
|
755
|
-
return <div className="graph-container" ref="divGraph" />;
|
|
756
|
-
}
|
|
757
|
-
}
|