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

Commit

Permalink
cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 22, 2024
1 parent ad2d71b commit 94986ac
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class IceBreakerResources extends BoardResources {
val ledg = resource.LED().inverted.onPin(37)
val ledr = resource.LED().inverted.onPin(11)

// Ideally (per Amaranth) a user can refer to these connectors to make their
// own resources, instead of just getting pins out of them.
val pmod1a = resource.Connector(
resource.InOut(),
1 -> 4,
Expand Down
6 changes: 2 additions & 4 deletions src/main/scala/ee/hrzn/chryse/platform/resource/Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import ee.hrzn.chryse.platform.BoardResources

import scala.collection.mutable.ArrayBuffer

// XXX: This is more of a resource holder/container.
// It's one or possibly many (or no?) resources. Hrm.
trait Base {
def setName(name: String): Unit
def bases(): Seq[DataResource[_ <: Data]]
def data: Seq[DataResource[_ <: Data]]
}

object Base {
Expand All @@ -21,7 +19,7 @@ object Base {
f.setAccessible(true)
f.get(br) match {
case res: Base =>
out.appendAll(res.bases())
out.appendAll(res.data)
case _ =>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Connector[Ix, E <: SinglePinResource](
def setName(name: String): Unit =
mappings.foreach { case (i, e) => e.setName(s"$name$i") }

def bases(): Seq[DataResource[_ <: Data]] =
mappings.flatMap(_._2.bases()).toSeq
def data: Seq[DataResource[_ <: Data]] =
mappings.flatMap(_._2.data).toSeq
}

object Connector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class DataResource[HW <: Data](gen: => HW) extends SinglePinResource {
this
}

def bases(): Seq[DataResource[_ <: Data]] = Seq(this)
def data: Seq[DataResource[_ <: Data]] = Seq(this)
}

case class InstSides[HW](user: HW, top: HW)
4 changes: 3 additions & 1 deletion src/main/scala/ee/hrzn/chryse/platform/resource/InOut.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ee.hrzn.chryse.platform.resource

import chisel3._

// TODO: it's an error to use both "i" and "o" (tristate is a different kettle
// of fish entirely).
class InOut extends Base with SinglePinResource {
val i = new DataResource[Bool](Input(Bool())) {}
val o = new DataResource[Bool](Output(Bool())) {}
Expand All @@ -17,7 +19,7 @@ class InOut extends Base with SinglePinResource {
this
}

def bases(): Seq[DataResource[_ <: Data]] = Seq(i, o)
def data: Seq[DataResource[_ <: Data]] = Seq(i, o)
}

object InOut {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ee/hrzn/chryse/platform/resource/UART.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UART extends Base {
this
}

def bases(): Seq[DataResource[_ <: Data]] = Seq(rx, tx)
def data: Seq[DataResource[_ <: Data]] = Seq(rx, tx)
}

object UART {
Expand Down

0 comments on commit 94986ac

Please sign in to comment.