Synthesize Mem to Block RAM

210 views
Skip to first unread message

Arjun Ramaswami

unread,
Jun 22, 2016, 9:57:53 AM6/22/16
to chisel-users
Hi everyone,

How can I describe a Mem module in Chisel such that it synthesizes to a Block RAM and not a distributed RAM in an FGPA? 

Looking forward to your replies.

Regards,
Arjun

Martin Schoeberl

unread,
Jul 18, 2016, 9:48:38 AM7/18/16
to chisel...@googlegroups.com
Hi Atjun,

Block RAMs today need input registers for all ports. Make sure that your read address goes through a register.


with the following lines of code relevant to you:

  val mem = Mem(Bits(width = width), size)

  // write
  when(io.wrEna === Bits(1)) {
    mem(io.wrAddr) := io.wrData
  }

  // read
  val rdAddrReg = Reg(next = io.rdAddr)
  io.rdData := mem(rdAddrReg)

Cheers,
Martin

--
You received this message because you are subscribed to the Google Groups "chisel-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
To post to this group, send email to chisel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/b9e28b9f-31de-4457-95d4-f656aa991811%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages