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

Commit

Permalink
refactor remaining pmods.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 22, 2024
1 parent 70f421b commit 42f72af
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,26 @@ class IceBreakerResources extends BoardResources {
9 -> 46,
10 -> 44,
)

val pmod1b1 = resource.InOut().onPin(43)
val pmod1b2 = resource.InOut().onPin(38)
val pmod1b3 = resource.InOut().onPin(34)
val pmod1b4 = resource.InOut().onPin(31)
val pmod1b7 = resource.InOut().onPin(42)
val pmod1b8 = resource.InOut().onPin(36)
val pmod1b9 = resource.InOut().onPin(32)
val pmod1b10 = resource.InOut().onPin(28)

val pmod2_1 = resource.InOut().onPin(27)
val pmod2_2 = resource.InOut().onPin(25)
val pmod2_3 = resource.InOut().onPin(21)
val pmod2_4 = resource.InOut().onPin(19)
val pmod2_7 = resource.InOut().onPin(26)
val pmod2_8 = resource.InOut().onPin(23)
val pmod2_9 = resource.InOut().onPin(20)
val pmod2_10 = resource.InOut().onPin(18)
val pmod1b = resource.Connector(
resource.InOut(),
1 -> 43,
2 -> 38,
3 -> 34,
4 -> 31,
7 -> 42,
8 -> 36,
9 -> 32,
10 -> 28,
)
val pmod2 = resource.Connector(
resource.InOut(),
1 -> 27,
2 -> 25,
3 -> 21,
4 -> 19,
7 -> 26,
8 -> 23,
9 -> 20,
10 -> 18,
)
}
10 changes: 5 additions & 5 deletions src/main/scala/ee/hrzn/chryse/platform/resource/Connector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package ee.hrzn.chryse.platform.resource

import chisel3._

class Connector[E <: SinglePinResource](
class Connector[Ix, E <: SinglePinResource](
gen: => E,
private val ixToPin: (Int, Pin)*,
private val ixToPin: (Ix, Pin)*,
) extends Resource {
private val mappings: Map[Int, E] = ixToPin
private val mappings: Map[Ix, E] = ixToPin
.map { case (i, p) =>
i -> gen.onPin(p)
}
.to(Map)

def apply(ix: Int): E = mappings(ix)
def apply(ix: Ix): E = mappings(ix)

def setName(name: String): Unit =
mappings.foreach { case (i, e) => e.setName(s"$name$i") }
Expand All @@ -21,6 +21,6 @@ class Connector[E <: SinglePinResource](
}

object Connector {
def apply[E <: SinglePinResource](gen: => E, ixToPin: (Int, Pin)*) =
def apply[Ix, E <: SinglePinResource](gen: => E, ixToPin: (Ix, Pin)*) =
new Connector(gen, ixToPin: _*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ class InOutTop(platform: Platform) extends Module {
plat.resources.uart.tx := plat.resources.pmod1a(2).i

// Do the same with 1b1 and 1b2, but use inverted inputs/outputs.
plat.resources.pmod1b1.o := plat.resources.ubtn
plat.resources.ledr := plat.resources.pmod1b2.i
plat.resources.pmod1b(1).o := plat.resources.ubtn
plat.resources.ledr := plat.resources.pmod1b(2).i
}

0 comments on commit 42f72af

Please sign in to comment.