Skip to content

Commit

Permalink
TODO: make it work
Browse files Browse the repository at this point in the history
gp
  • Loading branch information
ajlekcahdp4 committed Apr 16, 2024
1 parent 79d0835 commit a7a84e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 11 additions & 0 deletions projects/chisel-practice/boards/tangnano9k.cst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
// https://github.com/YosysHQ/apicula/blob/master/examples/tangnano9k.cst
// Part Number: GW1NR-LV9QN88PC6/I5

IO_LOC "io_switchn[0]" 33;
IO_LOC "io_switchn[1]" 30;
IO_LOC "io_switchn[2]" 29;
IO_LOC "io_switchn[3]" 28;
IO_LOC "io_switchn[4]" 26;
IO_LOC "io_switchn[5]" 25;
IO_LOC "io_switchn[6]" 39;
IO_LOC "io_switchn[7]" 36;

IO_LOC "io_switch" 35;

IO_LOC "io_led[0]" 76;
IO_LOC "io_led[1]" 38;
IO_LOC "io_led[2]" 37;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class CountCombinationsTopIO(numDigits: Int, numLeds: Int) extends Bundle {
val digit = Output(UInt(numDigits.W))
val led = Output(UInt(numLeds.W))
val segments = Output(UInt(8.W))
val switchn = Input(UInt(numDigits.W))
val switch = Input(Bool())
}

class CountCombinationsTop(
Expand All @@ -42,10 +44,11 @@ class CountCombinationsTop(
val dividedClock = withReset(reset = false.B) {
ClockDivider(clock, countFreq)
}
val (value, _) =
val (valueTmp, _) =
withClockAndReset(clock = dividedClock, reset = invertedReset) {
Counter(true.B, countMax)
}

val top = withReset(reset = invertedReset) {
Module(new CountCombinations(numBits))
}
Expand All @@ -55,14 +58,19 @@ class CountCombinationsTop(
io.digit <> sevenseg.io.digitSelect
io.segments <> sevenseg.io.segments
sevenseg.io.value := top.io.count
top.io.value := value
io.led := value
when (io.switch) {
io.led := io.switchn
top.io.value := io.switchn
} .otherwise {
io.led := valueTmp
top.io.value := valueTmp
}
}

object CountCombinationsVerilog extends App {
ChiselStage.emitSystemVerilogFile(
new CountCombinationsTop(8 /* numBits */, 4 /* numDigits */,
8 /* numLeds */, 135_000, 5_000_000, 256),
8 /* numLeds */, 135_000, 70_000_000, 256),
args = Array("--target-dir", "generated/projects"),
firtoolOpts = Array(
"--disable-all-randomization",
Expand Down

0 comments on commit a7a84e8

Please sign in to comment.