blob: a6cd270af4681a27e14aa3536afd620545ccbf1c (
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
|
// See LICENSE for license details.
package firrtl.features
import firrtl.Namespace
import firrtl.transforms.ManipulateNames
import scala.reflect.ClassTag
/** Parent of transforms that do change the letter case of names in a FIRRTL circuit */
abstract class LetterCaseTransform[A <: ManipulateNames[_] : ClassTag] extends ManipulateNames[A] {
protected def newName: String => String
final def manipulate = (a: String, ns: Namespace) => newName(a) match {
case `a` => None
case b => Some(ns.newName(b))
}
}
/** Convert all FIRRTL names to lowercase */
final class LowerCaseNames extends LetterCaseTransform[LowerCaseNames] {
override protected def newName = (a: String) => a.toLowerCase
}
/** Convert all FIRRTL names to UPPERCASE */
final class UpperCaseNames extends LetterCaseTransform[UpperCaseNames] {
override protected def newName = (a: String) => a.toUpperCase
}
|