Skip to content

Commit

Permalink
Fix ControlledInverter - similar to tristate
Browse files Browse the repository at this point in the history
  • Loading branch information
gr455 committed Apr 11, 2024
1 parent 5501064 commit 0d0395a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion simulator/spec/testData/misc-testdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@
"label": "CI-out1",
"bitWidth": 1,
"values": [
"0",
"X",
"1",
"0"
]
Expand Down
10 changes: 7 additions & 3 deletions simulator/src/modules/ControlledInverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ export default class ControlledInverter extends CircuitElement {
((~this.inp1.value >>> 0) << (32 - this.bitWidth)) >>>
(32 - this.bitWidth);
simulationArea.simulationQueue.add(this.output1);
}
if (this.state.value === 0) {
} else if (
this.output1.value !== undefined &&
!simulationArea.contentionPending.has(this.output1)
) {
this.output1.value = undefined;
simulationArea.simulationQueue.add(this.output1);
}
simulationArea.contentionPending.removeAllContentionsForNode(this.output1);
}

/**
* @memberof ControlledInverter
* function to draw element
Expand Down
4 changes: 2 additions & 2 deletions simulator/src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ 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 {
simulationArea.simulationQueue.add(this.parent);
Expand Down Expand Up @@ -397,7 +397,7 @@ export default class Node {
if (node.value != undefined && node.parent.objectType != 'SubCircuit'
&& !(node.subcircuitOverride && node.scope != this.scope)) {
// Tristate has always been a pain in the ass.
if (node.parent.objectType == 'TriState' && node.value != undefined) {
if ((node.parent.objectType == 'TriState' || node.parent.objectType == 'ControlledInverter') && node.value != undefined) {
if (node.parent.state.value) {
simulationArea.contentionPending.add(node, this);
break;
Expand Down

0 comments on commit 0d0395a

Please sign in to comment.