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:
commit
54055f2950
@ -1865,7 +1865,7 @@ def _convertInitVal(reg, init):
|
|||||||
if abs(init) < 2 ** 31:
|
if abs(init) < 2 ** 31:
|
||||||
v = '%sto_%s(%s, %s)%s' % (pre, vhd_tipe, init, len(reg), suf)
|
v = '%sto_%s(%s, %s)%s' % (pre, vhd_tipe, init, len(reg), suf)
|
||||||
else:
|
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:
|
else:
|
||||||
assert isinstance(init, EnumItemType)
|
assert isinstance(init, EnumItemType)
|
||||||
v = init._toVHDL()
|
v = init._toVHDL()
|
||||||
|
@ -43,7 +43,7 @@ registerSimulator(
|
|||||||
hdl="VHDL",
|
hdl="VHDL",
|
||||||
analyze="ghdl -a --std=08 --workdir=work pck_myhdl_%(version)s.vhd %(topname)s.vhd",
|
analyze="ghdl -a --std=08 --workdir=work pck_myhdl_%(version)s.vhd %(topname)s.vhd",
|
||||||
elaborate="ghdl -e --std=08 --workdir=work %(unitname)s",
|
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(
|
registerSimulator(
|
||||||
@ -137,9 +137,9 @@ class _VerificationClass(object):
|
|||||||
|
|
||||||
if isinstance(func, _Block):
|
if isinstance(func, _Block):
|
||||||
if hdl == "VHDL":
|
if hdl == "VHDL":
|
||||||
inst = func.convert(hdl='VHDL')
|
inst = func.convert(hdl='VHDL', **kwargs)
|
||||||
else:
|
else:
|
||||||
inst = func.convert(hdl='Verilog')
|
inst = func.convert(hdl='Verilog', **kwargs)
|
||||||
else:
|
else:
|
||||||
if hdl == "VHDL":
|
if hdl == "VHDL":
|
||||||
inst = toVHDL(func, *args, **kwargs)
|
inst = toVHDL(func, *args, **kwargs)
|
||||||
|
@ -547,6 +547,53 @@ def test_memory_convert():
|
|||||||
toVHDL.initial_values = pre_viv
|
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():
|
#def test_init_used_list():
|
||||||
# '''It should be the _init attribute of each element in the list
|
# '''It should be the _init attribute of each element in the list
|
||||||
# that is used for initialisation
|
# that is used for initialisation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user