Instantly share code, notes, and snippets.

@iori-yja /LED.scala
Last active Aug 29, 2015

Embed
What would you like to do?
scalaVersion := "2.10.2"
addSbtPlugin("com.github.scct" % "sbt-scct" % "0.2.1")
libraryDependencies += "edu.berkeley.cs" %% "chisel" % "latest.release"
import Chisel._
class LEDModule extends Module {
val io = new Bundle {val a = UInt(OUTPUT,8)}
val a = Reg(init = UInt(7,8))
val speed = UInt(20000000)
val count = Reg(init = speed)
count := count - UInt(1)
when (count === UInt(0)) {
a := a + UInt(1)
count := speed
}
/* if type unmached a with io.a, runtime error ocurs */
io.a := a;
}
class LEDTests(c: LEDModule) extends Tester(c) {
step(40000000)
/* Cant test Bool signal with expect(). Not implemented. */
// expect(c.io.a, Bool(false))
// expect(c.io.a, Bool(true))
}
object LED {
def main(args: Array[String]): Unit = {
val tutArgs = args.slice(1, args.length)
chiselMainTest(tutArgs, () => Module(new LEDModule())) {
c => new LEDTests(c) }
}
}
module ledtest(
input inclk,
input res,
output [7:0] led
);
LEDModule lm0(
.clk(inclk),
.reset(~res),
.io_a(led)
);
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment