2

I'm currently looking into myHdl to see if it's worth using or not. 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

The instantiation specifically is this line: 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). I tried adding in an import dff line, but that simply gave me a 'module' object is not callable type error, which makes sense.

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. 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?

Jpwang
  • 143
  • 1
  • 12

1 Answers1

3

After experimenting a bit, it seems like I just need to use the following command: from dff import dff, which makes a lot of sense.

Jpwang
  • 143
  • 1
  • 12