bus splitter is able to transfer high-z states

This commit is contained in:
hneemann 2020-11-18 08:06:32 +01:00
parent 4e8fc4d72e
commit 6acf49138d

View File

@ -37,6 +37,7 @@ public class BusSplitter extends Node implements Element {
private ObservableValue commonIn; private ObservableValue commonIn;
private boolean oe; private boolean oe;
private long commonD; private long commonD;
private long commonZ;
private ObservableValues outputValues; private ObservableValues outputValues;
/** /**
@ -77,12 +78,16 @@ public class BusSplitter extends Node implements Element {
oe = oeValue.getBool(); oe = oeValue.getBool();
if (oe) { if (oe) {
commonD = commonIn.getValue(); commonD = commonIn.getValue();
commonZ = commonIn.getHighZ();
} else { } else {
commonD = 0; commonD = 0;
commonZ = 0;
long mask = 1; long mask = 1;
for (int i = 0; i < bits; i++) { for (int i = 0; i < bits; i++) {
if (in[i].getBool()) if (in[i].getBool())
commonD |= mask; commonD |= mask;
if (in[i].isHighZ())
commonZ |= mask;
mask <<= 1; mask <<= 1;
} }
} }
@ -94,13 +99,16 @@ public class BusSplitter extends Node implements Element {
commonOut.setToHighZ(); commonOut.setToHighZ();
long mask = 1; long mask = 1;
for (int i = 0; i < bits; i++) { for (int i = 0; i < bits; i++) {
out[i].setBool((commonD & mask) != 0); if ((commonZ & mask) != 0)
out[i].setToHighZ();
else
out[i].setBool((commonD & mask) != 0);
mask <<= 1; mask <<= 1;
} }
} else { } else {
for (int i = 0; i < bits; i++) for (int i = 0; i < bits; i++)
out[i].setToHighZ(); out[i].setToHighZ();
commonOut.setValue(commonD); commonOut.set(commonD, commonZ);
} }
} }