This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.10.2" | |
addSbtPlugin("com.github.scct" % "sbt-scct" % "0.2.1") | |
libraryDependencies += "edu.berkeley.cs" %% "chisel" % "latest.release" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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