config: support default values for Field[T] keys
This commit is contained in:
parent
09d8d476c5
commit
655a08f12e
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
package freechips.rocketchip.config
|
package freechips.rocketchip.config
|
||||||
|
|
||||||
abstract class Field[T]
|
abstract class Field[T] private (val default: Option[T])
|
||||||
|
{
|
||||||
|
def this() = this(None)
|
||||||
|
def this(x: T) = this(Some(x))
|
||||||
|
}
|
||||||
|
|
||||||
abstract class View {
|
abstract class View {
|
||||||
final def apply[T](pname: Field[T]): T = apply(pname, this)
|
final def apply[T](pname: Field[T]): T = apply(pname, this)
|
||||||
@ -42,7 +46,7 @@ class Config(p: Parameters) extends Parameters {
|
|||||||
// Internal implementation:
|
// Internal implementation:
|
||||||
|
|
||||||
private class TerminalView extends View {
|
private class TerminalView extends View {
|
||||||
def find[T](pname: Field[T], site: View): Option[T] = None
|
def find[T](pname: Field[T], site: View): Option[T] = pname.default
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChainView(head: Parameters, tail: View) extends View {
|
private class ChainView(head: Parameters, tail: View) extends View {
|
||||||
|
Loading…
Reference in New Issue
Block a user