简体   繁体   English

myhdl中的模块实例化

[英]Module Instantiation in myhdl

I'm currently looking into myHdl to see if it's worth using or not. 我目前正在研究myHdl,以查看是否值得使用。 However, I've come across a hiccup regarding the instantiation of modules. 但是,我在模块的实例化方面遇到了麻烦。 I've got two files, one that's a module and one that's the testbench. 我有两个文件,一个是模块,一个是测试台。 Inside the testbench, I've instantiated the module following the example they have on the website: http://www.myhdl.org/examples/flipflops.html 在测试平台内,我按照网站上提供的示例实例化了该模块: http : //www.myhdl.org/examples/flipflops.html

The instantiation specifically is this line: dff_inst = dff(q, d, clk) 具体实例化为以下行: dff_inst = dff(q, d, clk)

However, I get an error when I try to run the testbench: 但是,尝试运行测试台时出现错误:

Exception TypeError: 'isinstance() arg 2 must be a class, type, or tuple  of classes and types' in <generator object _LabelGenerator at 0x7f6070b2ea50> ignored

I assume this has something to do with the fact that I have two separate files, so my guess is that python isn't finding the dff module(since it's in a separate file). 我认为这与以下事实有关:我有两个单独的文件,所以我猜是python没有找到dff模块(因为它在单独的文件中)。 I tried adding in an import dff line, but that simply gave me a 'module' object is not callable type error, which makes sense. 我尝试添加一个import dff行,但这只是给了我一个'module' object is not callable类型错误,这很有意义。

Looking in the documentation, they don't have a full .py file, so I'm not sure how they're linking these testbenches with the module. 在文档中查找,他们没有完整的.py文件,因此我不确定他们如何将这些测试平台与模块链接。 They specifically mention a hierarchy system and being able to instantiate other modules, but I can't seem to get it to work. 他们特别提到了一个层次结构系统,并且能够实例化其他模块,但是我似乎无法使其正常工作。

From what I understand from documentation, it looks like they're just writing the testbench and the module in the same file. 据我从文档中了解到,看起来他们只是在同一文件中编写测试平台和模块。 However, to my understanding, it looks like they imply you can import modules, but I can't figure out how that's done. 但是,据我了解,它们似乎暗示您可以导入模块,但是我不知道该怎么做。 Is there just some simple thing I'm overlooking? 我只是忽略了一些简单的事情吗?

经过一些试验之后,似乎我只需要使用以下命令: from dff import dff ,这很有意义。

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

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