aboutsummaryrefslogtreecommitdiff
path: root/top_count/src/counter.scala
blob: d8dc06eec10348f7856253ce7e8263d5db04da8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package top_count

import spinal.core._

case class counter() extends Component {
  val io = new Bundle {
    val en_i = in Bool()
    val cnt_o  = out UInt(4 bits)
  }

  // The counter register
  val cnt = Reg(UInt(4 bits)) init 0

  when (io.en_i) {
    cnt := cnt + 1
  }
  // Map the register content to the output
  io.cnt_o := cnt
}