Error When Connecting Analog-Only Bundle to Verilog Blackbox

オープン
#4,775 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
scala
領域
compilers

調査の方向性

まず example2.scala と firtool 1.75.0 で失敗を再現し、生成された FIRRTL と中間 IR を example1.scala と比較します。アナログ専用 bundle の接続を attach のセマンティクスを保持せずに firrtl.strictconnect に変換している FIRRTL lowering のステップを追跡します。完了条件は、アナログ専用のケースが lowering され、アナログ接続エラーなしで Verilog を出力することです。

索引モデルが issue の本文から書いたものです。

説明

@seldridge bringing from chisel:matrix.org

Type of issue: Bug Report

Please provide the steps to reproduce the problem:

  1. Define a Verilog blackbox with inout signals.
  2. Connect these inout signals to Chisel Analog IO.
  3. Use a bundle in IO that consists only of Analog signals.
  4. Run the build process, converting .fir to .sv.
  5. Observe the error during FIRRTL lowering.

Error messages
error: analog types may not be connected
note: see current operation: "firrtl.strictconnect"(%172, %arg90) : (!firrtl.bundle<signal_0: analog<1>, signal_1: analog<1>>, !firrtl.bundle<signal_0: analog<1>, signal_1: analog<1>>) -> ()

What is the current behavior?

  • If the IO bundle contains only Analog signals, the build fails.
  • The .fir output appears correct, showing attach statements.
  • However, in intermediate IRs, strictconnect is used instead of attach, leading to an error.
  • This issue occurs regardless of whether attach or bulk connections are used.

What is the expected behavior?

  • The Analog-only bundle should be correctly handled, similar to when Analog is mixed with regular Chisel IO.
  • The FIRRTL lowering process should preserve attach semantics without causing an error.

Please tell us about your environment:
I will provide example code.

  • example1.scala: Works fine because the bundle contains a mix of Analog and regular Chisel IO signals.
//> using scala "2.13.12"
//> using dep "org.chipsalliance::chisel::6.5.0"
//> using options  "-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit", "-Xmaxerrs", "1500", "-Ymacro-annotations",

import chisel3._
import chisel3.experimental.{Analog, attach}
import chisel3.stage.ChiselStage


class PhyMixedInterface extends Bundle {
  val analog_signal_0 = Analog(1.W)
  val analog_signal_1 = Analog(1.W)
  val digital_signal = Output(UInt(1.W))
}

class PhyInterfaceIO extends Bundle { 
  val mixed = new PhyMixedInterface
}

// BlackBox implementation
class PhyImpl extends BlackBox with HasBlackBoxPath {
  override val desiredName = "phy_impl"
  val io = IO(new Bundle {
    val phy = new PhyInterfaceIO
  })
  addPath("phy_impl.v")
}

// Wrapper module that contains the BlackBox
class PhyWrapper extends Module {
  val io = IO(new PhyInterfaceIO)
  
  val impl = Module(new PhyImpl)
  
  io.mixed <> impl.io.phy.mixed
}

object Main extends App {
    (new chisel3.stage.ChiselStage).emitVerilog(new PhyWrapper)
}
  • example2.scala: Fails because the bundle (PhyAnalogInterface) consists only of Analog signals.
//> using scala "2.13.12"
//> using dep "org.chipsalliance::chisel::6.5.0"
//> using options  "-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit", "-Xmaxerrs", "1500", "-Ymacro-annotations",

import chisel3._
import chisel3.experimental.{Analog, attach}
import chisel3.stage.ChiselStage

// Interface definition
class PhyAnalogInterface extends Bundle {
  val signal_0 = Analog(1.W)
  val signal_1 = Analog(1.W)
}

class PhyDigitalInterface extends Bundle {
  val signal = Output(UInt(1.W))
}

class PhyInterfaceIO extends Bundle {
  val digital = new PhyDigitalInterface
  val analog = new PhyAnalogInterface
}

// BlackBox implementation
class PhyImpl extends BlackBox with HasBlackBoxPath {
  override val desiredName = "phy_impl"
  val io = IO(new Bundle {
    val phy = new PhyInterfaceIO
  })
  addPath("phy_impl.v")
}

// Wrapper module that contains the BlackBox
class PhyWrapper extends Module {
  val io = IO(new PhyInterfaceIO)
  
  val impl = Module(new PhyImpl)
  
  io.digital.signal := impl.io.phy.digital.signal
  
  // Connect analog signals using attach
  attach(io.analog.signal_0, impl.io.phy.analog.signal_0)
  attach(io.analog.signal_1, impl.io.phy.analog.signal_1)
}

object Main extends App {
    (new chisel3.stage.ChiselStage).emitVerilog(new PhyWrapper)
}
  • example3.scala: bulk connection is used instead of attach, but the result is same (also fails)
//> using scala "2.13.12"
//> using dep "org.chipsalliance::chisel::6.5.0"
//> using options  "-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit", "-Xmaxerrs", "1500", "-Ymacro-annotations",

import chisel3._
import chisel3.experimental.{Analog, attach}
import chisel3.stage.ChiselStage

// Interface definition
class PhyAnalogInterface extends Bundle {
  val signal_0 = Analog(1.W)
  val signal_1 = Analog(1.W)
}

class PhyDigitalInterface extends Bundle {
  val signal = Output(UInt(1.W))
}

class PhyInterfaceIO extends Bundle {
  val digital = new PhyDigitalInterface
  val analog = new PhyAnalogInterface
}

// BlackBox implementation
class PhyImpl extends BlackBox with HasBlackBoxPath {
  override val desiredName = "phy_impl"
  val io = IO(new Bundle {
    val phy = new PhyInterfaceIO
  })
  addPath("phy_impl.v")
}

// Wrapper module that contains the BlackBox
class PhyWrapper extends Module {
  val io = IO(new PhyInterfaceIO)
  
  val impl = Module(new PhyImpl)
  
  io.digital.signal := impl.io.phy.digital.signal
  
  // Connect analog signals using bulk connection
  io.analog <> impl.io.phy.analog
}

object Main extends App {
    (new chisel3.stage.ChiselStage).emitVerilog(new PhyWrapper)
}
  • phy_impl.v: blackbox verilog code
// blackbox
module phy_impl (
    output wire digital_signal,
    
    // Analog interface
    inout wire signal_0,
    inout wire signal_1
);
    // Empty module implementation
    assign digital_signal = 1'b0;
    
endmodule

Other Information

Please note that I am not using scala-cli, so my build might not exactly match the standard setup.
And I used firtool 1.75.0.
If there are any additional details I should provide about my environment to help reproduce the issue, please let me know. Thanks!

What is the use case for changing the behavior?

主要言語
Scala
スター
4.8k
フォーク
669
平均マージ
1日 12時間
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

chipsalliance/chisel のほかの issue

chipsalliance/chisel の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。