Skip to content

Conversation

@unlsycn
Copy link
Collaborator

@unlsycn unlsycn commented Oct 10, 2025

No description provided.

@unlsycn unlsycn marked this pull request as draft October 10, 2025 09:59
@unlsycn unlsycn force-pushed the stdlib branch 3 times, most recently from c12df9c to 4301af5 Compare October 12, 2025 06:08
@unlsycn unlsycn force-pushed the stdlib branch 2 times, most recently from a23f9de to 80f55b5 Compare January 4, 2026 13:58
@unlsycn unlsycn changed the title [WIP] Standard Library [WIP] VerilogWrapper and Standard Library Jan 4, 2026
@unlsycn unlsycn force-pushed the stdlib branch 3 times, most recently from 243f89e to 576f339 Compare January 5, 2026 03:33
@unlsycn unlsycn changed the title [WIP] VerilogWrapper and Standard Library Bump to CIRCT 1.138.0 Jan 5, 2026
@unlsycn unlsycn marked this pull request as ready for review January 5, 2026 03:37
@unlsycn unlsycn force-pushed the stdlib branch 2 times, most recently from 6722d7a to 1802d56 Compare January 5, 2026 03:52
@unlsycn unlsycn changed the title Bump to CIRCT 1.138.0 VerilogWrapper and Standard Library Jan 5, 2026
@unlsycn unlsycn requested a review from Copilot January 5, 2026 04:03
Copy link

Copilot AI left a 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 VerilogWrapper trait and API for external Verilog module integration with parameter passing support
  • Refactors package structure: me.jiuyang.zaozi.testlibme.jiuyang.testlib and me.jiuyang.zaozi.stdlibme.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.

@unlsycn unlsycn force-pushed the stdlib branch 3 times, most recently from 678e24e to 7cd7a34 Compare January 6, 2026 03:24
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>
Copy link

Copilot AI left a 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
Copy link

Copilot AI Jan 6, 2026

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)".

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 20
// a bit of dirty but quotes does not expose the SingletonTypeTree
if selfOpt.exists(_.tpt.toString().startsWith("SingletonTypeTree")) =>
Copy link

Copilot AI Jan 6, 2026

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".

Copilot uses AI. Check for mistakes.
): Wire[QueueIO[D]] =
val fifo = DwbbFifo.instantiate(
DwbbFifoParameter(
// XXX: any way not to actually create an op?
Copy link

Copilot AI Jan 6, 2026

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.

Suggested change
// XXX: any way not to actually create an op?
// TODO: Find a way not to actually create an op here, if possible.

Copilot uses AI. Check for mistakes.
Comment on lines +843 to +848
trait GetWidth[D <: Data, R <: Referable[D]]:
extension (ref: R)
def width(
using Arena,
Context
): Int
Copy link

Copilot AI Jan 6, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
// Ideally, we can get all attribute from MLIR but the Scala type itself
def getType = _tpe
Copy link

Copilot AI Jan 6, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +139
def moduleName(parameter: PARAM): String =
s"${verilogModuleName(parameter)}_${verilogParameter(parameter).hashCode.toHexString}"
Copy link

Copilot AI Jan 6, 2026

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.

Copilot uses AI. Check for mistakes.
private[zaozi] val _elementType: E
private[zaozi] val _count: Int

def getElementType = _elementType
Copy link

Copilot AI Jan 6, 2026

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.

Copilot uses AI. Check for mistakes.
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