1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

Merge pull request #345 from ThomasHornschuh/init_reset_fix

Init reset fix
This commit is contained in:
Christopher Felton 2020-12-02 06:49:55 -06:00 committed by GitHub
commit 54055f2950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 4 deletions

View File

@ -1865,7 +1865,7 @@ def _convertInitVal(reg, init):
if abs(init) < 2 ** 31:
v = '%sto_%s(%s, %s)%s' % (pre, vhd_tipe, init, len(reg), suf)
else:
v = '%s%s\'"%s"%s' % (pre, vhd_tipe, tobin(init, len(reg)), suf)
v = '%s%s\'("%s")%s' % (pre, vhd_tipe, tobin(init, len(reg)), suf)
else:
assert isinstance(init, EnumItemType)
v = init._toVHDL()

View File

@ -43,7 +43,7 @@ registerSimulator(
hdl="VHDL",
analyze="ghdl -a --std=08 --workdir=work pck_myhdl_%(version)s.vhd %(topname)s.vhd",
elaborate="ghdl -e --std=08 --workdir=work %(unitname)s",
simulate="ghdl -r --workdir=work %(unitname)s"
simulate="ghdl -r --std=08 --workdir=work %(unitname)s --ieee-asserts=disable"
)
registerSimulator(
@ -137,9 +137,9 @@ class _VerificationClass(object):
if isinstance(func, _Block):
if hdl == "VHDL":
inst = func.convert(hdl='VHDL')
inst = func.convert(hdl='VHDL', **kwargs)
else:
inst = func.convert(hdl='Verilog')
inst = func.convert(hdl='Verilog', **kwargs)
else:
if hdl == "VHDL":
inst = toVHDL(func, *args, **kwargs)

View File

@ -547,6 +547,53 @@ def test_memory_convert():
toVHDL.initial_values = pre_viv
@block
def init_reset_tb():
clk = Signal(bool(0))
reset = ResetSignal(0, active=1, isasync=False)
s_large = Signal(intbv(0xc0000000)[32:])
s_small = Signal(intbv(0xc)[32:])
@instance
def clkgen():
clk.next = 0
for n in range(10):
yield delay(10)
clk.next = not clk
raise StopSimulation()
@instance
def raise_reset():
yield clk.posedge
reset.next = 1
yield clk.posedge
reset.next = 0
@always_seq(clk.posedge,reset=reset)
def seq():
print(s_large)
print(s_small)
s_large.next = s_large + 1
s_small.next = s_small + 1
return instances()
def test_init_reset():
""" Test assignment of initial values of signals used in an always_seq block with a reset signal
Because the _convertInitVal in _toVHDL.py does special handling depending on the init value
the test takes this into account.
"""
inst = init_reset_tb()
assert conversion.verify(inst,initial_values=True) == 0
#def test_init_used_list():
# '''It should be the _init attribute of each element in the list
# that is used for initialisation