diff --git a/build.sc b/build.sc index 598cfe2ae8..b592408815 100644 --- a/build.sc +++ b/build.sc @@ -57,6 +57,137 @@ object v { def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:$scalaVersion" def scalaLibrary(scalaVersion: String) = ivy"org.scala-lang:scala-library:$scalaVersion" +<<<<<<< HEAD +======= + + // 21, 1-2, {linux-x64, macos-x64, windows-x64} + // 22, 1-2, {linux-x64, macos-aarch64, macos-x64, windows-x64} + def jextract(jdkVersion: Int, jextractVersion: String, os: String, platform: String) = + s"https://download.java.net/java/early_access/jextract/21/1/openjdk-${jdkVersion}-jextract+${jextractVersion}_${os}-${platform}_bin.tar.gz" + + def circt(version: String, os: String, platform: String) = + s"https://github.com/llvm/circt/releases/download/firtool-${version}/circt-full-shared-${os}-${platform}.tar.gz" + + val warnConf = Seq( + "msg=APIs in chisel3.internal:s", + "msg=Importing from firrtl:s", + "msg=migration to the MLIR:s", + "msg=method hasDefiniteSize in trait IterableOnceOps is deprecated:s", // replacement `knownSize` is not in 2.12 + "msg=object JavaConverters in package collection is deprecated:s", + "msg=undefined in comment for method cf in class PrintableHelper:s", + // This is deprecated for external users but not internal use + "cat=deprecation&origin=firrtl\\.options\\.internal\\.WriteableCircuitAnnotation:s", + "cat=deprecation&origin=chisel3\\.util\\.experimental\\.BoringUtils.*:s", + "cat=deprecation&origin=chisel3\\.experimental\\.IntrinsicModule:s", + "cat=deprecation&origin=chisel3\\.ltl.*:s" + ) + + // ScalacOptions + val commonOptions = Seq( + "-deprecation", + "-feature", + "-unchecked", + "-Werror", + "-Ymacro-annotations", + "-explaintypes", + "-Xcheckinit", + "-Xlint:infer-any", + "-Xlint:missing-interpolator", + "-language:reflectiveCalls", + s"-Wconf:${warnConf.mkString(",")}" + ) +} + +object utils extends Module { + + val architecture = System.getProperty("os.arch") + val operationSystem = System.getProperty("os.name") + + val mac = operationSystem.toLowerCase.startsWith("mac") + val linux = operationSystem.toLowerCase.startsWith("linux") + val windows = operationSystem.toLowerCase.startsWith("win") + val amd64 = architecture.matches("^(x8664|amd64|ia32e|em64t|x64|x86_64)$") + val aarch64 = architecture.equals("aarch64") | architecture.startsWith("armv8") + + val firtoolVersion = { + val j = _root_.upickle.default.read[Map[String, String]](os.read(millSourcePath / os.up / "etc" / "circt.json")) + j("version").stripPrefix("firtool-") + } + + // use T.persistent to avoid download repeatedly + def circtInstallDir: T[os.Path] = T.persistent { + T.ctx().env.get("CIRCT_INSTALL_PATH") match { + case Some(dir) => os.Path(dir) + case None => + T.ctx().log.info("Use CIRCT_INSTALL_PATH to vendor circt") + val tarPath = T.dest / "circt.tar.gz" + if (!os.exists(tarPath)) { + val url = v.circt( + firtoolVersion, + if (linux) "linux" else if (mac) "macos" else throw new Exception("unsupported os"), + // circt does not yet publish for macos-aarch64, use x64 for now + if (amd64 || mac) "x64" else throw new Exception("unsupported arch") + ) + T.ctx().log.info(s"Downloading circt from ${url}") + mill.util.Util.download(url, os.rel / "circt.tar.gz") + T.ctx().log.info(s"Download Successfully") + } + os.proc("tar", "xvf", tarPath, "--strip-components=1").call(T.dest) + T.dest + } + } + + // use T.persistent to avoid download repeatedly + def jextractInstallDir: T[os.Path] = T.persistent { + T.ctx().env.get("JEXTRACT_INSTALL_PATH") match { + case Some(dir) => os.Path(dir) + case None => + T.ctx().log.info("Use JEXTRACT_INSTALL_PATH to vendor jextract") + val tarPath = T.dest / "jextract.tar.gz" + if (!os.exists(tarPath)) { + val url = v.jextract( + 21, + "1-2", + if (linux) "linux" else if (mac) "macos" else throw new Exception("unsupported os"), + // There is no macos-aarch64 for jextract 21, use x64 for now + if (amd64 || mac) "x64" else if (aarch64) "aarch64" else throw new Exception("unsupported arch") + ) + T.ctx().log.info(s"Downloading jextract from ${url}") + mill.util.Util.download(url, os.rel / "jextract.tar.gz") + T.ctx().log.info(s"Download Successfully") + } + os.proc("tar", "xvf", tarPath, "--strip-components=1").call(T.dest) + T.dest + } + } +} + +trait ChiselPublishModule extends CiReleaseModule { + // Publish information + def pomSettings = PomSettings( + description = artifactName(), + organization = "org.chipsalliance", + url = "https://www.chisel-lang.org", + licenses = Seq(License.`Apache-2.0`), + versionControl = VersionControl.github("chipsalliance", "chisel"), + developers = Seq( + Developer("jackkoenig", "Jack Koenig", "https://github.com/jackkoenig"), + Developer("azidar", "Adam Izraelevitz", "https://github.com/azidar"), + Developer("seldridge", "Schuyler Eldridge", "https://github.com/seldridge") + ) + ) + + override def sonatypeHost = Some(SonatypeHost.s01) + + override def publishVersion = VcsVersion + .vcsState() + .format( + countSep = "+", + revHashDigits = 8, + untaggedSuffix = "-SNAPSHOT" + ) + +>>>>>>> ca773c08a (Fix missing string interpolators, add -Xlint:missing-interpolator (#4471)) } private def majorScalaVersion(scalaVersion: String) = scalaVersion.split('.')(1).toInt diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala index 907f6c878a..f7282381bf 100644 --- a/core/src/main/scala/chisel3/Aggregate.scala +++ b/core/src/main/scala/chisel3/Aggregate.scala @@ -354,8 +354,14 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend case ActualDirection.Output => SpecifiedDirection.Output case ActualDirection.Bidirectional(ActualDirection.Default) | ActualDirection.Unspecified => SpecifiedDirection.Unspecified +<<<<<<< HEAD:core/src/main/scala/chisel3/Aggregate.scala case ActualDirection.Bidirectional(ActualDirection.Flipped) => SpecifiedDirection.Flip case ActualDirection.Empty => SpecifiedDirection.Unspecified +======= + case ActualDirection.Bidirectional.Flipped => SpecifiedDirection.Flip + case ActualDirection.Empty => SpecifiedDirection.Unspecified + case dir => throwException(s"Unexpected directionality: $dir") +>>>>>>> ca773c08a (Fix missing string interpolators, add -Xlint:missing-interpolator (#4471)):core/src/main/scala/chisel3/AggregateImpl.scala } // TODO port technically isn't directly child of this data structure, but the result of some // muxes / demuxes. However, this does make access consistent with the top-level bindings. diff --git a/core/src/main/scala/chisel3/connectable/Connection.scala b/core/src/main/scala/chisel3/connectable/Connection.scala index d2ebdcc0b0..28825b1d07 100644 --- a/core/src/main/scala/chisel3/connectable/Connection.scala +++ b/core/src/main/scala/chisel3/connectable/Connection.scala @@ -243,7 +243,7 @@ private[chisel3] object Connection { case List(a, b) => BiConnect.markAnalogConnected(sourceInfo, a, b, currentModule) BiConnect.markAnalogConnected(sourceInfo, b, a, currentModule) - case _ => throw new InternalErrorException("Match error: as.toList=${as.toList}") + case _ => throw new InternalErrorException(s"Match error: as.toList=${as.toList}") } } catch { // convert Exceptions to Builder.error's so compilation can continue case attach.AttachException(message) => Builder.error(message) diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/core/Hierarchy.scala b/core/src/main/scala/chisel3/experimental/hierarchy/core/Hierarchy.scala index 4fcb937dcd..0b6dd5bcd1 100644 --- a/core/src/main/scala/chisel3/experimental/hierarchy/core/Hierarchy.scala +++ b/core/src/main/scala/chisel3/experimental/hierarchy/core/Hierarchy.scala @@ -105,7 +105,7 @@ object Hierarchy { def toTarget: IsModule = i match { case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toTarget case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toTarget - case _ => throw new InternalErrorException("Match error: toTarget i=$i") + case _ => throw new InternalErrorException(s"Match error: toTarget i=$i") } /** Returns the toAbsoluteTarget of this hierarchy @@ -114,7 +114,29 @@ object Hierarchy { def toAbsoluteTarget: IsModule = i match { case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toAbsoluteTarget case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toAbsoluteTarget - case _ => throw new InternalErrorException("Match error: toAbsoluteTarget i=$i") + case _ => throw new InternalErrorException(s"Match error: toAbsoluteTarget i=$i") } +<<<<<<< HEAD +======= + + /** Returns the toRelativeTarget of this hierarchy + * @return relativeTarget of this Hierarchy + */ + def toRelativeTarget(root: Option[BaseModule]): IsModule = i match { + case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toRelativeTarget(root) + case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toRelativeTarget(root) + case _ => throw new InternalErrorException(s"Match error: toAbsoluteTarget i=$i") + } + + /** Returns the toRelativeTarget of this hierarchy + * @return relativeTarget of this Hierarchy + */ + def toRelativeTargetToHierarchy(root: Option[Hierarchy[BaseModule]]): IsModule = i match { + case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toRelativeTargetToHierarchy(root) + case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toRelativeTargetToHierarchy(root) + case _ => throw new InternalErrorException(s"Match error: toAbsoluteTarget i=$i") + } + +>>>>>>> ca773c08a (Fix missing string interpolators, add -Xlint:missing-interpolator (#4471)) } } diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala b/core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala index 6b9654c575..0ec4bfc1f3 100644 --- a/core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala +++ b/core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala @@ -33,7 +33,7 @@ final case class Instance[+A] private[chisel3] (private[chisel3] val underlying: case Proto(value: IsInstantiable) => None case Clone(i: BaseModule) => Some(i) case Clone(i: InstantiableClone[_]) => i.getInnerContext - case _ => throw new InternalErrorException("Match error: underlying=$underlying") + case _ => throw new InternalErrorException(s"Match error: underlying=$underlying") } /** @return the context this instance. Note that for non-module clones, getInnerDataContext will be the same as getClonedParent */ @@ -41,7 +41,7 @@ final case class Instance[+A] private[chisel3] (private[chisel3] val underlying: case Proto(value: BaseModule) => value._parent case Clone(i: BaseModule) => i._parent case Clone(i: InstantiableClone[_]) => i.getInnerContext - case _ => throw new InternalErrorException("Match error: underlying=$underlying") + case _ => throw new InternalErrorException(s"Match error: underlying=$underlying") } /** Used by Chisel's internal macros. DO NOT USE in your normal Chisel code!!! @@ -83,7 +83,7 @@ object Instance extends SourceInfoDoc { def toTarget: IsModule = i.underlying match { case Proto(x: BaseModule) => x.getTarget case Clone(x: IsClone[_] with BaseModule) => x.getTarget - case _ => throw new InternalErrorException("Match error: i.underlying=${i.underlying}") + case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}") } /** If this is an instance of a Module, returns the toAbsoluteTarget of this instance @@ -92,9 +92,34 @@ object Instance extends SourceInfoDoc { def toAbsoluteTarget: IsModule = i.underlying match { case Proto(x) => x.toAbsoluteTarget case Clone(x: IsClone[_] with BaseModule) => x.toAbsoluteTarget - case _ => throw new InternalErrorException("Match error: i.underlying=${i.underlying}") + case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}") } +<<<<<<< HEAD +======= + /** Returns a FIRRTL ReferenceTarget that references this object, relative to an optional root. + * + * If `root` is defined, the target is a hierarchical path starting from `root`. + * + * If `root` is not defined, the target is a hierarchical path equivalent to `toAbsoluteTarget`. + * + * @note If `root` is defined, and has not finished elaboration, this must be called within `atModuleBodyEnd`. + * @note The NamedComponent must be a descendant of `root`, if it is defined. + * @note This doesn't have special handling for Views. + */ + def toRelativeTarget(root: Option[BaseModule]): IsModule = i.underlying match { + case Proto(x) => x.toRelativeTarget(root) + case Clone(x: IsClone[_] with BaseModule) => x.toRelativeTarget(root) + case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}") + } + + def toRelativeTargetToHierarchy(root: Option[Hierarchy[BaseModule]]): IsModule = i.underlying match { + case Proto(x) => x.toRelativeTargetToHierarchy(root) + case Clone(x: IsClone[_] with BaseModule) => x.toRelativeTargetToHierarchy(root) + case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}") + } + +>>>>>>> ca773c08a (Fix missing string interpolators, add -Xlint:missing-interpolator (#4471)) def suggestName(name: String): Unit = i.underlying match { case Clone(m: BaseModule) => m.suggestName(name) case Proto(m) => m.suggestName(name) diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala b/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala index 4304638115..1bffb3a885 100644 --- a/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala +++ b/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala @@ -68,7 +68,7 @@ object Lookupable { newChild.bind(internal.CrossModuleBinding) newChild.setAllParents(Some(m)) newChild - case _ => throw new InternalErrorException("Match error: newParent=$newParent") + case _ => throw new InternalErrorException(s"Match error: newParent=$newParent") } } } @@ -195,7 +195,7 @@ object Lookupable { AggregateViewBinding(newMap) } } - case _ => throw new InternalErrorException("Match error: data.topBinding=${data.topBinding}") + case _ => throw new InternalErrorException(s"Match error: data.topBinding=${data.topBinding}") } // TODO Unify the following with `.viewAs` @@ -212,7 +212,7 @@ object Lookupable { Builder.unnamedViews += agg case _ => // Do nothing } - case _ => throw new InternalErrorException("Match error: newBinding=$newBinding") + case _ => throw new InternalErrorException(s"Match error: newBinding=$newBinding") } result.bind(newBinding) @@ -272,7 +272,7 @@ object Lookupable { val newChild = Module.do_pseudo_apply(new InstanceClone(m.getProto, () => m.instanceName)) newChild._parent = i._parent Clone(newChild) - case _ => throw new InternalErrorException("Match error: rec(m)=${rec(m)}") + case _ => throw new InternalErrorException(s"Match error: rec(m)=${rec(m)}") } case Clone(m: InstanceClone[_]) => rec(m) match { @@ -281,9 +281,9 @@ object Lookupable { val newChild = Module.do_pseudo_apply(new InstanceClone(m.getProto, () => m.instanceName)) newChild._parent = i._parent Clone(newChild) - case _ => throw new InternalErrorException("Match error: rec(m)=${rec(m)}") + case _ => throw new InternalErrorException(s"Match error: rec(m)=${rec(m)}") } - case _ => throw new InternalErrorException("Match error: module=$module") + case _ => throw new InternalErrorException(s"Match error: module=$module") } } @@ -388,7 +388,7 @@ object Lookupable { newChild.setRef(mem.getRef, true) newChild case _ => - throw new InternalErrorException("Match error: newParent=$newParent") + throw new InternalErrorException(s"Match error: newParent=$newParent") } } } diff --git a/src/main/scala/chisel3/aop/Select.scala b/src/main/scala/chisel3/aop/Select.scala index 68df53bde2..149c494567 100644 --- a/src/main/scala/chisel3/aop/Select.scala +++ b/src/main/scala/chisel3/aop/Select.scala @@ -479,10 +479,18 @@ object Select { // Given a loc, return all subcomponents of id that could be assigned to in connect private def getEffected(a: Arg): Seq[Data] = a match { +<<<<<<< HEAD case Node(id: Data) => getIntermediateAndLeafs(id) case Slot(imm, name) => Seq(imm.id.asInstanceOf[Record].elements(name)) case Index(imm, _) => getEffected(imm) case _ => throw new InternalErrorException("Match error: a=$a") +======= + case Node(id: Data) => DataMirror.collectAllMembers(id) + case Slot(imm: Node, name) => Seq(imm.id.asInstanceOf[Record].elements(name)) + case Index(imm, _) => getEffected(imm) + case LitIndex(imm, _) => getEffected(imm) + case _ => throw new InternalErrorException(s"Match error: a=$a") +>>>>>>> ca773c08a (Fix missing string interpolators, add -Xlint:missing-interpolator (#4471)) } // Given an arg, return the corresponding id. Don't use on a loc of a connect. @@ -511,7 +519,7 @@ object Select { case e: ChiselException => i.getOptionRef.get match { case l: LitArg => l.num.intValue.toString - case _ => throw new InternalErrorException("Match error: i.getOptionRef.get=${i.getOptionRef.get}") + case _ => throw new InternalErrorException(s"Match error: i.getOptionRef.get=${i.getOptionRef.get}") } } diff --git a/src/main/scala/chisel3/util/experimental/decode/QMCMinimizer.scala b/src/main/scala/chisel3/util/experimental/decode/QMCMinimizer.scala index 987901b140..b9456ea5b9 100644 --- a/src/main/scala/chisel3/util/experimental/decode/QMCMinimizer.scala +++ b/src/main/scala/chisel3/util/experimental/decode/QMCMinimizer.scala @@ -261,7 +261,7 @@ object QMCMinimizer extends Minimizer { (maxt ++ dc, false) case x if !x.mask.testBit(i) => // default to ? (mint, true) - case _ => throw new InternalErrorException("Match error: table.default=${table.default}") + case _ => throw new InternalErrorException(s"Match error: table.default=${table.default}") } implicants.foreach(_.isPrime = true) diff --git a/src/main/scala/circt/stage/phases/CIRCT.scala b/src/main/scala/circt/stage/phases/CIRCT.scala index 182d9d2253..d08880a10e 100644 --- a/src/main/scala/circt/stage/phases/CIRCT.scala +++ b/src/main/scala/circt/stage/phases/CIRCT.scala @@ -247,7 +247,7 @@ class CIRCT extends Phase { ) }) - logger.info(s"""Running CIRCT: '${cmd.mkString(" ")}""" + input.fold(_ => " < $$input'", _ => "'")) + logger.info(s"""Running CIRCT: '${cmd.mkString(" ")}""" + input.fold(_ => " < $$" + "input'", _ => "'")) val stdoutStream, stderrStream = new java.io.ByteArrayOutputStream val stdoutWriter = new java.io.PrintWriter(stdoutStream) val stderrWriter = new java.io.PrintWriter(stderrStream)