Initialize class depending on config value

家住魔仙堡 提交于 2019-12-12 02:36:23

问题


I would like to find out how it is possible to initialize a Module, depending on a value. So I have a config.extend value which will decide if the core will instantiate of the Core or ExtendedCore module.

However I am getting the error "value := is not a member of Sodor.core".

val extend = 1

val core = Module(new Core(data_address))

if(extend==1){
   core := Module(new ExtendedCore(data_address))
}

What is the proper way to intialize a Module depending on the statement, like in this case? Thanks.


回答1:


:= is the connection operator in Chisel. It is used for connecting Wires and Registers. What you really want to do is conditionally instantiate different Modules at elaboration time (ie. with Scala constructs not Chisel constructs).

Try the following:

val extend = 1

val core = if (extend == 1) Module(new ExtendedCore(data_address))
           else Module(new Core(data_address))


来源:https://stackoverflow.com/questions/41720320/initialize-class-depending-on-config-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!