Skip to content

fix(iss): make sure that CSR.address() generates as a bits type#1

Closed
dhower-qc wants to merge 6 commits into
ThinkOpenly:Zcmtfrom
dhower-qc:Zcmt
Closed

fix(iss): make sure that CSR.address() generates as a bits type#1
dhower-qc wants to merge 6 commits into
ThinkOpenly:Zcmtfrom
dhower-qc:Zcmt

Conversation

@dhower-qc

Copy link
Copy Markdown

Should fix issues in riscv#1234

@ThinkOpenly

Copy link
Copy Markdown
Owner

I downloaded the changes here as a patch file and applied that to my Zcmt branch from riscv#1234, but I see the same error.

@dhower-qc

Copy link
Copy Markdown
Author

I downloaded the changes here as a patch file and applied that to my Zcmt branch from riscv-software-src#1234, but I see the same error.

Can you show the error you are seeing?

@ThinkOpenly

Copy link
Copy Markdown
Owner
riscv-unified-db/tools/ruby-gems/idlc/lib/idlc.rb:229:in `compile_inst_scope': While parsing riscv-unified-db/gen/spec/rv32/inst/Zcmt/cm.jalt.yaml:28 (SyntaxError)

Expected one of [ \n], '#', ')' at line 2, column 35 (byte 57) after Bits<12> csr_addr = $bits(CSR[jvt]

        from riscv-unified-db/tools/ruby-gems/idlc/lib/idlc.rb:253:in `compile_inst_operation'
        from riscv-unified-db/tools/ruby-gems/udb/lib/udb/obj/instruction.rb:1070:in `block in operation_ast'
        from riscv-unified-db/tools/ruby-gems/udb/lib/udb/obj/database_obj.rb:136:in `defer'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/sorbet-runtime-0.5.12157/lib/types/private/methods/call_validation.rb:282:in `bind_call'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/sorbet-runtime-0.5.12157/lib/types/private/methods/call_validation.rb:282:in `validate_call'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/sorbet-runtime-0.5.12157/lib/types/private/methods/call_validation.rb:203:in `block in create_validator_slow'
        from riscv-unified-db/tools/ruby-gems/udb/lib/udb/obj/instruction.rb:1066:in `operation_ast'
        from riscv-unified-db/backends/cpp_hart_gen/templates/inst.hxx.erb:91:in `block in get_binding'
        from riscv-unified-db/backends/cpp_hart_gen/templates/inst.hxx.erb:61:in `each'
        from riscv-unified-db/backends/cpp_hart_gen/templates/inst.hxx.erb:61:in `get_binding'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/erb-5.0.1/lib/erb.rb:427:in `eval'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/erb-5.0.1/lib/erb.rb:427:in `result'
        from riscv-unified-db/backends/cpp_hart_gen/tasks.rake:150:in `block in <top (required)>'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `block in execute'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `each'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `execute'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `synchronize'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:188:in `invoke'
        from riscv-unified-db/backends/cpp_hart_gen/tasks.rake:314:in `block (3 levels) in <top (required)>'
        from riscv-unified-db/backends/cpp_hart_gen/tasks.rake:314:in `each'
        from riscv-unified-db/backends/cpp_hart_gen/tasks.rake:314:in `block (2 levels) in <top (required)>'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `block in execute'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `each'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:281:in `execute'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `synchronize'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:243:in `block in invoke_prerequisites'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:241:in `each'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:241:in `invoke_prerequisites'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `synchronize'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/task.rb:188:in `invoke'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:188:in `invoke_task'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:138:in `each'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:138:in `block in top_level'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:147:in `run_with_threads'
        from riscv-unified-db/.home/.gems/ruby/3.2.0/gems/rake-13.3.0/lib/rake/application.rb:132:in `top_level'
        from -e:1:in `<main>'

@dhower-qc

Copy link
Copy Markdown
Author
riscv-unified-db/tools/ruby-gems/idlc/lib/idlc.rb:229:in `compile_inst_scope': While parsing riscv-unified-db/gen/spec/rv32/inst/Zcmt/cm.jalt.yaml:28 (SyntaxError)

Expected one of [ \n], '#', ')' at line 2, column 35 (byte 57) after Bits<12> csr_addr = $bits(CSR[jvt]

I see. I'm looking into that now, but in the meantime, it should work now if you just remove the cast.

@dhower-qc

Copy link
Copy Markdown
Author

a14b6a9 should fix

@ThinkOpenly

Copy link
Copy Markdown
Owner

Confirming that after adding the 2nd patch, this works:

  Bits<12> csr_addr = CSR[jvt].address();
  Csr csr_handle = direct_csr_lookup(csr_addr);

@ThinkOpenly

Copy link
Copy Markdown
Owner

I didn't notice that this PR was targeted at my branch. Do you still want me to pull it there, or do you want to merge this into main (after removing the Zcmt instructions, probably)?

@ThinkOpenly
ThinkOpenly deleted the branch ThinkOpenly:Zcmt February 27, 2026 23:20
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

Successfully merging this pull request may close these issues.

2 participants