Skip to content

Commit

Permalink
SHF fixes (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBBB authored Oct 14, 2024
1 parent 39077d6 commit 9dd5f55
Show file tree
Hide file tree
Showing 58 changed files with 356 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ public void trace(Trace trace, int stamp) {
.ones(arg2HiByteChunks.ones())
.leftAlignedSuffixLow(arg2LoByteChunks.la())
.rightAlignedPrefixLow(arg2LoByteChunks.ra())
.shb3Hi(Bytes.ofUnsignedInt(this.shb.getShbHi()[0][i].toInteger()))
.shb3Lo(Bytes.ofUnsignedInt(this.shb.getShbLo()[0][i].toInteger()))
.shb4Hi(Bytes.ofUnsignedInt(this.shb.getShbHi()[4 - 3][i].toInteger()))
.shb4Lo(Bytes.ofUnsignedInt(this.shb.getShbLo()[4 - 3][i].toInteger()))
.shb5Hi(Bytes.ofUnsignedInt(this.shb.getShbHi()[5 - 3][i].toInteger()))
.shb5Lo(Bytes.ofUnsignedInt(this.shb.getShbLo()[5 - 3][i].toInteger()))
.shb6Hi(Bytes.ofUnsignedInt(this.shb.getShbHi()[6 - 3][i].toInteger()))
.shb6Lo(Bytes.ofUnsignedInt(this.shb.getShbLo()[6 - 3][i].toInteger()))
.shb7Hi(Bytes.ofUnsignedInt(this.shb.getShbHi()[7 - 3][i].toInteger()))
.shb7Lo(Bytes.ofUnsignedInt(this.shb.getShbLo()[7 - 3][i].toInteger()))
.shb3Hi(shb.getShbHi()[0][i])
.shb3Lo(shb.getShbLo()[0][i])
.shb4Hi(shb.getShbHi()[4 - 3][i])
.shb4Lo(shb.getShbLo()[4 - 3][i])
.shb5Hi(shb.getShbHi()[5 - 3][i])
.shb5Lo(shb.getShbLo()[5 - 3][i])
.shb6Hi(shb.getShbHi()[6 - 3][i])
.shb6Lo(shb.getShbLo()[6 - 3][i])
.shb7Hi(shb.getShbHi()[7 - 3][i])
.shb7Lo(shb.getShbLo()[7 - 3][i])
.shiftDirection(this.isShiftRight)
.iomf(true)
.shiftStamp((short) stamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ static List<ColumnHeader> headers(int length) {
new ColumnHeader("shf.RES_LO", 16, length),
new ColumnHeader("shf.RIGHT_ALIGNED_PREFIX_HIGH", 1, length),
new ColumnHeader("shf.RIGHT_ALIGNED_PREFIX_LOW", 1, length),
new ColumnHeader("shf.SHB_3_HI", 16, length),
new ColumnHeader("shf.SHB_3_LO", 16, length),
new ColumnHeader("shf.SHB_4_HI", 16, length),
new ColumnHeader("shf.SHB_4_LO", 16, length),
new ColumnHeader("shf.SHB_5_HI", 16, length),
new ColumnHeader("shf.SHB_5_LO", 16, length),
new ColumnHeader("shf.SHB_6_HI", 16, length),
new ColumnHeader("shf.SHB_6_LO", 16, length),
new ColumnHeader("shf.SHB_7_HI", 16, length),
new ColumnHeader("shf.SHB_7_LO", 16, length),
new ColumnHeader("shf.SHB_3_HI", 1, length),
new ColumnHeader("shf.SHB_3_LO", 1, length),
new ColumnHeader("shf.SHB_4_HI", 1, length),
new ColumnHeader("shf.SHB_4_LO", 1, length),
new ColumnHeader("shf.SHB_5_HI", 1, length),
new ColumnHeader("shf.SHB_5_LO", 1, length),
new ColumnHeader("shf.SHB_6_HI", 1, length),
new ColumnHeader("shf.SHB_6_LO", 1, length),
new ColumnHeader("shf.SHB_7_HI", 1, length),
new ColumnHeader("shf.SHB_7_LO", 1, length),
new ColumnHeader("shf.SHIFT_DIRECTION", 1, length),
new ColumnHeader("shf.SHIFT_STAMP", 4, length));
}
Expand Down Expand Up @@ -833,252 +833,122 @@ public Trace rightAlignedPrefixLow(final UnsignedByte b) {
return this;
}

public Trace shb3Hi(final Bytes b) {
public Trace shb3Hi(final UnsignedByte b) {
if (filled.get(39)) {
throw new IllegalStateException("shf.SHB_3_HI already set");
} else {
filled.set(39);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb3Hi has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb3Hi.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb3Hi.put(bs.get(j));
}
shb3Hi.put(b.toByte());

return this;
}

public Trace shb3Lo(final Bytes b) {
public Trace shb3Lo(final UnsignedByte b) {
if (filled.get(40)) {
throw new IllegalStateException("shf.SHB_3_LO already set");
} else {
filled.set(40);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb3Lo has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb3Lo.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb3Lo.put(bs.get(j));
}
shb3Lo.put(b.toByte());

return this;
}

public Trace shb4Hi(final Bytes b) {
public Trace shb4Hi(final UnsignedByte b) {
if (filled.get(41)) {
throw new IllegalStateException("shf.SHB_4_HI already set");
} else {
filled.set(41);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb4Hi has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb4Hi.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb4Hi.put(bs.get(j));
}
shb4Hi.put(b.toByte());

return this;
}

public Trace shb4Lo(final Bytes b) {
public Trace shb4Lo(final UnsignedByte b) {
if (filled.get(42)) {
throw new IllegalStateException("shf.SHB_4_LO already set");
} else {
filled.set(42);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb4Lo has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb4Lo.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb4Lo.put(bs.get(j));
}
shb4Lo.put(b.toByte());

return this;
}

public Trace shb5Hi(final Bytes b) {
public Trace shb5Hi(final UnsignedByte b) {
if (filled.get(43)) {
throw new IllegalStateException("shf.SHB_5_HI already set");
} else {
filled.set(43);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb5Hi has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb5Hi.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb5Hi.put(bs.get(j));
}
shb5Hi.put(b.toByte());

return this;
}

public Trace shb5Lo(final Bytes b) {
public Trace shb5Lo(final UnsignedByte b) {
if (filled.get(44)) {
throw new IllegalStateException("shf.SHB_5_LO already set");
} else {
filled.set(44);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb5Lo has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb5Lo.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb5Lo.put(bs.get(j));
}
shb5Lo.put(b.toByte());

return this;
}

public Trace shb6Hi(final Bytes b) {
public Trace shb6Hi(final UnsignedByte b) {
if (filled.get(45)) {
throw new IllegalStateException("shf.SHB_6_HI already set");
} else {
filled.set(45);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb6Hi has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb6Hi.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb6Hi.put(bs.get(j));
}
shb6Hi.put(b.toByte());

return this;
}

public Trace shb6Lo(final Bytes b) {
public Trace shb6Lo(final UnsignedByte b) {
if (filled.get(46)) {
throw new IllegalStateException("shf.SHB_6_LO already set");
} else {
filled.set(46);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb6Lo has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb6Lo.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb6Lo.put(bs.get(j));
}
shb6Lo.put(b.toByte());

return this;
}

public Trace shb7Hi(final Bytes b) {
public Trace shb7Hi(final UnsignedByte b) {
if (filled.get(47)) {
throw new IllegalStateException("shf.SHB_7_HI already set");
} else {
filled.set(47);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb7Hi has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb7Hi.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb7Hi.put(bs.get(j));
}
shb7Hi.put(b.toByte());

return this;
}

public Trace shb7Lo(final Bytes b) {
public Trace shb7Lo(final UnsignedByte b) {
if (filled.get(48)) {
throw new IllegalStateException("shf.SHB_7_LO already set");
} else {
filled.set(48);
}

// Trim array to size
Bytes bs = b.trimLeadingZeros();
// Sanity check against expected width
if (bs.bitLength() > 128) {
throw new IllegalArgumentException("shb7Lo has invalid width (" + bs.bitLength() + "bits)");
}
// Write padding (if necessary)
for (int i = bs.size(); i < 16; i++) {
shb7Lo.put((byte) 0);
}
// Write bytes
for (int j = 0; j < bs.size(); j++) {
shb7Lo.put(bs.get(j));
}
shb7Lo.put(b.toByte());

return this;
}
Expand Down Expand Up @@ -1482,43 +1352,43 @@ public Trace fillAndValidateRow() {
}

if (!filled.get(39)) {
shb3Hi.position(shb3Hi.position() + 16);
shb3Hi.position(shb3Hi.position() + 1);
}

if (!filled.get(40)) {
shb3Lo.position(shb3Lo.position() + 16);
shb3Lo.position(shb3Lo.position() + 1);
}

if (!filled.get(41)) {
shb4Hi.position(shb4Hi.position() + 16);
shb4Hi.position(shb4Hi.position() + 1);
}

if (!filled.get(42)) {
shb4Lo.position(shb4Lo.position() + 16);
shb4Lo.position(shb4Lo.position() + 1);
}

if (!filled.get(43)) {
shb5Hi.position(shb5Hi.position() + 16);
shb5Hi.position(shb5Hi.position() + 1);
}

if (!filled.get(44)) {
shb5Lo.position(shb5Lo.position() + 16);
shb5Lo.position(shb5Lo.position() + 1);
}

if (!filled.get(45)) {
shb6Hi.position(shb6Hi.position() + 16);
shb6Hi.position(shb6Hi.position() + 1);
}

if (!filled.get(46)) {
shb6Lo.position(shb6Lo.position() + 16);
shb6Lo.position(shb6Lo.position() + 1);
}

if (!filled.get(47)) {
shb7Hi.position(shb7Hi.position() + 16);
shb7Hi.position(shb7Hi.position() + 1);
}

if (!filled.get(48)) {
shb7Lo.position(shb7Lo.position() + 16);
shb7Lo.position(shb7Lo.position() + 1);
}

if (!filled.get(49)) {
Expand Down
Loading

0 comments on commit 9dd5f55

Please sign in to comment.