简体   繁体   English

从列表生成凿子模块IO接口

[英]Generating Chisel Module IO Interface From a List

I would like to generate a Module IO interface from a spec I have stored in a scala variable. 我想从存储在scala变量中的规范生成Module IO接口。

I would like to produce this class definition: 我想生成这个类定义:

class AddIfc extends Module {
   val io = IO(new Bundle {
     val a = Input(UInt(8.W))
     val b = Input(UInt(8.W))
     val o = Output(UInt(8.W))
   })
}

from something like a list of tuples: 从像元组列表的东西:

List( ("a", "in", 8), ("b", "in", 8), ("o", "out", 8))

I can imagine building an AST and evaluating it using some of the reflection capabilities in scala. 我可以想象使用scala中的一些反射功能构建AST并对其进行评估。 Has anyone done this and have an example to show? 有没有人这样做并有一个例子来展示?

Take a look at Record (the parent class of Bundle). 看一下Record (Bundle的父类)。 They're a bit more advanced because you have to implement elements (rather than reflection doing it for you in Bundle), and you have to implement cloneType. 它们有点高级,因为你必须实现元素(而不是在Bundle中为你做反射),你必须实现cloneType。

There is an example in the Chisel tests . 在Chisel测试中有一个例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM