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

Commit

Permalink
ICE40Platform: ubtnReset is opt-in.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 12, 2024
1 parent aadb599 commit 5960978
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ its own HDL depending on how much I love Scala. :)
* Generate PCFs on demand via board descriptions.
* Tie this all together with SV generation — lowering options should be here,
not in user code.
* iCE40 UBTN reset should be opt in.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import ee.hrzn.chryse.HasIO
import ee.hrzn.chryse.platform.ElaboratablePlatform
import ee.hrzn.chryse.platform.Platform

case object ICE40Platform extends ElaboratablePlatform {
case class ICE40Platform(ubtnReset: Boolean = false)
extends ElaboratablePlatform {
val id = "ice40"
val clockHz = 12_000_000

Expand Down
13 changes: 11 additions & 2 deletions src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ee.hrzn.chryse.platform.ice40

import chisel3._
import chisel3.experimental.noPrefix
import chisel3.util._
import ee.hrzn.chryse.HasIO
import ee.hrzn.chryse.platform.Platform
Expand Down Expand Up @@ -28,10 +29,18 @@ class ICE40Top[Top <: HasIO[_ <: Data]](genTop: => Top)(implicit
reset := true.B
resetTimerReg := resetTimerReg + 1.U
}
private val io_ubtn = IO(Input(Bool()))

val finalReset = noPrefix {
if (platform.asInstanceOf[ICE40Platform].ubtnReset) {
val io_ubtn = IO(Input(Bool()))
reset | ~io_ubtn
} else {
reset
}
}

private val top =
withClockAndReset(clk, reset | ~io_ubtn)(Module(genTop))
withClockAndReset(clk, finalReset)(Module(genTop))
private val io = IO(top.createIo())
io :<>= top.io.as[Data]
}
Expand Down

0 comments on commit 5960978

Please sign in to comment.