Skip to content

Commit fb4bbc1

Browse files
author
Edward Nutting
committed
Add Merge Bits function that correctly computes the merge of two bits when one is possibly undriven.
1 parent 435a1d8 commit fb4bbc1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/com/modsim/util/BinData.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,21 @@ public void set(BinData v) {
233233
mask = v.mask;
234234
}
235235

236+
public static int mergeBits(byte b0, byte b1) {
237+
if (b0 == 2 && b1 == 2) {
238+
return 2;
239+
}
240+
else if (b0 == 2) {
241+
return b1;
242+
}
243+
else if (b1 == 2) {
244+
return b0;
245+
}
246+
else if (b0 == b1) {
247+
return b0;
248+
}
249+
else {
250+
return 2;
251+
}
252+
}
236253
}

0 commit comments

Comments
 (0)