I don't get how to convert to VHDL


#1

I was thinking, there should be a program called myhdl working like:

$ myhdl vhdl hello1.py
…converted to VHDL: hello1.vhd

I know the link:
http://docs.myhdl.org/en/stable/manual/conversion.html

I read the full page and still don’t know how to convert MyHDL-Code to VHDL. I’m using example code from the tutorial, which outputs:

$ python3 hello1.py
10 Hello World!
30 Hello World!
50 Hello World!
<class ‘myhdl._SuspendSimulation’>: Simulated 50 timesteps

But what am I seeing there? What does this output mean?
How to convert MyHDL-Python-Code to VHDL, seriously?

Actually, I’m new to Python, too. Do I overlook something? I’m using Cygwin shell on Windows.


#2

I guess your hello1.py is something close to this:

from myhdl import block, delay, instance, now

@block
def HelloWorld():

    @instance
    def say_hello():
        while True:
            yield delay(10)
            print("%s Hello World!" % now())
            yield delay(10)

    return say_hello


inst = HelloWorld()
inst.run_sim(50)

The last line simulates the design for 50 steps. If you want to convert to VHDL after the simulation, you would add the following line:

inst.convert('VHDL')

Bear in mind, though, that not all code is convertible, and all convertible code is not synthesizable.


#3

OK, that’s working. But

10 Hello World!
30 Hello World!
50 Hello World!

tells me nothing. Is there a way to plot this simulation with ModelSim or another tool?


#4

ModelSim will not tell you anything more, since that’s all the code does. If you add some logic, you can simulate the converted VHDL (or Verilog) in ModelSim. You can also use GTKWave or another VCD viewer to view the signals. Just add the following line before the run_sim() call:

inst.config_sim(backend='myhdl', trace=True)

(But there are no signals in this case. You need to add some logic first.)