Follow SystemRDL 2.0 for literals, field geometry and addressing - #28
Merged
Conversation
The workflow installs clang-format-22 and then calls clang-format, which is a real file from the distribution package rather than an alternatives link, so every run has been checking with the older formatter the project does not target. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Diff register addresses, widths and field positions and reset values against systemrdl-compiler - Gate on numeric disagreement so files that both sides accept can still fail - Record two pre-existing defects in a self-cleaning known-mismatch baseline - Register the comparison as the value_comparison test Signed-off-by: Huang Rui <vowstar@gmail.com>
- Represent register and field values as bit patterns of a known width - Remove the 64-bit boundary so narrow and wide fields share one code path - Convert to uint64_t only through an explicit success flag, never by truncation - Cover construction, resize, digit accumulation and formatting with unit tests Signed-off-by: Huang Rui <vowstar@gmail.com>
- Accept the INT, HEX_INT and VLOG_INT forms defined by the grammar - Treat underscores as separators so 0x1_0000_0000 keeps all its digits - Reject a sized literal whose value exceeds its width instead of truncating - Report malformed input through an error flag rather than a partial value Signed-off-by: Huang Rui <vowstar@gmail.com>
- Route every numeric literal through the SystemRDL literal parser - Fix sized literals evaluating to their width prefix, so 8'hFF is 255 not 8 - Fix separators truncating values, so 0x1_0000_0000 is no longer 1 - Reject a literal wider than the 64-bit value model instead of using its low bits - Cover sized literals, separators and sized addresses with new test files Signed-off-by: Huang Rui <vowstar@gmail.com>
- Store field reset values as bit vectors so 128-bit and wider values stay exact - Apply the reset written as a property assignment, which never reached the register image and left it zero - Distinguish a field with no reset from one that resets to zero - Drop the 64-bit guard that skipped range checking on wide fields - Emit reset as a hex string and raise the elaborated JSON formats to 2.0 BREAKING CHANGE: In SystemRDL_SimplifiedModel and SystemRDL_ElaboratedModel, field "reset" is now a lowercase hex string such as "0xff" instead of a JSON number, and both formats report version 2.0. A field with no reset in the source omits the key entirely. SystemRDL_AST is unaffected and stays at 1.0. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Replace the single parameter map with a scope stack, innermost first - Fix an inner instance erasing the parameters of the component containing it - Restore array dimensions and instance offsets that depend on outer parameters, so a regfile no longer falls back to four elements Signed-off-by: Huang Rui <vowstar@gmail.com>
- Keep field groups in the order the source declares them - Replace the alphabetically ordered map that handed out bits by field name, which placed a later four-bit field below an earlier one-bit field Signed-off-by: Huang Rui <vowstar@gmail.com>
…ndard - Reject a register width that is not 2^N with N >= 3, per clauses 10.1-f and 10.6.1-a - Model accesswidth and reject values that are not 2^N or exceed the register width - Reject a register that instantiates no field, per clause 10.1-c - Name the violated clause in every message so the rule can be looked up - Split the non-power-of-two case into its own failing test, where it is actually reached BREAKING CHANGE: A register width that is not a power of two was previously accepted. Two such registers placed back to back share a bus word, so an access to one reaches into the other, which the standard has no way to describe. Write the next legal width instead and let the unused bits become reserved fields; the generated logic is the same. No register description in the smurf or qsoc trees relies on the old behaviour: all 365 register rows across the four RCSV files use a width of 32. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Reproduce six examples from SystemRDL 2.0 with the values the standard states - Compare against those values directly, consulting no other implementation - Record the five examples not yet satisfied, and fail when one starts passing - Leave these files to the spec checker rather than the reference comparison Signed-off-by: Huang Rui <vowstar@gmail.com>
- Read a subscript on a field as its bit width, per clause 5.1.2 item 3)iii
- Pack fields from bit 0 in declaration order, per clause 10.7
- Let an explicitly positioned field push the packing pointer past itself
- Drop the grouping and sorting that existed only to expand field arrays
BREAKING CHANGE: "field {} f[8]" previously produced eight one-bit fields named
f[0] to f[7]. It now produces one 8-bit field named f, which is what the
standard defines and what the worked example in 10.7.2 shows. Descriptions that
mix explicit and automatic field positions also change: packing starts at bit 0
rather than above the highest explicitly positioned field.
Signed-off-by: Huang Rui <vowstar@gmail.com>
- Implement the compact, regalign and fullalign addressing modes of 5.1.2.2.2 - Default to regalign instead of packing everything tightly - Apply the alignment property and the %= operator, both previously ignored - Let an array take its element size as the stride when += is absent - Record the power of two reading of regalign as a documented interpretation BREAKING CHANGE: Instances without an explicit @ address move. A 64-bit register after a 32-bit one now lands on an 8-byte boundary rather than immediately after it, and a register file is aligned to its own size. Addresses written with @ are unaffected, so descriptions that place everything explicitly, including those generated from RCSV, produce the same map as before. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Derive memory size from mementries and memwidth, per clause 11.3.1 - Reject a memory with no memwidth rather than assuming 4096 bytes - Reject an array dimension that cannot be evaluated rather than assuming four - Reject a register file with no register, per clause 12.2-c BREAKING CHANGE: A memory declaring memwidth but no mementries was sized at 4096 bytes and is now one entry wide, which is what the standard defines and what the reference implementation produces. Descriptions relying on the old size must state mementries explicitly. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Accept the [low:high] range form, which selects msb0 per clause 10.7 b) - Pack unsized fields down from regwidth-1 in an msb0 register - Reject a register mixing both range forms, per clause 10.7.1-a - Normalise stored bit positions so the rest of the elaborator sees one convention - Cover the msb0 half of the worked example in 10.7.2 Signed-off-by: Huang Rui <vowstar@gmail.com>
- Define SystemRDL::systemrdl in the config file, since an alias is not exported - Install only the two headers the string based API needs - Stop shipping the elaborator internals and the generated parser as public - Add a check that installs the package and builds a throwaway project on it The library built and passed its own tests while being unusable by anyone else, because nothing in the test run ever left the build tree. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Describe what the standard's worked examples check, and which rules are enforced - Separate what is not implemented from what is simply out of scope - Correct the simplified model version, which has been 2.0 since reset became a string Signed-off-by: Huang Rui <vowstar@gmail.com>
- Emit only the format name, which is what tells the three documents apart - Stop requiring a version in the output validators BREAKING CHANGE: The elaborated and AST documents no longer carry a "version" key. Nothing ever read it to make a decision, and keeping it invited a compatibility policy that this toolkit has no audience for. The format name still identifies the schema. Signed-off-by: Huang Rui <vowstar@gmail.com>
…ools - Move the two public headers to include/systemrdl, the whole installed interface - Move library sources to src and the ANTLR4 output to src/generated - Move the command line entry points to tools and the grammar to grammar - Expose only include/systemrdl to consumers, keeping private headers off their path - Point regeneration, cppcheck, packaging and the docs at the new locations The source root mixed 13 generated files with 14 hand written ones, so nothing said which were safe to edit, and the build interface put all ten root headers on the include path of every consumer when only one is public. That could not be expressed while public and private headers shared a directory. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Rewrite ARCHITECTURE.md as the pipeline, the order things happen in, and the rules the code keeps, instead of a listing that ls already gives correctly - Replace the test file inventory with the naming convention that discovers them - Drop wording that praised the project rather than telling the reader anything - Correct paths, a header column that repeated one header seven times, and an example that wrote its output into the source tree The listings had drifted: one named a file that does not exist, another claimed sixteen test files when there are forty-four, and five named test files had been renamed away. A rule does not drift the way an inventory does. Signed-off-by: Huang Rui <vowstar@gmail.com>
- Group conventional commits by kind, breaking changes first - Attach the notes to the release instead of a bare changelog link - Check the repository out in the publish job, which the generator needs Signed-off-by: Huang Rui <vowstar@gmail.com>
vowstar
force-pushed
the
fix/numeric-literal-parsing
branch
from
July 28, 2026 12:29
1f8cb3e to
bdb7d2c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Elaboration produced wrong numbers without saying so: every sized literal evaluated to its width prefix, separators truncated values, reset values above 64 bits were clipped, and instances were packed tightly instead of aligned. The corpus never used a sized literal and the differential test compared exit status rather than values, so none of it showed.
Numbers now go through one parser and field values are fixed width bit vectors. Fields and instances follow clauses 10.7 and 5.1.2.2.2, and rules the standard states with "shall" are enforced with the clause named in the message. The seven worked examples from the standard are test files now, checked against the standard rather than against another implementation.
Public headers moved to
include/systemrdlso only the one public header reaches a consumer. The installed package was unusable from outside the build tree.Breaking
resetis a hex string, and absent when the source gives noneversionfield in any JSON format2^NwithN >= 3field {} f[8]is one 8-bit field, not eight@move, since alignment now appliesNothing in smurf or qsoc depends on the old behaviour: all 365 register rows use width 32 and explicit addresses.