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

Merge pull request #267 from alexforencich/master

Rename async to isasync to resolve conflict with python 3.7
This commit is contained in:
Keerthan Jaic 2018-08-22 23:50:47 -07:00 committed by GitHub
commit 49e90cd21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 40 additions and 42 deletions

View File

@ -17,10 +17,8 @@ env:
- CI_TARGET=iverilog - CI_TARGET=iverilog
- CI_TARGET=ghdl - CI_TARGET=ghdl
# Remove when py37 bugs are fixed
matrix: matrix:
allow_failures: allow_failures:
- python: "3.7"
- python: "pypy3.5" - python: "pypy3.5"

View File

@ -276,13 +276,13 @@ Regular signals
This method returns a :class:`_SliceSignal` shadow signal. This method returns a :class:`_SliceSignal` shadow signal.
.. class:: ResetSignal(val, active, async) .. class:: ResetSignal(val, active, isasync)
This Signal subclass defines reset signals. *val*, *active*, and *async* This Signal subclass defines reset signals. *val*, *active*, and *isasync*
are mandatory arguments. are mandatory arguments.
*val* is a boolean value that specifies the intial value, *val* is a boolean value that specifies the intial value,
*active* is a boolean value that specifies the active level. *active* is a boolean value that specifies the active level.
*async* is a boolean value that specifies the reset style: *isasync* is a boolean value that specifies the reset style:
asynchronous (``True``) or synchronous (``False``). asynchronous (``True``) or synchronous (``False``).
This class should be used in conjunction with the :func:`always_seq` This class should be used in conjunction with the :func:`always_seq`

View File

@ -107,10 +107,10 @@ functionality. It detects which signals need to be reset, and uses their
initial values as the reset values. The reset signal itself needs to be initial values as the reset values. The reset signal itself needs to be
specified as a :class:`ResetSignal` object. For example:: specified as a :class:`ResetSignal` object. For example::
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
The first parameter specifies the initial value. The *active* parameter The first parameter specifies the initial value. The *active* parameter
specifies the value on which the reset is active, and the *async* specifies the value on which the reset is active, and the *isasync*
parameter specifies whether it is an asychronous (``True``) or a parameter specifies whether it is an asychronous (``True``) or a
synchronous (``False``) reset. If no reset is needed, you can assign synchronous (``False``) reset. If no reset is needed, you can assign
``None`` to the *reset* parameter in the :func:`always_seq` parameter. ``None`` to the *reset* parameter in the :func:`always_seq` parameter.

View File

@ -32,7 +32,7 @@ def main():
graycnt = Signal(modbv(0)[width:]) graycnt = Signal(modbv(0)[width:])
enable = Signal(bool()) enable = Signal(bool())
clock = Signal(bool()) clock = Signal(bool())
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
toVerilog(GrayIncReg, graycnt, enable, clock, reset, width) toVerilog(GrayIncReg, graycnt, enable, clock, reset, width)
toVHDL(GrayIncReg, graycnt, enable, clock, reset, width) toVHDL(GrayIncReg, graycnt, enable, clock, reset, width)

View File

@ -10,7 +10,7 @@ m = 8
count = Signal(modbv(0)[m:]) count = Signal(modbv(0)[m:])
enable = Signal(bool(0)) enable = Signal(bool(0))
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
inc_inst = inc(count, enable, clock, reset) inc_inst = inc(count, enable, clock, reset)
inc_inst = toVerilog(inc, count, enable, clock, reset) inc_inst = toVerilog(inc, count, enable, clock, reset)

View File

@ -6,7 +6,7 @@ def convert_gray_inc_reg(hdl, width=8):
graycnt = Signal(modbv(0)[width:]) graycnt = Signal(modbv(0)[width:])
enable = Signal(bool()) enable = Signal(bool())
clock = Signal(bool()) clock = Signal(bool())
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
inst = gray_inc_reg(graycnt, enable, clock, reset, width) inst = gray_inc_reg(graycnt, enable, clock, reset, width)
inst.convert(hdl) inst.convert(hdl)

View File

@ -10,7 +10,7 @@ def convert_inc(hdl):
count = Signal(modbv(0)[m:]) count = Signal(modbv(0)[m:])
enable = Signal(bool(0)) enable = Signal(bool(0))
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
inc_1 = inc(count, enable, clock, reset) inc_1 = inc(count, enable, clock, reset)

View File

@ -10,7 +10,7 @@ def testbench():
sof = Signal(bool(0)) sof = Signal(bool(0))
sync_flag = Signal(bool(0)) sync_flag = Signal(bool(0))
clk = Signal(bool(0)) clk = Signal(bool(0))
reset_n = ResetSignal(1, active=ACTIVE_LOW, async=True) reset_n = ResetSignal(1, active=ACTIVE_LOW, isasync=True)
state = Signal(t_state.SEARCH) state = Signal(t_state.SEARCH)
frame_ctrl_0 = framer_ctrl(sof, state, sync_flag, clk, reset_n) frame_ctrl_0 = framer_ctrl(sof, state, sync_flag, clk, reset_n)

View File

@ -14,7 +14,7 @@ def testbench():
count = Signal(modbv(0)[m:]) count = Signal(modbv(0)[m:])
enable = Signal(bool(0)) enable = Signal(bool(0))
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
inc_1 = inc(count, enable, clock, reset) inc_1 = inc(count, enable, clock, reset)

View File

@ -65,7 +65,7 @@ def tb(uart_tx):
tx_byte = Signal(intbv(0)[8:]) tx_byte = Signal(intbv(0)[8:])
tx_clk = Signal(bool(0)) tx_clk = Signal(bool(0))
# tx_rst = Signal(bool(1)) # tx_rst = Signal(bool(1))
tx_rst = ResetSignal(1, active=0, async=True) tx_rst = ResetSignal(1, active=0, isasync=True)
uart_tx_inst = uart_tx(tx_bit, tx_valid, tx_byte, tx_clk, tx_rst) uart_tx_inst = uart_tx(tx_bit, tx_valid, tx_byte, tx_clk, tx_rst)

View File

@ -45,7 +45,7 @@ _error.EmbeddedFunction = "embedded functions in always_seq function not support
class ResetSignal(_Signal): class ResetSignal(_Signal):
def __init__(self, val, active, async): def __init__(self, val, active, isasync):
""" Construct a ResetSignal. """ Construct a ResetSignal.
This is to be used in conjunction with the always_seq decorator, This is to be used in conjunction with the always_seq decorator,
@ -53,7 +53,7 @@ class ResetSignal(_Signal):
""" """
_Signal.__init__(self, bool(val)) _Signal.__init__(self, bool(val))
self.active = bool(active) self.active = bool(active)
self.async = async self.isasync = isasync
def always_seq(edge, reset): def always_seq(edge, reset):
@ -91,8 +91,8 @@ class _AlwaysSeq(_Always):
if reset is not None: if reset is not None:
self.genfunc = self.genfunc_reset self.genfunc = self.genfunc_reset
active = self.reset.active active = self.reset.active
async = self.reset.async isasync = self.reset.isasync
if async: if isasync:
if active: if active:
senslist.append(reset.posedge) senslist.append(reset.posedge)
else: else:

View File

@ -1838,12 +1838,12 @@ class _ConvertAlwaysSeqVisitor(_ConvertVisitor):
senslist = self.tree.senslist senslist = self.tree.senslist
edge = senslist[0] edge = senslist[0]
reset = self.tree.reset reset = self.tree.reset
async = reset is not None and reset.async isasync = reset is not None and reset.isasync
sigregs = self.tree.sigregs sigregs = self.tree.sigregs
varregs = self.tree.varregs varregs = self.tree.varregs
self.write("%s: process (" % self.tree.name) self.write("%s: process (" % self.tree.name)
self.write(edge.sig) self.write(edge.sig)
if async: if isasync:
self.write(', ') self.write(', ')
self.write(reset) self.write(reset)
self.write(") is") self.write(") is")
@ -1853,7 +1853,7 @@ class _ConvertAlwaysSeqVisitor(_ConvertVisitor):
self.writeline() self.writeline()
self.write("begin") self.write("begin")
self.indent() self.indent()
if not async: if not isasync:
self.writeline() self.writeline()
self.write("if %s then" % edge._toVHDL()) self.write("if %s then" % edge._toVHDL())
self.indent() self.indent()
@ -1870,7 +1870,7 @@ class _ConvertAlwaysSeqVisitor(_ConvertVisitor):
self.write("%s := %s;" % (n, _convertInitVal(reg, init))) self.write("%s := %s;" % (n, _convertInitVal(reg, init)))
self.dedent() self.dedent()
self.writeline() self.writeline()
if async: if isasync:
self.write("elsif %s then" % edge._toVHDL()) self.write("elsif %s then" % edge._toVHDL())
else: else:
self.write("else") self.write("else")
@ -1881,7 +1881,7 @@ class _ConvertAlwaysSeqVisitor(_ConvertVisitor):
self.writeline() self.writeline()
self.write("end if;") self.write("end if;")
self.dedent() self.dedent()
if not async: if not isasync:
self.writeline() self.writeline()
self.write("end if;") self.write("end if;")
self.dedent() self.dedent()

View File

@ -28,7 +28,7 @@ def gray_counter (clk, reset, enable, gray_count):
return comb, seq return comb, seq
clk = Signal(bool(0)) clk = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
enable = Signal(bool(0)) enable = Signal(bool(0))
gray_count = Signal(intbv(0)[8:]) gray_count = Signal(intbv(0)[8:])

View File

@ -31,7 +31,7 @@ def issue_13(reset, clk, d, en, q):
def test_issue_13(): def test_issue_13():
reset = ResetSignal(0, active=1, async=False) reset = ResetSignal(0, active=1, isasync=False)
clk = Signal(bool(0)) clk = Signal(bool(0))
d = Signal(intbv(0)[32:]) d = Signal(intbv(0)[32:])
en = Signal(bool(0)) en = Signal(bool(0))

View File

@ -16,7 +16,7 @@ def shifter(reset, clock, opa, opb, result):
def convert(): def convert():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=True, async=True) reset = ResetSignal(0, active=True, isasync=True)
opa = Signal(intbv(0)[4:]) opa = Signal(intbv(0)[4:])
opb = Signal(intbv(0)[4:]) opb = Signal(intbv(0)[4:])

View File

@ -26,7 +26,7 @@ def mpegChannel(clk, rst):
def test_issue_40(): def test_issue_40():
clk = Signal(bool(0)) clk = Signal(bool(0))
rst = ResetSignal(0, active=1, async=True) rst = ResetSignal(0, active=1, isasync=True)
assert conversion.analyze(mpegChannel, clk, rst) == 0 assert conversion.analyze(mpegChannel, clk, rst) == 0

View File

@ -308,7 +308,7 @@ def initial_value_list_bench(initial_vals, **kwargs):
def initial_value_mem_convert_bench(): def initial_value_mem_convert_bench():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
wr = Signal(bool(0)) wr = Signal(bool(0))
wrd = Signal(intbv(0, min=0, max=32)) wrd = Signal(intbv(0, min=0, max=32))
rdd = Signal(intbv(0, min=0, max=32)) rdd = Signal(intbv(0, min=0, max=32))

View File

@ -38,7 +38,7 @@ def two_level(clock, reset, ia, ib):
@block @block
def c_testbench_one(): def c_testbench_one():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
ia, ib = MyIntf(), MyIntf() ia, ib = MyIntf(), MyIntf()
tb_dut = one_level(clock, reset, ia, ib) tb_dut = one_level(clock, reset, ia, ib)
@ -70,7 +70,7 @@ def c_testbench_one():
@block @block
def c_testbench_two(): def c_testbench_two():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
ia, ib = MyIntf(), MyIntf() ia, ib = MyIntf(), MyIntf()
tb_dut = two_level(clock, reset, ia, ib) tb_dut = two_level(clock, reset, ia, ib)
@ -101,7 +101,7 @@ def c_testbench_two():
def test_one_level_analyze(): def test_one_level_analyze():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
ia, ib = MyIntf(), MyIntf() ia, ib = MyIntf(), MyIntf()
inst = one_level(clock, reset, ia, ib) inst = one_level(clock, reset, ia, ib)
assert inst.analyze_convert() == 0 assert inst.analyze_convert() == 0
@ -114,7 +114,7 @@ def test_one_level_verify():
def test_two_level_analyze(): def test_two_level_analyze():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
ia, ib = MyIntf(), MyIntf() ia, ib = MyIntf(), MyIntf()
inst = two_level(clock, reset, ia, ib) inst = two_level(clock, reset, ia, ib)
assert inst.analyze_convert() == 0 assert inst.analyze_convert() == 0

View File

@ -75,7 +75,7 @@ def name_conflict_after_replace(clock, reset, a, a_x):
def test_name_conflict_after_replace(): def test_name_conflict_after_replace():
clock = Signal(False) clock = Signal(False)
reset = ResetSignal(0, active=0, async=False) reset = ResetSignal(0, active=0, isasync=False)
a = Intf() a = Intf()
a_x = Signal(intbv(0)[len(a.x):]) a_x = Signal(intbv(0)[len(a.x):])
inst = name_conflict_after_replace(clock, reset, a, a_x) inst = name_conflict_after_replace(clock, reset, a, a_x)
@ -85,7 +85,7 @@ def test_name_conflict_after_replace():
@block @block
def c_testbench(): def c_testbench():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=False) reset = ResetSignal(0, active=0, isasync=False)
a, b, c = Intf(), Intf(), Intf() a, b, c = Intf(), Intf(), Intf()
tb_dut = use_interfaces(clock, reset, a, b, c) tb_dut = use_interfaces(clock, reset, a, b, c)
@ -117,7 +117,7 @@ def c_testbench():
def test_name_conflicts_analyze(): def test_name_conflicts_analyze():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=False) reset = ResetSignal(0, active=0, isasync=False)
a, b, c = Intf(), Intf(), Intf() a, b, c = Intf(), Intf(), Intf()
inst = use_interfaces(clock, reset, a, b, c) inst = use_interfaces(clock, reset, a, b, c)
assert inst.analyze_convert() == 0 assert inst.analyze_convert() == 0

View File

@ -151,7 +151,7 @@ def c_testbench_three():
as well as top-level interface conversion. as well as top-level interface conversion.
""" """
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
x = Signal(intbv(3, min=-5000, max=5000)) x = Signal(intbv(3, min=-5000, max=5000))
y = Signal(intbv(4, min=-200, max=200)) y = Signal(intbv(4, min=-200, max=200))
intf = IntfWithConstant2() intf = IntfWithConstant2()
@ -217,7 +217,7 @@ def test_two_verify():
def test_three_analyze(): def test_three_analyze():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
x = Signal(intbv(3, min=-5000, max=5000)) x = Signal(intbv(3, min=-5000, max=5000))
y = Signal(intbv(4, min=-200, max=200)) y = Signal(intbv(4, min=-200, max=200))
intf = IntfWithConstant2() intf = IntfWithConstant2()

View File

@ -98,7 +98,7 @@ def c_testbench_one():
used in this example caused and invalid multiple driver error. used in this example caused and invalid multiple driver error.
""" """
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=1, async=False) reset = ResetSignal(0, active=1, isasync=False)
sdi = Signal(bool(0)) sdi = Signal(bool(0))
sdo = Signal(bool(0)) sdo = Signal(bool(0))
nested = Signal(bool()) nested = Signal(bool())
@ -145,7 +145,7 @@ def test_one_testbench():
def test_one_analyze(): def test_one_analyze():
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=1, async=False) reset = ResetSignal(0, active=1, isasync=False)
sdi = Signal(bool(0)) sdi = Signal(bool(0))
sdo = Signal(bool(0)) sdo = Signal(bool(0))
nested = Signal(bool(0)) nested = Signal(bool(0))

View File

@ -14,7 +14,7 @@ def NonlocalBench():
qout = Signal(intbv(ONE)[8:]) qout = Signal(intbv(ONE)[8:])
init = Signal(bool(0)) init = Signal(bool(0))
clk = Signal(bool(0)) clk = Signal(bool(0))
reset = ResetSignal(0, active=1, async=True) reset = ResetSignal(0, active=1, isasync=True)
q = intbv(ONE)[8:] q = intbv(ONE)[8:]

View File

@ -10,7 +10,7 @@ def test_clock():
# should fail without a valid Signal # should fail without a valid Signal
clock = Signal(bool(0)) clock = Signal(bool(0))
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
with raises_kind(AlwaysSeqError, _error.EdgeType): with raises_kind(AlwaysSeqError, _error.EdgeType):
@always_seq(clock, reset=reset) @always_seq(clock, reset=reset)
@ -40,7 +40,7 @@ def test_reset():
pass pass
# should work with a valid Signal # should work with a valid Signal
reset = ResetSignal(0, active=0, async=True) reset = ResetSignal(0, active=0, isasync=True)
try: try:
@always_seq(clock.posedge, reset=reset) @always_seq(clock.posedge, reset=reset)
def logic2(): def logic2():