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

Commit

Permalink
WIP: this is a hack to keep the types. Unsure.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 26, 2024
1 parent d160a5c commit e53c302
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class ICE40Top[Top <: Module](
.get("PULLUP")
.map(_.asInstanceOf[IntParam].value == 1)
.getOrElse(false),
gen = res.makeIo(),
),
).suggestName(s"${res.name.get}_SB_IO")

Expand All @@ -71,9 +70,14 @@ class ICE40Top[Top <: Module](
buffer.OUTPUT_ENABLE := DontCare
buffer.D_OUT_0 := DontCare
case DirectionOf.Output =>
portIo := buffer.PACKAGE_PIN
buffer.OUTPUT_ENABLE := true.B
buffer.D_OUT_0 := topIo
if (portIo.isInstanceOf[Clock]) {
portIo := buffer.PACKAGE_PIN.asClock
buffer.D_OUT_0 := topIo.asUInt
} else {
portIo := buffer.PACKAGE_PIN
buffer.D_OUT_0 := topIo
}
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/scala/ee/hrzn/chryse/platform/ice40/SB_IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import chisel3._
import chisel3.experimental.Analog
import chisel3.experimental.ExtModule

class SB_IO[T <: Data](
class SB_IO(
pinType: Int,
ioStandard: String = IOStandard.LVCMOS,
pullup: Boolean = false,
gen: => T = Bool(),
) extends ExtModule(
Map(
"IO_STANDARD" -> ioStandard,
Expand All @@ -21,15 +20,15 @@ class SB_IO[T <: Data](
// tristates.
private val isOutput = (pinType & PinType.PIN_OUTPUT_TRISTATE) != 0

private def genPin(): T = {
private def genPin(): Bool = {
if (isOutput)
Output(gen)
Output(Bool())
else
Input(gen)
Input(Bool())
}

val PACKAGE_PIN = IO(genPin())
val OUTPUT_ENABLE = IO(Input(Bool()))
val D_IN_0 = IO(Output(gen))
val D_OUT_0 = IO(Input(gen))
val D_IN_0 = IO(Output(Bool()))
val D_OUT_0 = IO(Input(Bool()))
}

0 comments on commit e53c302

Please sign in to comment.