@@ -9,22 +9,28 @@ import tech.rocksavage.chiselware.apb.{ApbBundle, ApbParams}
99import tech .rocksavage .chiselware .timer .bundle .TimerOutputBundle
1010import tech .rocksavage .chiselware .timer .param .TimerParams
1111
12- /**
13- * A Timer module that implements a configurable timer with various functionalities.
14- *
15- * @param timerParams Parameters for configuring the timer.
16- * @param formal A boolean value to enable formal verification.
17- */
12+ /** A Timer module that implements a configurable timer with various
13+ * functionalities.
14+ *
15+ * @param timerParams
16+ * Parameters for configuring the timer.
17+ * @param formal
18+ * A boolean value to enable formal verification.
19+ */
1820class Timer (val timerParams : TimerParams , formal : Boolean ) extends Module {
21+
1922 /** Data width for the timer */
20- val dataWidth = timerParams.dataWidth
23+ val dataWidth = timerParams.dataWidth
24+
2125 /** Address width for the timer */
2226 val addressWidth = timerParams.addressWidth
2327
2428 /** Input/Output bundle for the Timer module */
2529 val io = IO (new Bundle {
30+
2631 /** APB interface for the timer */
27- val apb = new ApbBundle (ApbParams (dataWidth, addressWidth))
32+ val apb = new ApbBundle (ApbParams (dataWidth, addressWidth))
33+
2834 /** Output bundle for timer outputs */
2935 val timerOutput = new TimerOutputBundle (timerParams)
3036 })
@@ -34,41 +40,70 @@ class Timer(val timerParams: TimerParams, formal: Boolean) extends Module {
3440
3541 /** Enable signal register */
3642 val en : Bool = RegInit (false .B )
37- registerMap.createAddressableRegister(en, " en" , verbose = timerParams.verbose)
43+ registerMap.createAddressableRegister(
44+ en,
45+ " en" ,
46+ verbose = timerParams.verbose
47+ )
3848
3949 /** Prescaler value register */
4050 val prescaler : UInt = RegInit (0 .U (timerParams.prescalerWidth.W ))
41- registerMap.createAddressableRegister(prescaler, " prescaler" , verbose = timerParams.verbose)
51+ registerMap.createAddressableRegister(
52+ prescaler,
53+ " prescaler" ,
54+ verbose = timerParams.verbose
55+ )
4256
4357 /** Maximum count value register */
4458 val maxCount : UInt = RegInit (0 .U (timerParams.countWidth.W ))
45- registerMap.createAddressableRegister(maxCount, " maxCount" , verbose = timerParams.verbose)
59+ registerMap.createAddressableRegister(
60+ maxCount,
61+ " maxCount" ,
62+ verbose = timerParams.verbose
63+ )
4664
4765 /** PWM ceiling value register */
4866 val pwmCeiling : UInt = RegInit (0 .U (timerParams.countWidth.W ))
49- registerMap.createAddressableRegister(pwmCeiling, " pwmCeiling" , verbose = timerParams.verbose)
67+ registerMap.createAddressableRegister(
68+ pwmCeiling,
69+ " pwmCeiling" ,
70+ verbose = timerParams.verbose
71+ )
5072
5173 /** Value to set the count register */
5274 val setCountValue : UInt = RegInit (0 .U (timerParams.countWidth.W ))
53- registerMap.createAddressableRegister(setCountValue, " setCountValue" , verbose = timerParams.verbose)
75+ registerMap.createAddressableRegister(
76+ setCountValue,
77+ " setCountValue" ,
78+ verbose = timerParams.verbose
79+ )
5480
5581 /** Signal to set the count register */
5682 val setCount : Bool = RegInit (false .B )
57- registerMap.createAddressableRegister(setCount, " setCount" , verbose = timerParams.verbose)
83+ registerMap.createAddressableRegister(
84+ setCount,
85+ " setCount" ,
86+ verbose = timerParams.verbose
87+ )
5888
5989 /** Enable interrupt for maximum count register */
6090 val maxCountEnableInterrupt : Bool = RegInit (false .B )
61- registerMap.createAddressableRegister(maxCountEnableInterrupt, " maxCountEnableInterrupt" , verbose = timerParams.verbose)
91+ registerMap.createAddressableRegister(
92+ maxCountEnableInterrupt,
93+ " maxCountEnableInterrupt" ,
94+ verbose = timerParams.verbose
95+ )
6296
6397 // Generate AddrDecode
6498 /** Parameters for address decoding */
6599 val addrDecodeParams = registerMap.getAddrDecodeParams
100+
66101 /** AddrDecode module instance */
67- val addrDecode = Module (new AddrDecode (addrDecodeParams))
68- addrDecode.io.addr := io.apb.PADDR
69- addrDecode.io.en := true .B
70- addrDecode.io.selInput := true .B
71- io.apb.PREADY := (io.apb.PENABLE && io.apb.PSEL )
102+ val addrDecode = Module (new AddrDecode (addrDecodeParams))
103+ addrDecode.io.addr := io.apb.PADDR
104+ addrDecode.io.en := true .B
105+ addrDecode.io.selInput := true .B
106+ io.apb.PREADY := (io.apb.PENABLE && io.apb.PSEL )
72107 io.apb.PSLVERR := addrDecode.io.errorCode === AddrDecodeError .AddressOutOfRange
73108 io.apb.PRDATA := 0 .U
74109
@@ -102,4 +137,4 @@ class Timer(val timerParams: TimerParams, formal: Boolean) extends Module {
102137
103138 // Connect the TimerInner outputs to the top-level outputs
104139 io.timerOutput <> timerInner.io.timerOutputBundle
105- }
140+ }
0 commit comments