summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenry Cook2015-08-10 14:45:58 -0700
committerHenry Cook2015-08-10 14:45:58 -0700
commit0d2f241a7ffbadaaa2765b504d98442613766c59 (patch)
tree5d094b1d7872dd71e4ee0326371d7d2ccd260ffc /src
parent27c4e0fc6af6379d25990b90a0382774bc7c4765 (diff)
Parameter cleanup
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Chisel/Core.scala15
-rw-r--r--src/main/scala/Chisel/Parameters.scala13
2 files changed, 9 insertions, 19 deletions
diff --git a/src/main/scala/Chisel/Core.scala b/src/main/scala/Chisel/Core.scala
index 4030c549..adfc8f0d 100644
--- a/src/main/scala/Chisel/Core.scala
+++ b/src/main/scala/Chisel/Core.scala
@@ -60,6 +60,12 @@ private object DynamicContext {
def paramsScope[T](p: Parameters)(body: => T): T = {
currentParamsVar.withValue(p)(body)
}
+ def paramsScope[T,S](mask: Map[S,Any])(body: => T): T = {
+ paramsScope(currentParamsVar.value.alter(mask))(body)
+ }
+ def paramsScope[T](mask: PartialFunction[Any,Any])(body: => T): T = {
+ paramsScope(currentParamsVar.value.alterPartial(mask))(body)
+ }
}
private object Builder {
@@ -283,7 +289,6 @@ abstract class Data(dirArg: Direction) extends Id {
if (_mod ne null)
_mod.addNode(this)
- _mod.addNode(this)
def params = DynamicContext.getParams
def toType: Kind
@@ -949,8 +954,8 @@ class Bundle extends Aggregate(NO_DIR) {
}
object Module {
- def apply[T <: Module](bc: => T)(implicit currParams: Parameters = DynamicContext.getParams): T = {
- DynamicContext.paramsScope(currParams.push) {
+ def apply[T <: Module](bc: => T)(implicit currParams: Parameters = DynamicContext.getParams.push): T = {
+ DynamicContext.paramsScope(currParams) {
val m = DynamicContext.moduleScope{ bc.setRefs() }
val ports = m.computePorts
Builder.components += Component(m.name, ports, m._commands)
@@ -959,8 +964,7 @@ object Module {
}.connectImplicitIOs()
}
def apply[T <: Module](m: => T, f: PartialFunction[Any,Any]): T = {
- val q = DynamicContext.getParams.alterPartial(f)
- apply(m)(q)
+ apply(m)(DynamicContext.getParams.alterPartial(f))
}
}
@@ -974,7 +978,6 @@ abstract class Module(_clock: Clock = null, _reset: Bool = null) extends Id {
val name = Builder.globalNamespace.name(getClass.getName.split('.').last)
def params = DynamicContext.getParams
- params.path = this.getClass :: params.path //TODO: make immutable?
def io: Bundle
val clock = Clock(INPUT)
diff --git a/src/main/scala/Chisel/Parameters.scala b/src/main/scala/Chisel/Parameters.scala
index 2c9c7f69..34a03f51 100644
--- a/src/main/scala/Chisel/Parameters.scala
+++ b/src/main/scala/Chisel/Parameters.scala
@@ -135,8 +135,6 @@ object Dump {
// objects given to the user in mask functions (site,here,up)
abstract class View {
- // the list of classes in our current path down the heirarchy
- def path: List[Class[_]]
protected val deftSite: View // when views are queried without a specifying a site this is the default
@@ -172,7 +170,6 @@ final case class ViewSym(view:View) {
// internal type to represent functions that evaluate parameter values
abstract class _Lookup {
- var path:List[Class[_]] = null
def apply[T](pname:Any, site:View):Ex[T]
@@ -180,7 +177,6 @@ abstract class _Lookup {
final def push() = {
val me = this
new _Lookup {
- this.path = me.path
def apply[T](pname:Any, site:View) = me.apply(pname, site)
}
}
@@ -217,7 +213,6 @@ abstract class World(
val _knobs = new mutable.HashSet[Any]
abstract class _View extends View {
val look: _Lookup
- def path = look.path
def apply[T](pname:Any, site:View):T = {
_eval(look(pname, site).asInstanceOf[Ex[T]])
@@ -261,7 +256,6 @@ abstract class World(
// the top level lookup
def _topLook():_Lookup = {
class TopLookup extends _Lookup {
- this.path = Nil
def apply[T](pname:Any, site:View):Ex[T] = {
val here = _otherView(this, site)
@@ -429,12 +423,6 @@ final class Parameters(
def push():Parameters =
new Parameters(_world, _look.push())
- // parameter's paths should be immutable but I foresee that not being sufficient
- // when integrated into the chisel Module factory.
- def path = _look.path
- def path_=(x:List[Class[_]]) =
- _look.path = x
-
def apply[T](field:Any):T =
_world._eval(_look(field, _site())).asInstanceOf[T]
@@ -449,7 +437,6 @@ final class Parameters(
private def _alter(mask:(/*field*/Any,/*site*/View,/*here*/View,/*up*/View)=>Any) = {
class KidLookup extends _Lookup {
- this.path = _look.path
def apply[T](f:Any, site:View):Ex[T] = {
val here = _world._otherView(this, site)