Add exercises
This commit is contained in:
commit
ac3cf23632
19 changed files with 21160 additions and 0 deletions
31
SpinalTest/src/main/scala/spinaltest/Test.scala
Normal file
31
SpinalTest/src/main/scala/spinaltest/Test.scala
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package spinaltest
|
||||
|
||||
import spinal.core._
|
||||
import spinal.core.sim._
|
||||
|
||||
class Counter extends Component {
|
||||
val count = out(Reg(UInt(8 bits)).init(0))
|
||||
count := count + 1
|
||||
}
|
||||
|
||||
object Gen {
|
||||
def main(args: Array[String]) {
|
||||
SpinalVerilog(new Counter)
|
||||
}
|
||||
}
|
||||
|
||||
object Sim {
|
||||
def main(args: Array[String]) {
|
||||
SimConfig.withWave.compile(new Counter).doSim {dut =>
|
||||
dut.clockDomain.forkStimulus(10)
|
||||
var tick = 0
|
||||
|
||||
while (tick < 10) {
|
||||
dut.clockDomain.waitSampling()
|
||||
tick += 1
|
||||
}
|
||||
|
||||
println(s"counter: ${dut.count.toBigInt}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue