blob: d17f0d59a3e61e3ad6f93e25f5c19d8a621c2417 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// SPDX-License-Identifier: Apache-2.0
package firrtl.passes
package memlib
import firrtl.Mappers._
import firrtl.ir._
/** Annotates sequential memories that are candidates for macro replacement.
* Requirements for macro replacement:
* - read latency and write latency of one
* - only one readwrite port or write port
* - zero or one read port
* - undefined read-under-write behavior
*/
object ToMemIR extends Pass {
/** Only annotate memories that are candidates for memory macro replacements
* i.e. rw, w + r (read, write 1 cycle delay) and read-under-write "undefined."
*/
import ReadUnderWrite._
def updateStmts(s: Statement): Statement = s match {
case m @ DefMemory(_, _, _, _, 1, 1, r, w, rw, Undefined) if (w.length + rw.length) == 1 && r.length <= 1 =>
DefAnnotatedMemory(m)
case sx => sx.map(updateStmts)
}
def annotateModMems(m: DefModule) = m.map(updateStmts)
def run(c: Circuit) = c.copy(modules = c.modules.map(annotateModMems))
}
|