Skip to content

Commit

Permalink
Revert GCD BB changes | Move GCD to 0x4000 to not conflict w/ bootrom
Browse files Browse the repository at this point in the history
  • Loading branch information
abejgonzalez committed Nov 3, 2023
1 parent d7f78ba commit 19fda05
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
1 change: 0 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ $(SFC_MFC_TARGETS) &: $(TAPEOUT_CLASSPATH_TARGETS) $(FIRRTL_FILE) $(FINAL_ANNO_F
@if [ $(shell cat $(SFC_LEVEL)) = low ]; then cat $(TMP_DIR)/unnec-anno-deleted2.sfc.anno.json > $(SFC_ANNO_FILE) && rm $(TMP_DIR)/unnec-anno-deleted.sfc.anno.json && rm $(TMP_DIR)/unnec-anno-deleted2.sfc.anno.json; fi
firtool \
--format=fir \
--dedup \
--export-module-hierarchy \
--verify-each=true \
--warn-on-unprocessed-annotations \
Expand Down
31 changes: 7 additions & 24 deletions generators/chipyard/src/main/scala/example/GCD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import freechips.rocketchip.util.UIntIsOneOf

// DOC include start: GCD params
case class GCDParams(
address: BigInt = 0x1000,
address: BigInt = 0x4000,
width: Int = 32,
useAXI4: Boolean = false,
useBlackBox: Boolean = true)
Expand Down Expand Up @@ -46,11 +46,10 @@ trait HasGCDIO extends BaseModule {
}

// DOC include start: GCD blackbox
class GCDMMIOBlackBox(val w: Int) extends BlackBox(Map("WIDTH" -> IntParam(w))) with HasBlackBoxPath
class GCDMMIOBlackBox(val w: Int) extends BlackBox(Map("WIDTH" -> IntParam(w))) with HasBlackBoxResource
with HasGCDIO
{
val chipyardDir = System.getProperty("user.dir")
addPath(s"$chipyardDir/generators/chipyard/src/main/resources/vsrc/GCDMMIOBlackBox.v")
addResource("/vsrc/GCDMMIOBlackBox.v")
}
// DOC include end: GCD blackbox

Expand Down Expand Up @@ -114,36 +113,20 @@ trait GCDModule extends HasRegMap {
Module(new GCDMMIOChiselModule(params.width))
}

val impl1 = if (params.useBlackBox) {
Module(new GCDMMIOBlackBox(params.width))
} else {
Module(new GCDMMIOChiselModule(params.width))
}


impl.io.clock := clock
impl.io.reset := reset.asBool

impl.io.x := x
impl.io.y := y.bits
impl.io.input_valid := y.valid
y.ready := impl.io.input_ready && impl1.io.input_ready
y.ready := impl.io.input_ready

gcd.bits := impl.io.gcd
gcd.valid := impl.io.output_valid && impl1.io.output_valid
gcd.valid := impl.io.output_valid
impl.io.output_ready := gcd.ready

status := Cat(impl.io.input_ready, impl.io.output_valid, impl1.io.input_ready, impl1.io.output_valid)
io.gcd_busy := impl.io.busy && impl1.io.busy

impl1.io.clock := clock
impl1.io.reset := reset.asBool

impl1.io.x := x
impl1.io.y := y.bits
impl1.io.input_valid := y.valid

impl1.io.output_ready := gcd.ready
status := Cat(impl.io.input_ready, impl.io.output_valid)
io.gcd_busy := impl.io.busy

regmap(
0x00 -> Seq(
Expand Down
8 changes: 4 additions & 4 deletions tests/gcd.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "mmio.h"

#define GCD_STATUS 0x1000
#define GCD_X 0x1004
#define GCD_Y 0x1008
#define GCD_GCD 0x100C
#define GCD_STATUS 0x4000
#define GCD_X 0x4004
#define GCD_Y 0x4008
#define GCD_GCD 0x400C

unsigned int gcd_ref(unsigned int x, unsigned int y) {
while (y != 0) {
Expand Down

0 comments on commit 19fda05

Please sign in to comment.