circuitscript 0.0.17 → 0.0.19
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/__tests__/parseScripts.ts +160 -1
- package/__tests__/renderData/script1.cst.svg +1 -1
- package/__tests__/renderData/script5.cst.svg +1 -1
- package/__tests__/renderData/script6.cst +28 -0
- package/__tests__/renderData/script6.cst.svg +1 -0
- package/__tests__/renderData/script7.cst +26 -0
- package/__tests__/renderData/script7.cst.svg +1 -0
- package/__tests__/renderData/script8.cst +37 -0
- package/__tests__/renderData/script8.cst.svg +1 -0
- package/__tests__/testParse.ts +6 -2
- package/__tests__/testRender.ts +4 -1
- package/build/src/antlr/CircuitScriptLexer.js +152 -143
- package/build/src/antlr/CircuitScriptParser.js +731 -619
- package/build/src/antlr/CircuitScriptVisitor.js +2 -2
- package/build/src/draw_symbols.js +5 -2
- package/build/src/execute.js +140 -73
- package/build/src/export.js +2 -2
- package/build/src/globals.js +8 -0
- package/build/src/layout.js +27 -13
- package/build/src/objects/ExecutionScope.js +1 -1
- package/build/src/visitor.js +51 -25
- package/package.json +1 -1
- package/src/antlr/CircuitScript.g4 +9 -7
- package/src/antlr/CircuitScriptLexer.ts +152 -143
- package/src/antlr/CircuitScriptParser.ts +728 -616
- package/src/antlr/CircuitScriptVisitor.ts +6 -6
- package/src/draw_symbols.ts +7 -2
- package/src/execute.ts +185 -91
- package/src/export.ts +2 -2
- package/src/globals.ts +8 -0
- package/src/layout.ts +54 -29
- package/src/objects/ExecutionScope.ts +11 -3
- package/src/visitor.ts +64 -37
|
@@ -2,8 +2,8 @@ import { ParseTreeVisitor } from 'antlr4';
|
|
|
2
2
|
export default class CircuitScriptVisitor extends ParseTreeVisitor {
|
|
3
3
|
visitScript;
|
|
4
4
|
visitExpression;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
visitPath_blocks;
|
|
6
|
+
visitPath_block_inner;
|
|
7
7
|
visitProperty_set_expr2;
|
|
8
8
|
visitAssignment_expr2;
|
|
9
9
|
visitData_expr_with_assignment;
|
|
@@ -53,10 +53,13 @@ export class SymbolGraphic {
|
|
|
53
53
|
}
|
|
54
54
|
pinPosition(id) {
|
|
55
55
|
const pin = this.drawing.getPinPosition(id);
|
|
56
|
+
const [x, y] = pin.start;
|
|
57
|
+
const useX = Math.round(x * 10000) / 10000;
|
|
58
|
+
const useY = Math.round(y * 10000 / 10000);
|
|
56
59
|
if (pin) {
|
|
57
60
|
return {
|
|
58
|
-
x:
|
|
59
|
-
y:
|
|
61
|
+
x: useX,
|
|
62
|
+
y: useY,
|
|
60
63
|
angle: pin.angle,
|
|
61
64
|
};
|
|
62
65
|
}
|
package/build/src/execute.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentTypes, GlobalNames, ParamKeys, ReferenceTypes } from './globals.js';
|
|
1
|
+
import { BlockTypes, ComponentTypes, GlobalNames, NoNetText, ParamKeys, ReferenceTypes } from './globals.js';
|
|
2
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
3
|
import { ActiveObject, ExecutionScope, FrameAction, SequenceAction } from './objects/ExecutionScope.js';
|
|
4
4
|
import { Net } from './objects/Net.js';
|
|
@@ -11,6 +11,7 @@ export class ExecutionContext {
|
|
|
11
11
|
netNamespace;
|
|
12
12
|
executionLevel;
|
|
13
13
|
scope;
|
|
14
|
+
tmpPointId = 0;
|
|
14
15
|
resolveNet = null;
|
|
15
16
|
stopFurtherExpressions = false;
|
|
16
17
|
returnValue = null;
|
|
@@ -180,11 +181,17 @@ export class ExecutionContext {
|
|
|
180
181
|
this.print('add symbol', instanceName, '[' + pinsOutput.join(', ') + ']');
|
|
181
182
|
return component;
|
|
182
183
|
}
|
|
183
|
-
printPoint() {
|
|
184
|
-
|
|
184
|
+
printPoint(extra = '') {
|
|
185
|
+
let netName = NoNetText;
|
|
186
|
+
if (this.scope.hasNet(this.scope.currentComponent, this.scope.currentPin)) {
|
|
187
|
+
netName = this.scope
|
|
188
|
+
.getNet(this.scope.currentComponent, this.scope.currentPin)
|
|
189
|
+
.toString();
|
|
190
|
+
}
|
|
191
|
+
this.print((extra !== '' ? (extra + ' ') : '') + 'point: ' +
|
|
185
192
|
this.scope.currentComponent.instanceName +
|
|
186
193
|
' ' +
|
|
187
|
-
this.scope.currentPin);
|
|
194
|
+
this.scope.currentPin + ' ' + netName);
|
|
188
195
|
}
|
|
189
196
|
addComponentExisting(component, pin) {
|
|
190
197
|
const startPin = pin;
|
|
@@ -298,85 +305,135 @@ export class ExecutionContext {
|
|
|
298
305
|
this.print('created clone of net component:', cloneInstanceName);
|
|
299
306
|
return clonedComponent;
|
|
300
307
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
enterBlocks(blockType) {
|
|
309
|
+
if (blockType === BlockTypes.Point) {
|
|
310
|
+
this.addPoint(`_point.${this.name}.${this.tmpPointId}`, false);
|
|
311
|
+
this.tmpPointId += 1;
|
|
312
|
+
}
|
|
313
|
+
else if (blockType === BlockTypes.Parallel) {
|
|
314
|
+
this.addPoint(`_parallel.${this.name}.${this.tmpPointId}`, false);
|
|
315
|
+
this.tmpPointId += 1;
|
|
316
|
+
}
|
|
317
|
+
this.scope.blockStack.set(this.scope.indentLevel, {
|
|
318
|
+
entered_at: [
|
|
319
|
+
this.scope.currentComponent,
|
|
320
|
+
this.scope.currentPin,
|
|
321
|
+
this.scope.currentWireId
|
|
322
|
+
],
|
|
323
|
+
inner_blocks: new Map(),
|
|
305
324
|
current_index: null,
|
|
325
|
+
type: blockType,
|
|
306
326
|
});
|
|
307
|
-
this.print('enter
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return 0;
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
const [comp1, pin1] = sortedNets[0][1];
|
|
339
|
-
const tmpList = sortedNets.slice(1);
|
|
340
|
-
tmpList.forEach((item) => {
|
|
341
|
-
const [, [comp2, pin2]] = item;
|
|
342
|
-
this.atComponent(comp1, pin1, { addSequence: true });
|
|
343
|
-
this.toComponent(comp2, pin2, { addSequence: true });
|
|
344
|
-
});
|
|
345
|
-
this.scope.currentComponent = comp1;
|
|
346
|
-
this.scope.currentPin = pin1;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
enterBranch(branchIndex) {
|
|
350
|
-
this.print('enter inner branch >>>');
|
|
351
|
-
const stackRef = this.scope.branchStack.get(this.scope.indentLevel);
|
|
352
|
-
stackRef['branch_index'] = branchIndex;
|
|
353
|
-
stackRef['inner_branches'].set(branchIndex, {
|
|
327
|
+
this.print('enter blocks');
|
|
328
|
+
}
|
|
329
|
+
exitBlocks() {
|
|
330
|
+
const stackRef = this.scope.blockStack.get(this.scope.indentLevel);
|
|
331
|
+
const { type: blockType } = stackRef;
|
|
332
|
+
if (blockType === BlockTypes.Join || blockType === BlockTypes.Parallel) {
|
|
333
|
+
const { final_point: finalPoint } = stackRef;
|
|
334
|
+
const [component, pin, wireId] = finalPoint;
|
|
335
|
+
this.scope.currentComponent = component;
|
|
336
|
+
this.scope.currentPin = pin;
|
|
337
|
+
this.scope.currentWireId = wireId;
|
|
338
|
+
if (wireId !== -1) {
|
|
339
|
+
this.scope.sequence.push([
|
|
340
|
+
SequenceAction.WireJump, wireId, 1
|
|
341
|
+
]);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else if (blockType === BlockTypes.Point) {
|
|
345
|
+
const { entered_at: [component, pin,] } = stackRef;
|
|
346
|
+
this.atComponent(component, pin, { addSequence: true });
|
|
347
|
+
}
|
|
348
|
+
this.print('exit blocks');
|
|
349
|
+
}
|
|
350
|
+
enterBlock(blockIndex) {
|
|
351
|
+
const stackRef = this.scope.blockStack.get(this.scope.indentLevel);
|
|
352
|
+
stackRef['block_index'] = blockIndex;
|
|
353
|
+
const { type: blockType } = stackRef;
|
|
354
|
+
stackRef['inner_blocks'].set(blockIndex, {
|
|
354
355
|
last_net: null,
|
|
355
356
|
ignore_last_net: false,
|
|
356
357
|
});
|
|
358
|
+
if (blockType === BlockTypes.Join || blockType === BlockTypes.Point) {
|
|
359
|
+
this.scope.currentComponent = null;
|
|
360
|
+
this.scope.currentPin = null;
|
|
361
|
+
this.scope.currentWireId = -1;
|
|
362
|
+
}
|
|
363
|
+
else if (blockType === BlockTypes.Parallel) {
|
|
364
|
+
const { entered_at: [component, pin,] } = stackRef;
|
|
365
|
+
this.atComponent(component, pin, { addSequence: true });
|
|
366
|
+
}
|
|
367
|
+
this.print(`enter inner block of type (${blockType}) >>>`);
|
|
357
368
|
this.scope.indentLevel += 1;
|
|
358
369
|
}
|
|
359
|
-
|
|
360
|
-
const stackRef = this.scope.
|
|
361
|
-
const
|
|
362
|
-
|
|
370
|
+
exitBlock(blockIndex) {
|
|
371
|
+
const stackRef = this.scope.blockStack.get(this.scope.indentLevel - 1);
|
|
372
|
+
const { type: blockType } = stackRef;
|
|
373
|
+
const blockIndexRef = stackRef['inner_blocks'].get(blockIndex);
|
|
374
|
+
blockIndexRef['last_net'] = [
|
|
363
375
|
this.scope.currentComponent,
|
|
364
376
|
this.scope.currentPin,
|
|
377
|
+
this.scope.currentWireId
|
|
365
378
|
];
|
|
366
|
-
stackRef['
|
|
367
|
-
const [preBranchComponent, preBranchPin, preBranchWireId] = stackRef['entered_at'];
|
|
379
|
+
stackRef['block_index'] = null;
|
|
368
380
|
this.scope.indentLevel -= 1;
|
|
369
|
-
this.print('exit inner
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
this.
|
|
381
|
+
this.print('exit inner block <<<');
|
|
382
|
+
if (blockType === BlockTypes.Branch) {
|
|
383
|
+
const { entered_at: [component, pin, wireId] } = stackRef;
|
|
384
|
+
this.atComponent(component, pin, { addSequence: true });
|
|
385
|
+
if (wireId !== -1) {
|
|
386
|
+
this.scope.sequence.push([SequenceAction.WireJump, wireId, 1]);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
else if (blockType === BlockTypes.Join || blockType === BlockTypes.Parallel) {
|
|
390
|
+
if (blockIndex === 0) {
|
|
391
|
+
const pointIdName = (blockType === BlockTypes.Join) ? '_join' : '_parallel';
|
|
392
|
+
this.addPoint(`${pointIdName}.${this.name}.${this.tmpPointId}`, false);
|
|
393
|
+
this.tmpPointId += 1;
|
|
394
|
+
stackRef['final_point'] = [
|
|
395
|
+
this.scope.currentComponent,
|
|
396
|
+
this.scope.currentPin,
|
|
397
|
+
this.scope.currentWireId
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
const { final_point: finalPoint } = stackRef;
|
|
402
|
+
const [component, pin,] = finalPoint;
|
|
403
|
+
this.toComponent(component, pin, { addSequence: true });
|
|
404
|
+
}
|
|
373
405
|
}
|
|
374
406
|
}
|
|
407
|
+
atPointBlock() {
|
|
408
|
+
const [component, pin,] = this.getPointBlockLocation();
|
|
409
|
+
this.atComponent(component, pin, {
|
|
410
|
+
addSequence: true
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
toPointBlock() {
|
|
414
|
+
const [component, pin,] = this.getPointBlockLocation();
|
|
415
|
+
this.toComponent(component, pin, {
|
|
416
|
+
addSequence: true
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
getPointBlockLocation() {
|
|
420
|
+
this.print('get block point');
|
|
421
|
+
for (let i = 0; i < this.scope.indentLevel; i++) {
|
|
422
|
+
const stackRef = this.scope.blockStack.get(this.scope.indentLevel - 1 - i);
|
|
423
|
+
const { entered_at } = stackRef;
|
|
424
|
+
const component = entered_at[0];
|
|
425
|
+
if (component.instanceName.startsWith('_point.')) {
|
|
426
|
+
return entered_at;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
this.print('did not find block point');
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
375
432
|
breakBranch() {
|
|
376
433
|
this.print('break branch');
|
|
377
|
-
const branchesInfo = this.scope.
|
|
378
|
-
const branchIndex = branchesInfo['
|
|
379
|
-
const branchIndexRef = branchesInfo['
|
|
434
|
+
const branchesInfo = this.scope.blockStack.get(this.scope.indentLevel - 1);
|
|
435
|
+
const branchIndex = branchesInfo['block_index'];
|
|
436
|
+
const branchIndexRef = branchesInfo['inner_blocks'].get(branchIndex);
|
|
380
437
|
branchIndexRef['ignore_last_net'] = true;
|
|
381
438
|
}
|
|
382
439
|
createFunction(functionName, __runFunc) {
|
|
@@ -508,7 +565,7 @@ export class ExecutionContext {
|
|
|
508
565
|
}
|
|
509
566
|
else if (action === SequenceAction.WireJump) {
|
|
510
567
|
const jumpWireId = wireIdOffset + sequenceAction[1];
|
|
511
|
-
this.scope.sequence.push([SequenceAction.WireJump, jumpWireId]);
|
|
568
|
+
this.scope.sequence.push([SequenceAction.WireJump, jumpWireId, 1]);
|
|
512
569
|
}
|
|
513
570
|
else if (action === SequenceAction.At || action === SequenceAction.To) {
|
|
514
571
|
const tmpComponent = sequenceAction[1];
|
|
@@ -536,8 +593,17 @@ export class ExecutionContext {
|
|
|
536
593
|
this.scope.sequence.push(sequenceAction);
|
|
537
594
|
}
|
|
538
595
|
});
|
|
539
|
-
|
|
540
|
-
|
|
596
|
+
if (childScope.currentComponent === childScope.componentRoot) {
|
|
597
|
+
this.scope.currentComponent = currentComponent;
|
|
598
|
+
this.scope.currentPin = currentPin;
|
|
599
|
+
this.scope.currentWireId = currentWireId;
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
this.scope.currentComponent = childScope.currentComponent;
|
|
603
|
+
this.scope.currentPin = childScope.currentPin;
|
|
604
|
+
this.scope.currentWireId = childScope.currentWireId + wireIdOffset;
|
|
605
|
+
}
|
|
606
|
+
this.printPoint('resume at');
|
|
541
607
|
this.print('-- nets --');
|
|
542
608
|
const currentNets = this.scope.getNets();
|
|
543
609
|
currentNets.reduce((accum, [, , net]) => {
|
|
@@ -568,11 +634,12 @@ export class ExecutionContext {
|
|
|
568
634
|
this.scope.sequence.push([SequenceAction.Wire, wireId, tmp]);
|
|
569
635
|
this.scope.currentComponent.pinWires.set(this.scope.currentPin, tmp);
|
|
570
636
|
}
|
|
571
|
-
addPoint(pointId) {
|
|
637
|
+
addPoint(pointId, userDefined = true) {
|
|
572
638
|
if (this.scope.instances.has(pointId)) {
|
|
573
639
|
this.print('Warning: ' + pointId + ' is being redefined');
|
|
574
640
|
}
|
|
575
|
-
const
|
|
641
|
+
const useName = userDefined ? 'point.' + pointId : pointId;
|
|
642
|
+
const componentPoint = ClassComponent.simple(useName, 1, "point");
|
|
576
643
|
componentPoint.displayProp = "point";
|
|
577
644
|
componentPoint.typeProp = ComponentTypes.point;
|
|
578
645
|
this.scope.instances.set(pointId, componentPoint);
|
package/build/src/export.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentTypes } from "./globals.js";
|
|
1
|
+
import { ComponentTypes, NoNetText } from "./globals.js";
|
|
2
2
|
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
3
3
|
export function generateKiCADNetList(netlist) {
|
|
4
4
|
const componentsList = [];
|
|
@@ -28,7 +28,7 @@ export function generateKiCADNetList(netlist) {
|
|
|
28
28
|
for (const key in pins) {
|
|
29
29
|
const netInfo = pins[key];
|
|
30
30
|
const netName = netInfo.netName;
|
|
31
|
-
if (netName ===
|
|
31
|
+
if (netName === NoNetText) {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
34
|
if (nets[netName] === undefined) {
|
package/build/src/globals.js
CHANGED
|
@@ -7,6 +7,7 @@ export var GlobalNames;
|
|
|
7
7
|
GlobalNames["DefaultInductor"] = "ind";
|
|
8
8
|
GlobalNames["symbol"] = "symbol";
|
|
9
9
|
})(GlobalNames || (GlobalNames = {}));
|
|
10
|
+
export const NoNetText = 'NO_NET';
|
|
10
11
|
export var ParamKeys;
|
|
11
12
|
(function (ParamKeys) {
|
|
12
13
|
ParamKeys["__is_net"] = "__is_net";
|
|
@@ -47,3 +48,10 @@ export var ReferenceTypes;
|
|
|
47
48
|
ReferenceTypes["variable"] = "variable";
|
|
48
49
|
ReferenceTypes["instance"] = "instance";
|
|
49
50
|
})(ReferenceTypes || (ReferenceTypes = {}));
|
|
51
|
+
export var BlockTypes;
|
|
52
|
+
(function (BlockTypes) {
|
|
53
|
+
BlockTypes[BlockTypes["Branch"] = 1] = "Branch";
|
|
54
|
+
BlockTypes[BlockTypes["Join"] = 2] = "Join";
|
|
55
|
+
BlockTypes[BlockTypes["Parallel"] = 3] = "Parallel";
|
|
56
|
+
BlockTypes[BlockTypes["Point"] = 4] = "Point";
|
|
57
|
+
})(BlockTypes || (BlockTypes = {}));
|
package/build/src/layout.js
CHANGED
|
@@ -79,6 +79,17 @@ export class LayoutEngine {
|
|
|
79
79
|
}
|
|
80
80
|
wireGroups.get(netName).push(wire);
|
|
81
81
|
});
|
|
82
|
+
const { junctions, mergedWires } = this.findJunctions(wireGroups);
|
|
83
|
+
return {
|
|
84
|
+
components: placedComponents,
|
|
85
|
+
wires: placedWires,
|
|
86
|
+
mergedWires,
|
|
87
|
+
junctions,
|
|
88
|
+
frameObjects,
|
|
89
|
+
textObjects,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
findJunctions(wireGroups) {
|
|
82
93
|
const junctions = [];
|
|
83
94
|
const mergedWires = [];
|
|
84
95
|
for (const [key, wires] of wireGroups) {
|
|
@@ -101,12 +112,8 @@ export class LayoutEngine {
|
|
|
101
112
|
});
|
|
102
113
|
}
|
|
103
114
|
return {
|
|
104
|
-
components: placedComponents,
|
|
105
|
-
wires: placedWires,
|
|
106
|
-
mergedWires,
|
|
107
115
|
junctions,
|
|
108
|
-
|
|
109
|
-
textObjects,
|
|
116
|
+
mergedWires
|
|
110
117
|
};
|
|
111
118
|
}
|
|
112
119
|
placeFrames(graph, subgraphInfo, frameObjects) {
|
|
@@ -402,7 +409,7 @@ export class LayoutEngine {
|
|
|
402
409
|
currentFrame && currentFrame.innerItems.push(tmpComponent);
|
|
403
410
|
}
|
|
404
411
|
if (action === SequenceAction.To) {
|
|
405
|
-
|
|
412
|
+
this.setGraphEdge(graph, previousNode, tmpInstanceName, makeEdgeValue(previousNode, previousPin, tmpInstanceName, pin, i));
|
|
406
413
|
}
|
|
407
414
|
previousNode = tmpInstanceName;
|
|
408
415
|
previousPin = pin;
|
|
@@ -427,7 +434,7 @@ export class LayoutEngine {
|
|
|
427
434
|
wire.netName = useNetName;
|
|
428
435
|
const wireName = getWireName(wire.id);
|
|
429
436
|
graph.setNode(wireName, [RenderItemType.Wire, wire, i]);
|
|
430
|
-
|
|
437
|
+
this.setGraphEdge(graph, previousNode, wireName, makeEdgeValue(previousNode, previousPin, wireName, 0, i));
|
|
431
438
|
previousNode = wireName;
|
|
432
439
|
previousPin = 1;
|
|
433
440
|
const wireSegmentsInfo = wireSegments.map(item => {
|
|
@@ -447,9 +454,14 @@ export class LayoutEngine {
|
|
|
447
454
|
}
|
|
448
455
|
else if (action === SequenceAction.WireJump) {
|
|
449
456
|
this.print(...sequence[i]);
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
457
|
+
const wireId = sequence[i][1];
|
|
458
|
+
const wireName = getWireName(wireId);
|
|
459
|
+
let wirePin = 1;
|
|
460
|
+
if (sequence[i].length === 3) {
|
|
461
|
+
wirePin = sequence[i][2];
|
|
462
|
+
}
|
|
463
|
+
previousNode = wireName;
|
|
464
|
+
previousPin = wirePin;
|
|
453
465
|
}
|
|
454
466
|
else if (action === SequenceAction.Frame) {
|
|
455
467
|
const [, frameObject, frameAction] = sequence[i];
|
|
@@ -482,6 +494,9 @@ export class LayoutEngine {
|
|
|
482
494
|
containerFrames,
|
|
483
495
|
};
|
|
484
496
|
}
|
|
497
|
+
setGraphEdge(graph, node1, node2, edgeValue) {
|
|
498
|
+
graph.setEdge(node1, node2, edgeValue);
|
|
499
|
+
}
|
|
485
500
|
sizeSubGraphs(graph) {
|
|
486
501
|
const subGraphs = graphlib.alg.components(graph);
|
|
487
502
|
const subGraphsStarts = [];
|
|
@@ -613,9 +628,8 @@ export class LayoutEngine {
|
|
|
613
628
|
if (x1 !== x2 && y1 !== y2) {
|
|
614
629
|
if (node1 instanceof RenderWire &&
|
|
615
630
|
node2 instanceof RenderComponent) {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
' may not be placed correctly');
|
|
631
|
+
const refdes = node2.component.assignedRefDes;
|
|
632
|
+
this.layoutWarnings.push(`component ${refdes} may not be placed correctly`);
|
|
619
633
|
}
|
|
620
634
|
}
|
|
621
635
|
}
|
package/build/src/visitor.js
CHANGED
|
@@ -8,7 +8,7 @@ import { PinDefinition, PinIdType } from './objects/PinDefinition.js';
|
|
|
8
8
|
import { PinTypes } from './objects/PinTypes.js';
|
|
9
9
|
import { UndeclaredReference } from './objects/types.js';
|
|
10
10
|
import { Logger } from './logger.js';
|
|
11
|
-
import { ComponentTypes } from './globals.js';
|
|
11
|
+
import { BlockTypes, ComponentTypes, NoNetText } from './globals.js';
|
|
12
12
|
import { SymbolDrawingCommands } from './draw_symbols.js';
|
|
13
13
|
import { parseFileWithVisitor } from './parser.js';
|
|
14
14
|
export class MainVisitor extends ParseTreeVisitor {
|
|
@@ -186,26 +186,36 @@ export class MainVisitor extends ParseTreeVisitor {
|
|
|
186
186
|
return this.getExecutor().addComponentExisting(component, pinValue);
|
|
187
187
|
}
|
|
188
188
|
visitAt_component_expr(ctx) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
addSequence: true,
|
|
192
|
-
cloneNetComponent: true
|
|
193
|
-
});
|
|
194
|
-
if (ctx.ID()) {
|
|
195
|
-
this.setComponentOrientation(currentPoint[0], currentPoint[1], ctx.ID().getText());
|
|
189
|
+
if (ctx.Point()) {
|
|
190
|
+
this.getExecutor().atPointBlock();
|
|
196
191
|
}
|
|
197
|
-
|
|
192
|
+
else {
|
|
193
|
+
const [component, pin] = this.visit(ctx.component_select_expr());
|
|
194
|
+
const currentPoint = this.getExecutor().atComponent(component, pin, {
|
|
195
|
+
addSequence: true,
|
|
196
|
+
cloneNetComponent: true
|
|
197
|
+
});
|
|
198
|
+
if (ctx.ID()) {
|
|
199
|
+
this.setComponentOrientation(currentPoint[0], currentPoint[1], ctx.ID().getText());
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return this.getExecutor().getCurrentPoint();
|
|
198
203
|
}
|
|
199
204
|
visitTo_component_expr(ctx) {
|
|
200
205
|
let currentPoint;
|
|
201
|
-
ctx.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
206
|
+
if (ctx.Point()) {
|
|
207
|
+
this.getExecutor().toPointBlock();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
ctx.component_select_expr_list().forEach((item) => {
|
|
211
|
+
const [component, pin] = this.visit(item);
|
|
212
|
+
currentPoint = this.getExecutor().toComponent(component, pin, {
|
|
213
|
+
addSequence: true, cloneNetComponent: true
|
|
214
|
+
});
|
|
205
215
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
if (ctx.ID()) {
|
|
217
|
+
this.setComponentOrientation(currentPoint[0], currentPoint[1], ctx.ID().getText());
|
|
218
|
+
}
|
|
209
219
|
}
|
|
210
220
|
return this.getExecutor().getCurrentPoint();
|
|
211
221
|
}
|
|
@@ -222,15 +232,31 @@ export class MainVisitor extends ParseTreeVisitor {
|
|
|
222
232
|
return [component, pinId];
|
|
223
233
|
}
|
|
224
234
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
235
|
+
visitPath_blocks(ctx) {
|
|
236
|
+
const blocks = ctx.path_block_inner_list();
|
|
237
|
+
let blockType = BlockTypes.Branch;
|
|
238
|
+
if (blocks.length > 0) {
|
|
239
|
+
const firstBlock = blocks[0];
|
|
240
|
+
if (firstBlock.Branch()) {
|
|
241
|
+
blockType = BlockTypes.Branch;
|
|
242
|
+
}
|
|
243
|
+
else if (firstBlock.Join()) {
|
|
244
|
+
blockType = BlockTypes.Join;
|
|
245
|
+
}
|
|
246
|
+
else if (firstBlock.Parallel()) {
|
|
247
|
+
blockType = BlockTypes.Parallel;
|
|
248
|
+
}
|
|
249
|
+
else if (firstBlock.Point()) {
|
|
250
|
+
blockType = BlockTypes.Point;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
this.getExecutor().enterBlocks(blockType);
|
|
254
|
+
blocks.forEach((branch, index) => {
|
|
255
|
+
this.getExecutor().enterBlock(index);
|
|
230
256
|
this.visit(branch);
|
|
231
|
-
this.getExecutor().
|
|
257
|
+
this.getExecutor().exitBlock(index);
|
|
232
258
|
});
|
|
233
|
-
this.getExecutor().
|
|
259
|
+
this.getExecutor().exitBlocks();
|
|
234
260
|
return this.getExecutor().getCurrentPoint();
|
|
235
261
|
}
|
|
236
262
|
visitBreak_keyword() {
|
|
@@ -945,8 +971,8 @@ export class MainVisitor extends ParseTreeVisitor {
|
|
|
945
971
|
resolveNets(scope, instance) {
|
|
946
972
|
const result = [];
|
|
947
973
|
for (const [pinId, pin] of instance.pins) {
|
|
948
|
-
let netName =
|
|
949
|
-
let netBaseName =
|
|
974
|
+
let netName = NoNetText;
|
|
975
|
+
let netBaseName = NoNetText;
|
|
950
976
|
if (scope.hasNet(instance, pinId)) {
|
|
951
977
|
const netObject = scope.getNet(instance, pinId);
|
|
952
978
|
netName = netObject.namespace + netObject.name;
|
package/package.json
CHANGED
|
@@ -17,6 +17,8 @@ Add: 'add';
|
|
|
17
17
|
At: 'at';
|
|
18
18
|
To: 'to';
|
|
19
19
|
Point: 'point';
|
|
20
|
+
Join: 'join';
|
|
21
|
+
Parallel: 'parallel';
|
|
20
22
|
|
|
21
23
|
Return: 'return';
|
|
22
24
|
Define: 'def';
|
|
@@ -46,18 +48,18 @@ expression: add_component_expr
|
|
|
46
48
|
| break_keyword
|
|
47
49
|
| function_def_expr
|
|
48
50
|
| wire_expr
|
|
49
|
-
| point_expr
|
|
50
51
|
| import_expr
|
|
51
52
|
| frame_expr
|
|
52
53
|
| atom_expr
|
|
53
54
|
|
|
54
55
|
| at_block
|
|
55
|
-
|
|
|
56
|
+
| path_blocks
|
|
57
|
+
| point_expr
|
|
56
58
|
;
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Branch ':' NEWLINE INDENT (NEWLINE | expression)+ DEDENT;
|
|
60
|
+
path_blocks: path_block_inner+;
|
|
61
|
+
path_block_inner:
|
|
62
|
+
(Branch | Join | Parallel | Point) ':' NEWLINE INDENT (NEWLINE | expression)+ DEDENT;
|
|
61
63
|
|
|
62
64
|
property_set_expr2:
|
|
63
65
|
atom_expr ':' NEWLINE INDENT ( NEWLINE | assignment_expr2)+ DEDENT;
|
|
@@ -72,10 +74,10 @@ pin_select_expr: Pin (INTEGER_VALUE | STRING_VALUE);
|
|
|
72
74
|
// This does not have the 'pin' word
|
|
73
75
|
pin_select_expr2: INTEGER_VALUE | STRING_VALUE;
|
|
74
76
|
|
|
75
|
-
at_component_expr: At component_select_expr ID
|
|
77
|
+
at_component_expr: At ((component_select_expr ID?) | Point); // ID? is for orientation
|
|
76
78
|
// at_component_expr_next: 'at' component_select_expr (',' component_select_expr)*;
|
|
77
79
|
|
|
78
|
-
to_component_expr: To component_select_expr (',' component_select_expr)* ID
|
|
80
|
+
to_component_expr: To ((component_select_expr (',' component_select_expr)* ID?) | Point); // ID? is for orientation
|
|
79
81
|
// pin_select_expr_next: 'pin' INTEGER_VALUE (',' INTEGER_VALUE)?;
|
|
80
82
|
|
|
81
83
|
at_to_multiple_expr: At component_select_expr To component_select_expr (',' component_select_expr)* ':' NEWLINE INDENT (NEWLINE | at_to_multiple_line_expr) + DEDENT;
|