From 3d5f928bba7eb2648721ba4901fbe2c77473e7fc Mon Sep 17 00:00:00 2001 From: Asherah Connor Date: Thu, 23 May 2024 18:25:55 +0300 Subject: [PATCH] ICE40Top: reimplement ubtnReset. --- .../ee/hrzn/chryse/platform/ice40/ICE40Top.scala | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala b/src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala index 4a29950..d3c6f98 100644 --- a/src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala +++ b/src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala @@ -42,11 +42,11 @@ class ICE40Top[Top <: Module]( resetTimerReg := resetTimerReg + 1.U } + var ubtn_reset: Option[Bool] = None private val finalReset = noPrefix { - // TODO (iCE40): this no longer works. :) if (platform.asInstanceOf[IceBreakerPlatform].ubtnReset) { - val io_ubtn = IO(Input(Bool())) - reset | ~io_ubtn + ubtn_reset = Some(Wire(Bool())) + reset | ~ubtn_reset.get } else { reset } @@ -75,6 +75,15 @@ class ICE40Top[Top <: Module]( clki := io case _ => + if (name == "ubtn" && ubtn_reset.isDefined) { + if (res.ioInst.isDefined) { + throw new Exception("ubtnReset requested but ubtn used in design") + } + ios += name -> res.pinId.get + val io = IO(res.makeIo()).suggestName(name) + ubtn_reset.get := io + } + if (res.ioInst.isDefined) { ios += name -> res.pinId.get val io = IO(res.makeIo()).suggestName(name)