Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
-Xlint cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 31, 2024
1 parent e38a905 commit fcb6259
Show file tree
Hide file tree
Showing 26 changed files with 25 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lazy val root = (project in file("."))
),
scalacOptions ++= Seq(
"-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit",
"-Ymacro-annotations", "-Wunused",
"-Ymacro-annotations", "-Xlint",
),
addCompilerPlugin(
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full,
Expand Down
11 changes: 1 addition & 10 deletions src/main/scala/ee/hrzn/chryse/ChryseApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import ee.hrzn.chryse.platform.Platform
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.cxxrtl.CXXRTLOptions
import ee.hrzn.chryse.platform.cxxrtl.CXXRTLPlatform

import scala.collection.mutable

abstract class ChryseApp {
val name: String
Expand Down Expand Up @@ -79,16 +76,10 @@ abstract class ChryseApp {
)

case Some(chosen) =>
for { sc <- additionalSubcommands }
if (sc == chosen) {
sc.execute()
return
}
throw new Exception("unhandled subcommand")
chosen.asInstanceOf[ChryseSubcommand].execute()

case None =>
conf.printHelp()

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ee/hrzn/chryse/ExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ee.hrzn.chryse.platform.ecp5.ULX3SPlatform
import ee.hrzn.chryse.platform.ice40.IceBreakerPlatform

object ExampleApp extends ChryseApp {
class Top(implicit platform: Platform) extends Module {}
class Top(implicit @annotation.unused platform: Platform) extends Module {}

override val name = "example"
override def genTop()(implicit platform: Platform) = new Top
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/ee/hrzn/chryse/chisel/DirectionOf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package ee.hrzn.chryse.chisel

import chisel3._

import scala.language.implicitConversions

private[chryse] object directionOf {
def apply[T <: Data](data: T): Direction =
specifiedDirectionOf(data) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package ee.hrzn.chryse.chisel

import chisel3._

import scala.language.implicitConversions

private[chryse] object specifiedDirectionOf {
def apply[T <: Data](data: T): SpecifiedDirection =
classOf[Data]
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/ee/hrzn/chryse/platform/ChryseTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ee.hrzn.chryse.platform.resource.ResourceData

import scala.collection.mutable
import scala.language.existentials
import scala.language.implicitConversions

trait ChryseTop extends RawModule {
override def desiredName = "chrysetop"
Expand All @@ -33,7 +32,7 @@ trait ChryseTop extends RawModule {
): PlatformConnectResult = PlatformConnectResultFallthrough

protected def platformPort[HW <: Data](
res: ResourceData[HW],
@annotation.unused res: ResourceData[HW],
topIo: Data,
portIo: Data,
): Unit = {
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/ee/hrzn/chryse/platform/Platform.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ee.hrzn.chryse.platform

import chisel3._

trait Platform {
val id: String
val clockHz: Int
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/ee/hrzn/chryse/platform/PlatformBoard.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ee.hrzn.chryse.platform

import chisel3._
import chisel3.experimental.BaseModule
import ee.hrzn.chryse.ChryseApp

trait PlatformBoard[PBR <: PlatformBoardResources]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import chisel3.experimental.Param
import ee.hrzn.chryse.platform.resource.ResourceBase
import ee.hrzn.chryse.platform.resource.ResourceData

import scala.collection.mutable.ArrayBuffer

abstract class PlatformBoardResources {
val defaultAttributes = Map[String, Param]()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ee.hrzn.chryse.platform.cxxrtl

import chisel3._
import chisel3.experimental.ExtModule
import circt.stage.ChiselStage
import ee.hrzn.chryse.chisel.BuilderContext
import ee.hrzn.chryse.chisel.specifiedDirectionOf

Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/ee/hrzn/chryse/platform/ecp5/ECP5Top.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import chisel3._
import chisel3.util.unsignedBitLength
import ee.hrzn.chryse.chisel.directionOf
import ee.hrzn.chryse.platform.ChryseTop
import ee.hrzn.chryse.platform.Platform
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.resource.PinPlatform
Expand Down Expand Up @@ -82,6 +81,8 @@ class ECP5Top[Top <: Module](

private val top =
withClockAndReset(clk, reset)(Module(genTop))
if (top.desiredName == desiredName)
throw new IllegalArgumentException(s"user top is called $desiredName")

// TODO (ECP5): allow clock source override.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ee.hrzn.chryse.platform.ecp5

import chisel3._
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.resource.ClockSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ee.hrzn.chryse.platform.ecp5

import chisel3._
import chisel3.experimental.Param
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.resource.Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import ee.hrzn.chryse.platform.resource.PinPlatform
import scala.language.implicitConversions

object USRMCLKPin {
implicit def usrmclk2Pin(usrmclk: this.type): Pin =
implicit def usrmclk2Pin(@annotation.unused usrmclk: this.type): Pin =
PinPlatform(this)
}
4 changes: 0 additions & 4 deletions src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ package ee.hrzn.chryse.platform.ice40

import chisel3._
import chisel3.experimental.IntParam
import chisel3.experimental.StringParam
import chisel3.experimental.noPrefix
import chisel3.util._
import chisel3.util.experimental.forceName
import ee.hrzn.chryse.chisel.directionOf
import ee.hrzn.chryse.platform.ChryseTop
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.resource.PinInt
import ee.hrzn.chryse.platform.resource.ResourceData

import scala.collection.mutable

class ICE40Top[Top <: Module](
platform: PlatformBoard[_ <: PlatformBoardResources],
genTop: => Top,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package ee.hrzn.chryse.platform.ice40

import chisel3._
import chisel3.experimental.Param
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.resource.Connector
import ee.hrzn.chryse.platform.resource.SPI
import ee.hrzn.chryse.platform.resource.LED
import ee.hrzn.chryse.platform.resource.UART
import ee.hrzn.chryse.platform.resource.Button
import ee.hrzn.chryse.platform.resource.ClockSource
import ee.hrzn.chryse.platform.resource.Connector
import ee.hrzn.chryse.platform.resource.InOut
import ee.hrzn.chryse.platform.resource.LED
import ee.hrzn.chryse.platform.resource.SPI
import ee.hrzn.chryse.platform.resource.UART

case class IceBreakerPlatform(
ubtnReset: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object ResourceBase {
def allFromBoardResources[T <: PlatformBoardResources](
br: T,
): Seq[ResourceData[_ <: Data]] = {
var out = ArrayBuffer[ResourceData[_ <: Data]]()
val out = ArrayBuffer[ResourceData[_ <: Data]]()
for { f <- br.getClass().getDeclaredFields().iterator } {
f.setAccessible(true)
f.get(br) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ object ResourceData {
}

implicit def viewBool: DataView[ResourceData[Bool], Bool] =
DataView(res => Bool(), _.ioInstOrMake() -> _)
DataView(_ => Bool(), _.ioInstOrMake() -> _)

implicit def res2bool(res: ResourceData[Bool]): Bool =
res.viewAs[Bool]

implicit def viewClock: DataView[ResourceData[Clock], Clock] =
DataView(res => Clock(), _.ioInstOrMake() -> _)
DataView(_ => Clock(), _.ioInstOrMake() -> _)

implicit def res2clock(res: ResourceData[Clock]): Clock =
res.viewAs[Clock]
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ee/hrzn/chryse/tasks/BaseTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait BaseTask {
final protected case object CmdStepExecute extends CmdStep("execute")

private def paddedStep(step: CmdStep): String = {
var r = s"($step)"
val r = s"($step)"
val spaces = "(place&route) ".length() - r.length()
r + " " * spaces
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/ee/hrzn/chryse/tasks/BuildTask.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package ee.hrzn.chryse.tasks

import chisel3._
import circt.stage.ChiselStage
import ee.hrzn.chryse.ChryseApp
import ee.hrzn.chryse.platform.Platform
import ee.hrzn.chryse.platform.PlatformBoard
import ee.hrzn.chryse.platform.PlatformBoardResources
import ee.hrzn.chryse.platform.ice40.ICE40Top
import ee.hrzn.chryse.platform.ice40.PCF

import java.nio.file.Files
import java.nio.file.Paths
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/ee/hrzn/chryse/tasks/CxxsimTask.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package ee.hrzn.chryse.tasks

import chisel3._
import circt.stage.ChiselStage
import ee.hrzn.chryse.ChryseApp
import ee.hrzn.chryse.ChryseAppStepFailureException
import ee.hrzn.chryse.ExampleApp.cxxrtlOptions
import ee.hrzn.chryse.platform.Platform
import ee.hrzn.chryse.platform.cxxrtl.BlackBoxGenerator
import ee.hrzn.chryse.platform.cxxrtl.CXXRTLOptions
import ee.hrzn.chryse.platform.cxxrtl.CXXRTLPlatform
import org.apache.commons.io.FileUtils

import java.io.PrintWriter
import java.nio.file.Files
import java.nio.file.Paths
import scala.collection.mutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object InterfaceExtractor {
final private case object ModeInout extends Mode

def apply(sv: String): Map[String, Module] = {
var map = mutable.Map[String, Module]()
val map = mutable.Map[String, Module]()
for {
Seq(moduleName, contents) <- reWhole.findAllMatchIn(sv).map(_.subgroups)
} {
Expand All @@ -38,7 +38,11 @@ object InterfaceExtractor {
var outputs = Seq[String]()
var inouts = Seq[String]()
for { el <- contents.split(",") if el.strip().length() != 0 } {
val Seq(kind, name) = reIndividual.findAllMatchIn(el).next().subgroups
val (kind, name) =
reIndividual.findAllMatchIn(el).next().subgroups match {
case Seq(kind, name) => (kind, name)
case _ => throw new Exception("weh")
}
kind match {
case "input" => mode = ModeInput
case "output" => mode = ModeOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PlatformBoardResourcesSpec extends AnyFlatSpec with Matchers {
)

val plat = SimPlatform()
simulate(plat(new InversionTop()(plat))) { c =>
simulate(plat(new InversionTop()(plat))) { _ =>
// InversionTop connects uart.tx and ledg to ubtn. ubtn and ledg are both
// inverted components, uart.tx isn't. Note that what we poke and peek are
// the signals on the pins, not transformed for the user, otherwise
Expand Down Expand Up @@ -99,7 +99,7 @@ class PlatformBoardResourcesSpec extends AnyFlatSpec with Matchers {
)

val plat = SimPlatform()
simulate(plat(new InOutTop()(plat))) { c =>
simulate(plat(new InOutTop()(plat))) { _ =>
for { v <- Seq(true, false) } {
plat.resources.uart.rx.portIoInst.get.poke(v.B)
plat.resources.pmod(2).i.portIoInst.get.poke(v.B)
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/ee/hrzn/chryse/platform/SimTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SimTop[Top <: Module](
genTop: => Top,
) extends Module
with ChryseTop {
private val top = Module(genTop)
Module(genTop)

val connectedResources =
connectResources(platform, None)
Expand Down
3 changes: 0 additions & 3 deletions src/test/scala/ee/hrzn/chryse/platform/ecp5/LPFSpec.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package ee.hrzn.chryse.platform.ecp5

import chisel3._
import ee.hrzn.chryse.platform.resource.PinString
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should._

import java.io.StringWriter

class LPFSpec extends AnyFlatSpec with Matchers {
behavior.of("LPF")

Expand Down
5 changes: 1 addition & 4 deletions src/test/scala/ee/hrzn/chryse/platform/ice40/PCFSpec.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package ee.hrzn.chryse.platform.ice40

import chisel3._
import ee.hrzn.chryse.platform.resource.PinInt
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should._

import java.io.StringWriter
import ee.hrzn.chryse.platform.resource.PinInt

class PCFSpec extends AnyFlatSpec with Matchers {
behavior.of("PCF")

Expand Down

0 comments on commit fcb6259

Please sign in to comment.