Skip to content

Commit 63fca34

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # src/main/scala/tech/rocksavage/chiselware/timer/TimerConfig.scala # src/test/scala/tech/rocksavage/chiselware/timer/TimerTest.scala
2 parents a28f276 + 03748f1 commit 63fca34

12 files changed

Lines changed: 100 additions & 107 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ clean:
2222
rm -rf generated target *anno.json ./*.rpt doc/*.rpt syn/*.rpt syn.log out test_run_dir target
2323
rm -rf project/project project/target
2424
rm -rf generated
25+
rm -rf ~/.sbt ~/.ivy2
2526
# filter all files with bad extensions
2627
find . -type f -name "*.aux" -delete
2728
find . -type f -name "*.toc" -delete
@@ -46,7 +47,7 @@ sta:
4647

4748
test:
4849
@echo Running tests...
49-
@$(SBT) test
50+
@$(SBT) test -DuseVerilator="true"
5051

5152
cov:
5253
@$(SBT) coverageOn test coverageReport

build.sbt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ ThisBuild / organizationName := "Rocksavage Technology"
88
//Test / parallelExecution := false
99

1010
lazy val chisel_module_runner = RootProject(
11-
uri("https://github.com/The-Chiselers/chisel_module_runner.git#main")
11+
uri("https://github.com/The-Chiselers/chisel_module_runner.git#main"),
1212
)
1313
lazy val stdlib = RootProject(
14-
uri("https://github.com/The-Chiselers/stdlib.git#main")
14+
uri("https://github.com/The-Chiselers/stdlib.git#main"),
1515
)
1616
lazy val synth = RootProject(
17-
uri("https://github.com/The-Chiselers/synth.git#main")
17+
uri("https://github.com/The-Chiselers/synth.git#main"),
1818
)
1919
lazy val addrdecode = RootProject(
20-
uri("https://github.com/The-Chiselers/addrdecode.git#main")
20+
uri("https://github.com/The-Chiselers/addrdecode.git#main"),
2121
)
2222
lazy val apb = RootProject(uri("https://github.com/The-Chiselers/apb.git#main"))
2323
lazy val registermap = RootProject(
24-
uri("https://github.com/The-Chiselers/registermap.git#main")
24+
uri("https://github.com/The-Chiselers/registermap.git#main"),
2525
)
2626
lazy val test_utils = RootProject(
27-
uri("https://github.com/The-Chiselers/test_utils.git#main")
27+
uri("https://github.com/The-Chiselers/test_utils.git#main"),
2828
)
2929
lazy val root = (project in file("."))
3030
.settings(
@@ -33,18 +33,18 @@ lazy val root = (project in file("."))
3333
libraryDependencies ++= Seq(
3434
"org.chipsalliance" %% "chisel" % chiselVersion,
3535
"edu.berkeley.cs" %% "chiseltest" % "6.0.0",
36-
"org.rogach" %% "scallop" % "5.2.0"
36+
"org.rogach" %% "scallop" % "5.2.0",
3737
),
3838
scalacOptions ++= Seq(
3939
"-language:reflectiveCalls",
4040
"-deprecation",
4141
"-feature",
4242
"-Xcheckinit",
43-
"-Ymacro-annotations"
43+
"-Ymacro-annotations",
4444
),
4545
addCompilerPlugin(
46-
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full
47-
)
46+
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full,
47+
),
4848
)
4949
.dependsOn(
5050
chisel_module_runner,
@@ -53,7 +53,7 @@ lazy val root = (project in file("."))
5353
addrdecode,
5454
apb,
5555
registermap,
56-
test_utils
56+
test_utils,
5757
)
5858
val chiselVersion = "6.6.0"
5959
val scalafmtVersion = "2.5.0"

flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
sbt
2424
scala-cli
2525
scalafmt
26+
scalafix
2627

2728
# Chisel
2829
circt
@@ -108,6 +109,7 @@
108109
sbt
109110
scala-cli
110111
scalafmt
112+
scalafix
111113

112114
# Chisel
113115
circt
@@ -189,6 +191,7 @@
189191
sbt
190192
scala-cli
191193
scalafmt
194+
scalafix
192195

193196
# Chisel
194197
circt

shared-config

src/main/scala/tech/rocksavage/chiselware/timer/Timer.scala

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
package tech.rocksavage.chiselware.timer
44

55
import chisel3._
6-
import tech.rocksavage.chiselware.addrdecode.{AddrDecode, AddrDecodeError}
6+
import tech.rocksavage.chiselware.addrdecode.AddrDecode
7+
import tech.rocksavage.chiselware.addrdecode.AddrDecodeError
78
import tech.rocksavage.chiselware.addressable.RegisterMap
8-
import tech.rocksavage.chiselware.apb.{ApbBundle, ApbParams}
9+
import tech.rocksavage.chiselware.apb.ApbBundle
10+
import tech.rocksavage.chiselware.apb.ApbParams
911
import tech.rocksavage.chiselware.timer.bundle.TimerOutputBundle
1012
import tech.rocksavage.chiselware.timer.param.TimerParams
13+
import tech.rocksavage.test.TestUtils.coverAll
1114

12-
/** A Timer module that implements a configurable timer with various
13-
* functionalities.
15+
/** A Timer module that implements a configurable timer with various functionalities.
1416
*
1517
* @param timerParams
1618
* Parameters for configuring the timer.
1719
* @param formal
1820
* A boolean value to enable formal verification.
1921
*/
20-
class Timer(val timerParams: TimerParams, formal: Boolean) extends Module {
22+
class Timer(
23+
val timerParams: TimerParams,
24+
formal: Boolean)
25+
extends Module {
2126

2227
/** Data width for the timer */
2328
val dataWidth = timerParams.dataWidth
@@ -50,55 +55,55 @@ class Timer(val timerParams: TimerParams, formal: Boolean) extends Module {
5055
registerMap.createAddressableRegister(
5156
en,
5257
"en",
53-
verbose = timerParams.verbose
58+
verbose = timerParams.verbose,
5459
)
5560

5661
/** Prescaler value register */
5762
val prescaler: UInt = RegInit(0.U(timerParams.prescalerWidth.W))
5863
registerMap.createAddressableRegister(
5964
prescaler,
6065
"prescaler",
61-
verbose = timerParams.verbose
66+
verbose = timerParams.verbose,
6267
)
6368

6469
/** Maximum count value register */
6570
val maxCount: UInt = RegInit(0.U(timerParams.countWidth.W))
6671
registerMap.createAddressableRegister(
6772
maxCount,
6873
"maxCount",
69-
verbose = timerParams.verbose
74+
verbose = timerParams.verbose,
7075
)
7176

7277
/** PWM ceiling value register */
7378
val pwmCeiling: UInt = RegInit(0.U(timerParams.countWidth.W))
7479
registerMap.createAddressableRegister(
7580
pwmCeiling,
7681
"pwmCeiling",
77-
verbose = timerParams.verbose
82+
verbose = timerParams.verbose,
7883
)
7984

8085
/** Value to set the count register */
8186
val setCountValue: UInt = RegInit(0.U(timerParams.countWidth.W))
8287
registerMap.createAddressableRegister(
8388
setCountValue,
8489
"setCountValue",
85-
verbose = timerParams.verbose
90+
verbose = timerParams.verbose,
8691
)
8792

8893
/** Signal to set the count register */
8994
val setCount: Bool = RegInit(false.B)
9095
registerMap.createAddressableRegister(
9196
setCount,
9297
"setCount",
93-
verbose = timerParams.verbose
98+
verbose = timerParams.verbose,
9499
)
95100

96101
/** Enable interrupt for maximum count register */
97102
val maxCountEnableInterrupt: Bool = RegInit(false.B)
98103
registerMap.createAddressableRegister(
99104
maxCountEnableInterrupt,
100105
"maxCountEnableInterrupt",
101-
verbose = timerParams.verbose
106+
verbose = timerParams.verbose,
102107
)
103108

104109
// Generate AddrDecode
@@ -111,37 +116,39 @@ class Timer(val timerParams: TimerParams, formal: Boolean) extends Module {
111116
addrDecode.io.en := true.B
112117
addrDecode.io.selInput := true.B
113118
io.apb.PREADY := (io.apb.PENABLE && io.apb.PSEL)
114-
io.apb.PSLVERR := addrDecode.io.errorCode === AddrDecodeError.AddressOutOfRange
115-
io.apb.PRDATA := 0.U
119+
io.apb.PSLVERR := addrDecode.io.errorCode === AddrDecodeError.AddressOutOfRange
120+
io.apb.PRDATA := 0.U
116121

117122
// Control Register Read/Write
118123
when(io.apb.PSEL && io.apb.PENABLE) {
119124
when(io.apb.PWRITE) {
120-
for (reg <- registerMap.getRegisters) {
125+
for (reg <- registerMap.getRegisters)
121126
when(addrDecode.io.sel(reg.id)) {
122127
reg.writeCallback(addrDecode.io.addrOut, io.apb.PWDATA)
123128
}
124-
}
125129
}.otherwise {
126-
for (reg <- registerMap.getRegisters) {
130+
for (reg <- registerMap.getRegisters)
127131
when(addrDecode.io.sel(reg.id)) {
128132
io.apb.PRDATA := reg.readCallback(addrDecode.io.addrOut)
129133
}
130-
}
131134
}
132135
}
133136

134137
// Instantiate the TimerInner module
135138
/** TimerInner module instance */
136139
val timerInner = Module(new TimerInner(timerParams, formal))
137-
timerInner.io.timerInputBundle.en := en
138-
timerInner.io.timerInputBundle.setCount := setCount
139-
timerInner.io.timerInputBundle.prescaler := prescaler
140-
timerInner.io.timerInputBundle.maxCount := maxCount
141-
timerInner.io.timerInputBundle.pwmCeiling := pwmCeiling
142-
timerInner.io.timerInputBundle.setCountValue := setCountValue
140+
timerInner.io.timerInputBundle.en := en
141+
timerInner.io.timerInputBundle.setCount := setCount
142+
timerInner.io.timerInputBundle.prescaler := prescaler
143+
timerInner.io.timerInputBundle.maxCount := maxCount
144+
timerInner.io.timerInputBundle.pwmCeiling := pwmCeiling
145+
timerInner.io.timerInputBundle.setCountValue := setCountValue
143146
timerInner.io.timerInputBundle.maxCountEnableInterrupt := maxCountEnableInterrupt
144147

145148
// Connect the TimerInner outputs to the top-level outputs
146149
io.timerOutput <> timerInner.io.timerOutputBundle
150+
151+
if (timerParams.coverage)
152+
// Cover the entire IO bundle recursively.
153+
coverAll(io, "_io")
147154
}

0 commit comments

Comments
 (0)