Update Chisel from 6.5.0 to 7.0.0#11
Conversation
218579f to
28b609f
Compare
|
cc @jackkoenig, I brought this up a few weeks ago (regarding the transition from Chisel 6 to 7), but wanted to make sure it was still on your radar. |
28b609f to
ccaf0b4
Compare
14bc211 to
b309d81
Compare
|
Current status, I'm getting two errors due to These are the errors I'm seeing: Any clues on this @jackkoenig? Also @seldridge could you please check that I migrated to ChiselSim in a sane way? That's contained in 6fb4668 |
|
It looks like Chisel just isn't properly validating SInt literals: //> using repository "sonatype-s01:snapshots"
//> using scala "2.13.16"
//> using dep "org.chipsalliance::chisel:7.0.0-M2+533-a7effb7d-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin:7.0.0-M2+533-a7effb7d-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
import _root_.circt.stage.ChiselStage
class Foo extends Module {
val out = IO(Output(SInt(8.W)))
out := 0xde.S(8.W)
}
object Main extends App {
println(
ChiselStage.emitCHIRRTL(new Foo)
)
println(
ChiselStage.emitSystemVerilog(
gen = new Foo,
firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info", "-default-layer-specialization=enable")
)
)
}Chisel is happy to emit that CHIRRTL but firtool rejects it: This used to "work" because Chisel emitted it as an 8-bit unit cast to SInt (which is 9-bits) which then would be implicitly truncated: |
|
Very interesting, looks like this regression happened somewhat recently, since that same code sample works fine on |
|
Okay, it works on |
|
Yes it was chipsalliance/chisel#4748 that exposed this issue, but it's not a regression--it's exposing a bug that has been in Chisel for at least a while, possibly forever. The observation is that the width should never affect the semantic meaning of a value (as long as the width is large enough to hold it). In Chisel 6.7.0 and I suspect all Chisel prior to the linked PR/commit, this was not true for SInt literals: //> using repository "sonatype-s01:snapshots"
//> using scala "2.13.16"
//> using dep "org.chipsalliance::chisel:6.7.0"
//> using plugin "org.chipsalliance:::chisel-plugin:6.7.0"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
import _root_.circt.stage.ChiselStage
class Foo extends Module {
val out1 = IO(Output(Bool()))
val out2 = IO(Output(Bool()))
val reference = 0xde.S(64.W) // Big enough to easily hold the value
// Could use assertions but this makes it more obvious in the Verilog
out1 := reference === 0xde.S
out2 := reference === 0xde.S(8.W)
}
object Main extends App {
println(
ChiselStage.emitSystemVerilog(
gen = new Foo,
firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info") //, "-default-layer-specialization=enable")
)
)
}Generates // Generated by CIRCT firtool-1.62.1-1-gdf5ed6ea5
module Foo(
input clock,
reset,
output out1,
out2
);
assign out1 = 1'h1;
assign out2 = 1'h0;
endmodule
It seems likely that FixedPoint is doing this on purpose--using the binary representation of negative SInts--but the API its taking advantage of is fundamentally unsound and needs to be fixed. One can replicate this behavior by going through UInts and then casting to SInt. (EDIT: This used to mention truncating but that actually returns a UInt lol). 0xde.U.asSIntOr by manipulating the 2s complement value's manually as BigInts. |
b309d81 to
6ff5009
Compare
|
Nice, after using a snapshot which includes chipsalliance/chisel#4786, we get this error, which is much nicer to work with: |
|
CI is passing 👀 |
Yup, finally! In the last commit, I updated those failing tests to not use out-of-range literals. I feel like we should keep this PR in draft state until it depends on actually-released Chisel 7, rather than a snapshot. Thanks so much for all the help on this @jackkoenig! |
Totally, I meant it as a vote of confidence toward releasing 7.0.0-RC1--still need a few things but getting very close. |
908293f to
22dcfd3
Compare
seldridge
left a comment
There was a problem hiding this comment.
Really nice migration. I'm glad this also got the line count down by nuking ChiselRunners. I'm a huge fan of getting onto unified testing infrastructure. If there's things you're missing/needing, those can be added to ChiselSim as appropriate.
42d427a to
e90d9c9
Compare
e90d9c9 to
a9f9856
Compare
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 Wrapping unary negation (`unary_-%`) was deprecated in this PR: chipsalliance/chisel#4829 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
The `chisel3.testers` package was removed here: chipsalliance/chisel#4746 It doesn't look like ChiselSim has the same `Boolean` result from `simulate`, so we must check for simulation errors by catching exceptions.
For background: actions/setup-java#712 Also updated JDK to 21 (latest LTS), updated some GitHub actions to their latest versions, and using install-circt GitHub action to get firtool.
An 8-bit signed integer with a binary point at 2 effectively has a 6-bit signed number for the value to the left of the decimal point. That means it can represent values in the range [-2^5, 2^5-1], or [-32, 31]. After chipsalliance/chisel#4786 was merged, the `55` and `56` literals are now correctly flagged as being out-of-range for this type. I've subtracted 32 from these out-of-range values (changing the MSB from 1 to 0), and the tests now pass.
a9f9856 to
e0769d4
Compare
This update includes this Chisel PR, which deprecated everything in the `firrtl` package: chipsalliance/chisel#4878 Bump `firtool` version to latest as well.
Also update CI versions of firtool and verilator to latest.
|
This has been languishing for awhile now, just bumped to latest Chisel version and marked this as ready to merge. |
UnknownWidthbecame acase objectin this Chisel PR: chipsalliance/chisel#4242The
connectFromBitsmethod was removed in this Chisel PR: chipsalliance/chisel#4168The
connectFromBitsAPI was replaced with the_fromUIntAPI in this Chisel PR: chipsalliance/chisel#4782Wrapping unary negation (
unary_-%) was deprecated in this PR: chipsalliance/chisel#4829Updating to the latest Chisel/Scala compiler version set off a cascade of updates (scalafmt, scalatest, etc). Hopefully that's alright to include in this PR.