Skip to content

Commit c694ba9

Browse files
fix(gsoc'24): Fix ControlledInverter - similar to tristate (#4887) (#352)
Co-authored-by: Arnabdaz <[email protected]>
1 parent fa03754 commit c694ba9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/simulator/src/modules/ControlledInverter.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ export default class ControlledInverter extends CircuitElement {
6868
(32 - this.bitWidth)
6969
simulationArea.simulationQueue.add(this.output1)
7070
}
71-
if (this.state.value === 0) {
72-
this.output1.value = undefined
71+
else if (
72+
this.output1.value !== undefined &&
73+
!simulationArea.contentionPending.has(this.output1)
74+
) {
75+
this.output1.value = undefined;
76+
simulationArea.simulationQueue.add(this.output1);
7377
}
78+
simulationArea.contentionPending.removeAllContentionsForNode(this.output1);
7479
}
7580

7681
/**

src/simulator/src/node.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export default class Node {
396396
this.parent.isResolvable() &&
397397
!this.parent.queueProperties.inQueue
398398
) {
399-
if (this.parent.objectType == 'TriState') {
399+
if (this.parent.objectType == 'TriState' || this.parent.objectType == 'ControlledInverter') {
400400
if (this.parent.state.value) {
401401
simulationArea.simulationQueue.add(this.parent)
402402
}
@@ -435,11 +435,7 @@ export default class Node {
435435
`Contention Error: ${this.value} and ${node.value} at ${circuitElementName} in ${circuitName}`
436436
)
437437
} else if (node.bitWidth == this.bitWidth || node.type == 2) {
438-
if (
439-
node.parent.objectType == 'TriState' &&
440-
node.value != undefined &&
441-
node.type == 1
442-
) {
438+
if ((node.parent.objectType == 'TriState' || node.parent.objectType == 'ControlledInverter') && node.value != undefined) {
443439
if (node.parent.state.value) {
444440
simulationArea.contentionPending.push(node.parent)
445441
}

0 commit comments

Comments
 (0)