Skip to content

Instantly share code, notes, and snippets.

@sux2mfgj
Created October 25, 2016 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sux2mfgj/06d941328baad1c607a87b46b03f4029 to your computer and use it in GitHub Desktop.
Save sux2mfgj/06d941328baad1c607a87b46b03f4029 to your computer and use it in GitHub Desktop.
import Chisel._
class MemTest(mem_width: Int = 8, ram_size: Int = 64) extends Module {
val io = new Bundle {
val read_value = Bits(width = mem_width).asOutput
val write_value = Bits(width = mem_width).asInput
val w_addr = Bits(width = mem_width).asInput
val r_addr = Bits(width = mem_width).asInput
val write_enable = Bool(INPUT)
}
val ram = Mem(Bits(width = mem_width), ram_size)
val out = Reg(Bits(width = mem_width))
io.read_value := out
when(io.write_enable) {
ram(io.w_addr) := io.write_value
}
when(Bool(true)) {
out := ram(io.r_addr)
}
}
object Run {
def main(args: Array[String]) {
chiselMain(args, () => Module(new MemTest))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment