diff options
| author | Albert Magyar | 2018-12-21 11:57:23 -0800 |
|---|---|---|
| committer | GitHub | 2018-12-21 11:57:23 -0800 |
| commit | 1d1798cfd03f23896b7ea6203a1569da9532a939 (patch) | |
| tree | a35af58e87be7f48ae592d50b52e078d6f507458 /src | |
| parent | 3433f8f8a82c3b129456e9512dd2cf442a6042f6 (diff) | |
Small convenience tweaks to IR/WIR APIs (#961)
* Seal Direction trait
* Add WRef factories for ports and instances
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/WIR.scala | 5 | ||||
| -rw-r--r-- | src/main/scala/firrtl/ir/IR.scala | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/WIR.scala b/src/main/scala/firrtl/WIR.scala index b96cd253..a5d2571d 100644 --- a/src/main/scala/firrtl/WIR.scala +++ b/src/main/scala/firrtl/WIR.scala @@ -40,6 +40,11 @@ object WRef { def apply(reg: DefRegister): WRef = new WRef(reg.name, reg.tpe, RegKind, UNKNOWNGENDER) /** Creates a WRef from a Node */ def apply(node: DefNode): WRef = new WRef(node.name, node.value.tpe, NodeKind, MALE) + /** Creates a WRef from a Port */ + def apply(port: Port): WRef = new WRef(port.name, port.tpe, PortKind, UNKNOWNGENDER) + /** Creates a WRef from a WDefInstance */ + def apply(wi: WDefInstance): WRef = new WRef(wi.name, wi.tpe, InstanceKind, UNKNOWNGENDER) + /** Creates a WRef from an arbitrary string name */ def apply(n: String, t: Type = UnknownType, k: Kind = ExpKind): WRef = new WRef(n, t, k, UNKNOWNGENDER) } case class WSubField(expr: Expression, name: String, tpe: Type, gender: Gender) extends Expression { diff --git a/src/main/scala/firrtl/ir/IR.scala b/src/main/scala/firrtl/ir/IR.scala index cdf8e194..19ee56ca 100644 --- a/src/main/scala/firrtl/ir/IR.scala +++ b/src/main/scala/firrtl/ir/IR.scala @@ -607,7 +607,7 @@ case object UnknownType extends Type { } /** [[Port]] Direction */ -abstract class Direction extends FirrtlNode +sealed abstract class Direction extends FirrtlNode case object Input extends Direction { def serialize: String = "input" } |
