Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion simulator/spec/misc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Simulator Misc-Elements Testing', () => {

test('Controlled Inverter working', () => {
const result = runAll(testData.ControlledInverter);
expect(result.summary.passed).toBe(3);
expect(result.summary.passed).toBe(2);
});

test('Equal Splitter working', () => {
Expand Down
8 changes: 7 additions & 1 deletion simulator/src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,15 @@ export function play(scope = globalScope, resetNodes = false) {
forceResetNodesSet(true);
}
}
// Check for TriState Contentions

// Check for TriState and ControlledInverter Contentions
if (simulationArea.contentionPending.length) {
if(simulationArea.contentionPending[0].objectType === 'TriState'){
showError('Contention at TriState');
}
if(simulationArea.contentionPending[0].objectType === 'ControlledInverter'){
showError('Contention at ControlledInverter');
}
forceResetNodesSet(true);
errorDetectedSet(true);
}
Expand Down
11 changes: 8 additions & 3 deletions simulator/src/modules/ControlledInverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ export default class ControlledInverter extends CircuitElement {
(32 - this.bitWidth);
simulationArea.simulationQueue.add(this.output1);
}
if (this.state.value === 0) {
this.output1.value = undefined;
}
else {
if (this.output1.value !== undefined && this.output1.oldValue !== undefined && !simulationArea.contentionPending.contains(this)) {
this.output1.value = undefined;
simulationArea.simulationQueue.add(this.output1);
}
}
this.output1.oldValue = this.output1.value;
simulationArea.contentionPending.clean(this);
}

/**
Expand Down
13 changes: 6 additions & 7 deletions simulator/src/modules/TriState.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ export default class TriState extends CircuitElement {
this.output1.value = this.inp1.value; // >>>0)<<(32-this.bitWidth))>>>(32-this.bitWidth);
simulationArea.simulationQueue.add(this.output1);
}
simulationArea.contentionPending.clean(this);
} else if (
this.output1.value !== undefined &&
!simulationArea.contentionPending.contains(this)
) {
this.output1.value = undefined;
simulationArea.simulationQueue.add(this.output1);
} else {
if (this.output1.value !== undefined && this.output1.oldValue !== undefined && !simulationArea. contentionPending.contains(this)) {
this.output1.value = undefined;
simulationArea.simulationQueue.add(this.output1);
}
}
this.output1.oldValue = this.output1.value;
simulationArea.contentionPending.clean(this);
}

Expand Down
9 changes: 8 additions & 1 deletion simulator/src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,12 @@ export default class Node {

if (this.type == NODE_OUTPUT && !this.subcircuitOverride) {
if (this.parent.isResolvable() && !this.parent.queueProperties.inQueue) {
if (this.parent.objectType == 'TriState') {
if (this.parent.objectType == 'TriState' || this.parent.objectType == 'ControlledInverter') {
if (this.parent.state.value) { simulationArea.simulationQueue.add(this.parent); }
else if (this.parent.state.value === 0) {
this.parent.output1.value = undefined;
simulationArea.simulationQueue.add(this.parent);
}
} else {
simulationArea.simulationQueue.add(this.parent);
}
Expand Down Expand Up @@ -392,6 +396,9 @@ export default class Node {
if (node.parent.objectType == 'TriState' && node.value != undefined && node.type == 1) {
if (node.parent.state.value) { simulationArea.contentionPending.push(node.parent); }
}
if (node.parent.objectType == 'ControlledInverter' && node.value != undefined && node.type == 1) {
if (node.parent.state.value) { simulationArea.contentionPending.push(node.parent); }
}

node.bitWidth = this.bitWidth;
node.value = this.value;
Expand Down