Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong bit headers with msb: left #43

Open
JFMarten opened this issue Mar 3, 2025 · 0 comments
Open

Wrong bit headers with msb: left #43

JFMarten opened this issue Mar 3, 2025 · 0 comments

Comments

@JFMarten
Copy link

JFMarten commented Mar 3, 2025

The bit headers seems to be broken in combination with msb: left. I used the following snippet to generate just some test cases

#import "@preview/bytefield:0.0.7": *

#let bf(bpr: 32, msb: left, length: 4, ok: true, header: "bytes") = {
  [*BPR:* #bpr; *MSB:* #msb; *Bytes:* #length; *Header*: #header; #if ok [✔] else {text(fill: red, [✘])};]
  v(-5mm)
  bytefield(bpr: bpr, msb: msb, bitheader(header), bytes(length)[#length; Bytes])
}

= Right
#bf(msb: right)
#bf(msb: right, length: 1, ok: false)
#bf(msb: right, bpr: 8, length: 1)
#bf(msb: right, bpr: 8, length: 2)
= Left
#bf()
#bf(length: 2, ok: false)
#bf(bpr: 8, length: 1)
#bf(bpr: 8, length: 2, ok: false)
#bf(bpr: 8, length: 2, header: "bounds", ok: false)

and got the following results:

Image

For example 2 i was unsure if the numbering is expected as it came out. For msb: left changing the bpr to e.g. 8 breaks multiple cases. It's particularly strange that the MSB is labeled 15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant