Naming Plugin and Object Pattern
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
Research direction
Start with the Foo and Bar reproducer in the issue and compare their emitted SystemVerilog, focusing on how the naming plugin derives the register name for RegNext(io.a). Trace the object-pattern prefix("io") handling and verify that Bar's register receives the same io_ prefix as Foo, producing io_b_REG.
Written by the indexing model from the issue text.
Description
I've been using a pattern of wrapping hardware in an object to provide namespacing. This has been useful because it enables a direct conversion of an anonymous bundle pattern like val io = IO(new Bundle { }) to something which is more amenable to adding domain information. However, this pattern doesn't work correctly with the naming plugin.
Consider:
//> using repository https://central.sonatype.com/repository/maven-snapshots
//> using scala 2.13.18
//> using dep org.chipsalliance::chisel:7.13.0+23-b2a0e030-SNAPSHOT
//> using plugin org.chipsalliance:::chisel-plugin:7.13.0+23-b2a0e030-SNAPSHOT
//> using options -unchecked -deprecation -language:reflectiveCalls -feature -Xcheckinit
//> using options -Xfatal-warnings -Ywarn-dead-code -Ywarn-unused -Ymacro-annotations
import chisel3._
import chisel3.experimental.prefix
import circt.stage.ChiselStage
class Foo extends Module {
val io = IO {
new Bundle {
val a = Input(Bool())
val b = Output(Bool())
}
}
io.b := RegNext(io.a)
}
class Bar extends Module {
object io {
val a = IO(Input(Bool()))
val b = IO(Output(Bool()))
}
prefix("io")(io)
io.b := RegNext(io.a)
}
object Main extends App {
println(
ChiselStage.emitSystemVerilog(
gen = new Foo,
firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info", "-default-layer-specialization=enable")
)
)
println(
ChiselStage.emitSystemVerilog(
gen = new Bar,
firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info", "-default-layer-specialization=enable")
)
)
}
The above produces the following Verilog:
// Generated by CIRCT firtool-1.151.0
module Foo(
input clock,
reset,
io_a,
output io_b
);
reg io_b_REG;
always @(posedge clock)
io_b_REG <= io_a;
assign io_b = io_b_REG;
endmodule
// Generated by CIRCT firtool-1.151.0
module Bar(
input clock,
reset,
io_a,
output io_b
);
reg b_REG;
always @(posedge clock)
b_REG <= io_a;
assign io_b = b_REG;
endmodule
It seems like these should produce the same thing. Given that b has a prefix of io_. However, this doesn't get used when determining the name of the register with the object pattern.
- Dominant language
- Scala
- Stars
- 4.8k
- Forks
- 662
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from chipsalliance/chisel
-
LFSR.tapsMaxPeriod: 17 second tap sets (widths 725 to 755) are a single number larger than the widthOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
chipsalliance/chisel#5512 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
chipsalliance/chisel#5504 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
chipsalliance/chisel#5507 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
chipsalliance/chisel#5499 · 1 reaction ·
Maintainers usually reply within 1 day
-
MultiClockSpec chiselTest fails with recent Verilator versionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
chipsalliance/chisel#5418 · 3 comments ·
Maintainers usually reply within 1 day
All issues in chipsalliance/chisel
Similar issues
-
area:verification status:backlog
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
KD5UJC-XYZ/scarab#459 ·
Maintainers usually reply within 1 day
-
A-api C-bug S-ready-for-human
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ergoplatform/ergo#2838 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
scalacenter/scaladex#1834 ·
-
PlatformSpecific.hasGreenThreads incorrectly returns false for JDK updates and non-GA versionsPossibly taken @hearnadam claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
zio/zio#11303 · 1 reaction · 2 assignees ·
Maintainers usually reply within 1 day