From 61f71ec79f5f326b86d2dc73a1b880d454dca36e Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Sat, 28 Mar 2026 15:51:26 +0100 Subject: add top_count --- top_count/src/counter.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 top_count/src/counter.scala (limited to 'top_count/src/counter.scala') diff --git a/top_count/src/counter.scala b/top_count/src/counter.scala new file mode 100644 index 0000000..d8dc06e --- /dev/null +++ b/top_count/src/counter.scala @@ -0,0 +1,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 +} -- cgit v1.2.3