Skip to content

Commit

Permalink
feat(countcomb): working switches
Browse files Browse the repository at this point in the history
gp
  • Loading branch information
ajlekcahdp4 committed Apr 17, 2024
1 parent 79d0835 commit 3daf898
Show file tree
Hide file tree
Showing 2 changed files with 18 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_switchNumber[0]" 33;
IO_LOC "io_switchNumber[1]" 30;
IO_LOC "io_switchNumber[2]" 29;
IO_LOC "io_switchNumber[3]" 28;
IO_LOC "io_switchNumber[4]" 26;
IO_LOC "io_switchNumber[5]" 25;
IO_LOC "io_switchNumber[6]" 39;
IO_LOC "io_switchNumber[7]" 36;

IO_LOC "io_switch" 41;

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 switchNumber = Input(UInt(numLeds.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,14 @@ 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
io.led := Mux(io.switch, ~io.switchNumber, valueTmp)
top.io.value := Mux(io.switch, ~io.switchNumber, 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, 50_000_000, 256),
args = Array("--target-dir", "generated/projects"),
firtoolOpts = Array(
"--disable-all-randomization",
Expand Down

0 comments on commit 3daf898

Please sign in to comment.