Re: the usage of val foo = new Foo { val x = 3 }
:
I think rewriting object foo extends Foo { val x = 3 }
is hard for us Chisel people for multiple reasons:
- What we actually do is
val foo = func(new Foo { val x = 3 })
wherefunc
isdef func[T](in: T): T
. Writingfunc(object Foo { ... })
is not legal. - This pattern is in our hello world. It appears in almost every Chisel user’s code.
Searching public github repos shows > 4k usages. - This is a backwards compatibility problem for all of our users, and it seems onerous to make a code-rewriter and require everyone to use it.
- More generally, this pattern is useful and important for Chisel’s goals as a hardware DSL. From our experience, structural typing is a very familiar paradigm for Verilog/VHDL users- we try to add more safety while still giving a familiar look and feel.