Hello,
I am new to MyHDL and trying to understand what’s possible to do with it compared to VHDL. In the past I did some work in VHDL on FPGAs.
My question: I want to put signals into objects and use them as interfaces between modules (similar like the class Ififobus in rhea). I want to define methods in the class that would take care of common operations on the signals. Of course in the end I want to export everything to VHDL and run on FPGA
But my code experiments indicate MyHDL code generator does not understand method calls, nor function calls with object arguments.
This is my testing code:
from myhdl import Signal, delay, Simulation, always_comb, instance, intbv, bin, toVerilog, modbv, ResetSignal, always_seq, toVHDL, block
m = 8
@block
def IncStru3(count, enable, clock, reset):
class Subcluster:
cnt2 = Signal(modbv(0)[m:])
class Cluster:
cnt1 = Signal(modbv(0)[m:])
sc = Subcluster()
# experiment 1
def doThingMethod(self):
self.cnt1.next = r.cnt1 + 1
self.sc.cnt2.next = r.sc.cnt2 - 1
# experiment 2
def doThingClassArg(r):
r.cnt1.next = r.cnt1 + 1
r.sc.cnt2.next = r.sc.cnt2 - 1
# experiment 3
def doThingSignalArg(cnt1, cnt2):
cnt1.next = cnt1 + 1
cnt2.next = cnt2 - 1
r = Cluster()
@always_seq(clock.posedge, reset=reset)
def incLogic():
if enable:
# experiment 4: works fine
# r.cnt1.next = r.cnt1 + 1
# r.sc.cnt2.next = r.sc.cnt2 - 1
#
doThingSignalArg(r.cnt1, r.sc.cnt2) # works fine
# doThingClassArg(r) # error: Unsupported attribute: cnt1
# r.doThingMethod() # error: Not supported: method call: 'doThingMethod'
@always_comb
def outLogic():
count.next = r.cnt1 | r.sc.cnt2
return incLogic, outLogic
count = Signal(modbv(0)[m:])
enable = Signal(bool(0))
clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True)
inc_inst = IncStru3(count, enable, clock, reset)
inc_inst.convert(hdl="VHDL", path="inc_sy")
inc_inst.convert(hdl="Verilog", path="inc_sy")
I use MyHDL 1.0dev (from github). In the example the functions doThingClassArg() and doThingMethod() fail in convertsion. Am I doing something wrong?
Regards,
Jaroslav