Skip to content

Instantly share code, notes, and snippets.

@iori-yja
Last active August 29, 2015 14:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iori-yja/f91bcd2985c5b0cfe720 to your computer and use it in GitHub Desktop.
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