Dear All,
Well I try something that is simplistic, but I have a low mileage on Myhdl. If one of the senior here around could have a look and explain the beginner where he is mistaken he would be very thankful
First code simulate but doesn’t convert:
def Stream(sig_01, period, idx, buffer, txdata):
sig_01.next = 0
yield delay(period)
while(idx < len(buffer)):
txdata.next = buffer[int(idx)]
idx.next = idx + 1
yield delay(period)
idx.next = 0
sig_01.next = 1
yield delay(2*period)
@block
def Top_verif_01(RSTn, ENBn, TXD):
''' Top signals '''
rstn = ResetSignal(1, active=0, isasync = True)
enbn = Signal(bool(1))
txd = Signal(bool(0))
''' internal signals '''
depth = 256
txdata =Signal(intbv(0)[8:])
idx = Signal(intbv(0, 0, depth ))
sys_clk = Signal(bool(0))
frequency = 24e6 # Frequency 24MHz
period = int(1./frequency * 1e9) # put the period in nano second
half_period = int(period/2)
buffer = ( 0x83, 0x55, 0xA1, 0xFF, 0xF1 )
buffer1 = ( 0x71, 0x88 )
@instance
def signal_clk():
while True:
sys_clk.next = not sys_clk
yield delay(half_period)
@always_comb
def slice_shadower():
RSTn.next = rstn
ENBn.next = enbn
TXD.next = txd
@instance
def tx_signal():
rstn.next = 1
enbn.next = 1
yield delay(2 * period)
rstn.next = 0
yield delay(4 * period)
rstn.next = 1
yield delay(2 * period)
yield(Stream(enbn, period, idx, buffer, txdata))
print('1st Stream')
yield(Stream(enbn, period, idx, buffer1, txdata))
print('2snd Stream')
raise StopSimulation
return instances()
Second code removing the def stream() and replacing the code inside the block does simulate and convert. Why ? For a good reason that I am missing yet.
#yield(Stream(enbn, period, idx, buffer, txdata))
enbn.next = 0
yield delay(period)
while(idx < len(buffer)):
txdata.next = buffer[int(idx)]
idx.next = idx + 1
yield delay(period)
idx.next = 0
enbn.next = 1
yield delay(2*period)
print('1st Stream')
enbn.next = 0
yield delay(period)
while(idx < len(buffer1)):
txdata.next = buffer1[int(idx)]
idx.next = idx + 1
yield delay(period)
idx.next = 0
enbn.next = 1
yield delay(2*period)
#yield(Stream(enbn, period, idx, buffer1, txdata))
print('2snd Stream')
Test results and converts
--------------------------------------------------------------------------------------------
test_top (__main__.Test) ... 1st Stream
2snd Stream
ok
test_top_convert (__main__.Test) ... C:\Py36-32_VirtEnv\VirtEnv_02\lib\site-packages\myhdl\conversion\_toVerilog.py:327: ToVerilogWarning: Signal is driven but not read: txdata
category=ToVerilogWarning
C:\Py36-32_VirtEnv\VirtEnv_02\lib\site-packages\myhdl\conversion\_toVerilog.py:349: ToVerilogWarning: Signal is not driven: txd
category=ToVerilogWarning
ok
----------------------------------------------------------------------
Ran 2 tests in 0.094s
OK