-
Notifications
You must be signed in to change notification settings - Fork 6
VerilogWrapper and Standard Library #87
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
base: master
Are you sure you want to change the base?
Conversation
c12df9c to
4301af5
Compare
a23f9de to
80f55b5
Compare
243f89e to
576f339
Compare
6722d7a to
1802d56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces VerilogWrapper functionality for instantiating external Verilog modules, reorganizes the standard library package structure, and adds various API improvements including Queue implementation, type utilities, and width query methods.
Key Changes:
- Adds
VerilogWrappertrait and API for external Verilog module integration with parameter passing support - Refactors package structure:
me.jiuyang.zaozi.testlib→me.jiuyang.testlibandme.jiuyang.zaozi.stdlib→me.jiuyang.stdlib - Implements Queue with DesignWare Building Blocks backend, Decoupled interface, and type conversion utilities
Reviewed changes
Copilot reviewed 63 out of 69 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| zaozi/src/Api.scala | Adds VerilogWrapper trait, VerilogParameter, and VerilogWrapperApi; adds GetWidth trait for querying bit widths |
| zaozi/src/default/VerilogWrapperApi.scala | Implements VerilogWrapper API with extmodule creation and instantiation support |
| zaozi/src/default/BaseGeneratorApi.scala | Extracts common instance creation and MLIR bytecode dumping logic into BaseGeneratorHelper |
| zaozi/src/magic/macros/Generator.scala | Updates @Generator macro to support both Generator and VerilogWrapper traits |
| stdlib/src/dwbb/Queue.scala | Adds DwbbFifo VerilogWrapper for DW_fifo_s1_sf with QueueImpl given instance |
| stdlib/src/Decoupled.scala | Adds DecoupledIO and ValidIO interfaces with HasFire trait |
| stdlib/src/TypeUtils.scala | Adds HardwareDataType alias and TypeUtilsApi for asBits/asTypeOf conversions |
| testlib/src/ZaoziTest.scala | Updates package from me.jiuyang.zaozi.testlib to me.jiuyang.testlib |
| .scalafix.conf | Adds Scalafix configuration for import organization and code style rules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
678e24e to
7cd7a34
Compare
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 51 out of 54 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import java.lang.foreign.Arena | ||
|
|
||
| // TODO: split LHS & RHS into two different trait? this might help for Vec static accessing assignment. | ||
| // TODO: Const cannot be SINK |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO comment on line 15 suggests using "Const" when it should probably say "Const cannot be SINK" or clarify that constants cannot be used as sink (left-hand side) in assignments. The current phrasing "Const cannot be SINK" is unclear - consider expanding this to "TODO: Constants should not be allowed as assignment targets (SINK)".
| // a bit of dirty but quotes does not expose the SingletonTypeTree | ||
| if selfOpt.exists(_.tpt.toString().startsWith("SingletonTypeTree")) => |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment about "a bit of dirty but quotes does not expose the SingletonTypeTree" on line 19 contains a grammatical error. It should be "a bit dirty" (without "of") or "a bit of a hack".
| ): Wire[QueueIO[D]] = | ||
| val fifo = DwbbFifo.instantiate( | ||
| DwbbFifoParameter( | ||
| // XXX: any way not to actually create an op? |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on lines 93-94 uses a non-standard comment format "XXX:" which typically indicates a critical issue or temporary workaround. Consider using "TODO:" or "FIXME:" for consistency with the rest of the codebase, or clarify what "XXX" means in this context.
| // XXX: any way not to actually create an op? | |
| // TODO: Find a way not to actually create an op here, if possible. |
| trait GetWidth[D <: Data, R <: Referable[D]]: | ||
| extension (ref: R) | ||
| def width( | ||
| using Arena, | ||
| Context | ||
| ): Int |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width method is added to several APIs (BitsApi, BoolApi, UIntApi, SIntApi, RecordApi, BundleApi, VecApi) but not documented. Consider adding scaladoc comments explaining what the width method returns, especially since it's a new public API that users will interact with.
| // Ideally, we can get all attribute from MLIR but the Scala type itself | ||
| def getType = _tpe |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getType and getElementType methods are newly exposed public APIs but lack documentation. These methods expose internal implementation details (_tpe, _elementType) and should have clear documentation explaining their purpose, return values, and when users should call them.
| def moduleName(parameter: PARAM): String = | ||
| s"${verilogModuleName(parameter)}_${verilogParameter(parameter).hashCode.toHexString}" |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The moduleName implementation uses hashCode.toHexString to ensure uniqueness based on verilog parameters. However, hashCode can have collisions - two different VerilogParameter instances could potentially have the same hashCode, leading to module name conflicts. Consider using a more robust mechanism like a cryptographic hash or a counter-based approach for generating unique module names.
| private[zaozi] val _elementType: E | ||
| private[zaozi] val _count: Int | ||
|
|
||
| def getElementType = _elementType |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getElementType method is exposed but lacks documentation. Users need to understand what this method returns and when it should be used.
No description provided.