Skip to content

Commit 4da4f25

Browse files
committed
Merge branch '3.5.x' into 3.5-release
2 parents 93d1716 + 9d1e208 commit 4da4f25

File tree

37 files changed

+1589
-178
lines changed

37 files changed

+1589
-178
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Text from here to the end of the body will be considered for inclusion in the re
4444

4545
### Reviewer Checklist (only modified by reviewer)
4646
- [ ] Did you add the appropriate labels?
47-
- [ ] Did you mark the proper milestone (Bug fix: `3.3.x`, [small] API extension: `3.4.x`, API modification or big change: `3.5.0`)?
47+
- [ ] Did you mark the proper milestone (Bug fix: `3.4.x`, [small] API extension: `3.5.x`, API modification or big change: `3.6.0`)?
4848
- [ ] Did you review?
4949
- [ ] Did you check whether all relevant Contributor checkboxes have been checked?
5050
- [ ] Did you mark as `Please Merge`?

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- 3.5.x
89
- 3.4.x
910
- 3.3.x
1011
- 3.2.x

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ For example, in SBT this could be expressed as:
121121
```scala
122122
// build.sbt
123123
scalaVersion := "2.13.7"
124-
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.5.0-RC2" cross CrossVersion.full)
125-
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.5.0-RC2"
124+
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.5.0" cross CrossVersion.full)
125+
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.5.0"
126126
// We also recommend using chiseltest for writing unit tests
127-
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.5.0-RC2" % "test"
127+
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.5.0" % "test"
128128
```
129129
### Guide For New Contributors
130130
If you are trying to make a contribution to this project, please read [CONTRIBUTING.md](https://github.com/Burnleydev1/chisel3/blob/recent_PR/CONTRIBUTING.md)
@@ -144,7 +144,7 @@ These simulation-based verification tools are available for Chisel:
144144
- [**ScalaDoc**](https://www.chisel-lang.org/api/latest/chisel3/index.html), a listing, description, and examples of the functionality exposed by Chisel
145145
- [**Gitter**](https://gitter.im/freechipsproject/chisel3), where you can ask questions or discuss anything Chisel
146146
- [**Website**](https://www.chisel-lang.org) ([source](https://github.com/freechipsproject/www.chisel-lang.org/))
147-
- [**Scastie (3.5.0-RC2)**](https://scastie.scala-lang.org/R6wV80vUTr2CwhvouEdidg)
147+
- [**Scastie (3.5.0)**](https://scastie.scala-lang.org/9ga9i2DvQymKlA5JjS1ieA)
148148
- [**asic-world**](http://www.asic-world.com/verilog/veritut.html) If you aren't familiar with verilog, this is a good tutorial.
149149

150150
If you are migrating from Chisel2, see [the migration guide](https://www.chisel-lang.org/chisel3/chisel3-vs-chisel2.html).

build.sbt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// See LICENSE for license details.
22

3+
import com.typesafe.tools.mima.core._
4+
35
enablePlugins(SiteScaladocPlugin)
46

57
val defaultVersions = Map(
@@ -114,7 +116,8 @@ lazy val pluginScalaVersions = Seq(
114116
"2.13.4",
115117
"2.13.5",
116118
"2.13.6",
117-
"2.13.7"
119+
"2.13.7",
120+
"2.13.8"
118121
)
119122

120123
lazy val plugin = (project in file("plugin")).
@@ -134,7 +137,7 @@ lazy val plugin = (project in file("plugin")).
134137
).
135138
settings(
136139
mimaPreviousArtifacts := {
137-
Set()
140+
Set("edu.berkeley.cs" % "chisel3-plugin" % "3.5.0" cross CrossVersion.full)
138141
}
139142
)
140143

@@ -153,7 +156,7 @@ lazy val macros = (project in file("macros")).
153156
settings(name := "chisel3-macros").
154157
settings(commonSettings: _*).
155158
settings(publishSettings: _*).
156-
settings(mimaPreviousArtifacts := Set())
159+
settings(mimaPreviousArtifacts := Set("edu.berkeley.cs" %% "chisel3-macros" % "3.5.0"))
157160

158161
lazy val firrtlRef = ProjectRef(workspaceDirectory / "firrtl", "firrtl")
159162

@@ -167,7 +170,7 @@ lazy val core = (project in file("core")).
167170
buildInfoKeys := Seq[BuildInfoKey](buildInfoPackage, version, scalaVersion, sbtVersion)
168171
).
169172
settings(publishSettings: _*).
170-
settings(mimaPreviousArtifacts := Set()).
173+
settings(mimaPreviousArtifacts := Set("edu.berkeley.cs" %% "chisel3-core" % "3.5.0")).
171174
settings(
172175
name := "chisel3-core",
173176
scalacOptions := scalacOptions.value ++ Seq(
@@ -196,8 +199,13 @@ lazy val chisel = (project in file(".")).
196199
dependsOn(core).
197200
aggregate(macros, core, plugin).
198201
settings(
199-
mimaPreviousArtifacts := Set(),
202+
mimaPreviousArtifacts := Set("edu.berkeley.cs" %% "chisel3" % "3.5.0"),
203+
mimaBinaryIssueFilters ++= Seq(
204+
// Modified package private methods (https://github.com/lightbend/mima/issues/53)
205+
ProblemFilters.exclude[DirectMissingMethodProblem]("chisel3.stage.ChiselOptions.this"),
206+
),
200207
libraryDependencies += defaultVersions("treadle") % "test",
208+
Test / scalacOptions += "-P:chiselplugin:genBundleElements",
201209
scalacOptions in Test ++= Seq("-language:reflectiveCalls"),
202210
scalacOptions in Compile in doc ++= Seq(
203211
"-diagrams",

build.sc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class chisel3CrossModule(val crossScalaVersion: String) extends CommonModule wit
107107
object test extends Tests {
108108
override def scalacPluginClasspath = m.scalacPluginClasspath
109109

110+
override def scalacOptions = T {
111+
super.scalacOptions() ++ Agg("-P:chiselplugin:genBundleElements")
112+
}
113+
110114
override def ivyDeps = m.ivyDeps() ++ Agg(
111115
ivy"org.scalatest::scalatest:3.2.10",
112116
ivy"org.scalatestplus::scalacheck-1-14:3.2.2.0",

core/src/main/scala/chisel3/Aggregate.scala

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,66 @@ abstract class Bundle(implicit compileOptions: CompileOptions) extends Record {
12071207
* assert(uint === "h12345678".U) // This will pass
12081208
* }}}
12091209
*/
1210-
final lazy val elements: SeqMap[String, Data] = {
1210+
final lazy val elements: SeqMap[String, Data] =
1211+
// _elementsImpl is a method, only call it once
1212+
_elementsImpl match {
1213+
// Those not using plugin-generated _elementsImpl use the old reflective implementation
1214+
case oldElements: VectorMap[_, _] => oldElements.asInstanceOf[VectorMap[String, Data]]
1215+
// Plugin-generated _elementsImpl are incomplete and need some processing
1216+
case rawElements => _processRawElements(rawElements)
1217+
}
1218+
1219+
// The compiler plugin is imperfect at picking out elements statically so we process at runtime
1220+
// checking for errors and filtering out mistakes
1221+
private def _processRawElements(rawElements: Iterable[(String, Any)]): SeqMap[String, Data] = {
1222+
val hardwareFields = rawElements.flatMap {
1223+
case (name, data: Data) =>
1224+
if (data.isSynthesizable) {
1225+
Some(s"$name: $data")
1226+
} else {
1227+
None
1228+
}
1229+
case (name, Some(data: Data)) =>
1230+
if (data.isSynthesizable) {
1231+
Some(s"$name: $data")
1232+
} else {
1233+
None
1234+
}
1235+
case (name, s: scala.collection.Seq[Any]) if s.nonEmpty =>
1236+
s.head match {
1237+
// Ignore empty Seq()
1238+
case d: Data =>
1239+
throwException(
1240+
"Public Seq members cannot be used to define Bundle elements " +
1241+
s"(found public Seq member '${name}'). " +
1242+
"Either use a Vec if all elements are of the same type, or MixedVec if the elements " +
1243+
"are of different types. If this Seq member is not intended to construct RTL, mix in the trait " +
1244+
"IgnoreSeqInBundle."
1245+
)
1246+
case _ => // don't care about non-Data Seq
1247+
}
1248+
None
1249+
1250+
case _ => None
1251+
}
1252+
if (hardwareFields.nonEmpty) {
1253+
throw ExpectedChiselTypeException(s"Bundle: $this contains hardware fields: " + hardwareFields.mkString(","))
1254+
}
1255+
VectorMap(rawElements.toSeq.flatMap {
1256+
case (name, data: Data) =>
1257+
Some(name -> data)
1258+
case (name, Some(data: Data)) =>
1259+
Some(name -> data)
1260+
case _ => None
1261+
}.sortWith {
1262+
case ((an, a), (bn, b)) => (a._id > b._id) || ((a eq b) && (an > bn))
1263+
}: _*)
1264+
}
1265+
1266+
/* The old, reflective implementation of Bundle.elements
1267+
* This method is optionally overwritten by the compiler plugin for much better performance
1268+
*/
1269+
protected def _elementsImpl: Iterable[(String, Any)] = {
12111270
val nameMap = LinkedHashMap[String, Data]()
12121271
for (m <- getPublicFields(classOf[Bundle])) {
12131272
getBundleField(m) match {

core/src/main/scala/chisel3/BlackBox.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,30 @@ abstract class BlackBox(
145145
extends BaseBlackBox {
146146

147147
// Find a Record port named "io" for purposes of stripping the prefix
148-
private[chisel3] lazy val _io: Record =
148+
private[chisel3] lazy val _io: Option[Record] =
149149
this
150150
.findPort("io")
151151
.collect { case r: Record => r } // Must be a Record
152-
.getOrElse(null) // null handling occurs in generateComponent
153152

154153
// Allow access to bindings from the compatibility package
155-
protected def _compatIoPortBound() = portsContains(_io)
154+
protected def _compatIoPortBound() = _io.exists(portsContains(_))
156155

157156
private[chisel3] override def generateComponent(): Option[Component] = {
158157
_compatAutoWrapPorts() // pre-IO(...) compatibility hack
159158

160159
// Restrict IO to just io, clock, and reset
161-
require(_io != null, "BlackBox must have a port named 'io' of type Record!")
162-
require(portsContains(_io), "BlackBox must have io wrapped in IO(...)")
160+
if (!_io.forall(portsContains)) {
161+
throwException(s"BlackBox '$this' must have a port named 'io' of type Record wrapped in IO(...)!")
162+
}
163+
163164
require(portsSize == 1, "BlackBox must only have one IO, called `io`")
164165

165166
require(!_closed, "Can't generate module more than once")
166167
_closed = true
167168

168-
val namedPorts = _io.elements.toSeq.reverse // ListMaps are stored in reverse order
169+
val io = _io.get
170+
171+
val namedPorts = io.elements.toSeq.reverse // ListMaps are stored in reverse order
169172

170173
// There is a risk of user improperly attempting to connect directly with io
171174
// Long term solution will be to define BlackBox IO differently as part of
@@ -181,18 +184,18 @@ abstract class BlackBox(
181184
// of the io bundle, but NOT on the io bundle itself.
182185
// Doing so would cause the wrong names to be assigned, since their parent
183186
// is now the module itself instead of the io bundle.
184-
for (id <- getIds; if id ne _io) {
187+
for (id <- getIds; if id ne io) {
185188
id._onModuleClose
186189
}
187190

188191
val firrtlPorts = namedPorts.map { namedPort => Port(namedPort._2, namedPort._2.specifiedDirection) }
189-
val component = DefBlackBox(this, name, firrtlPorts, _io.specifiedDirection, params)
192+
val component = DefBlackBox(this, name, firrtlPorts, io.specifiedDirection, params)
190193
_component = Some(component)
191194
_component
192195
}
193196

194197
private[chisel3] def initializeInParent(parentCompileOptions: CompileOptions): Unit = {
195-
for ((_, port) <- _io.elements) {
198+
for ((_, port) <- _io.map(_.elements).getOrElse(Nil)) {
196199
pushCommand(DefInvalid(UnlocatableSourceInfo, port.ref))
197200
}
198201
}

core/src/main/scala/chisel3/Data.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
480480
protected[chisel3] def binding: Option[Binding] = _binding
481481
protected def binding_=(target: Binding) {
482482
if (_binding.isDefined) {
483-
throw RebindingException(s"Attempted reassignment of binding to $this")
483+
throw RebindingException(s"Attempted reassignment of binding to $this, from: ${target}")
484484
}
485485
_binding = Some(target)
486486
}

0 commit comments

Comments
 (0)