1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

Support for list of signals in the sensitivity list of simple @instance blocks.

This commit is contained in:
Jan Decaluwe 2008-09-10 17:26:59 +02:00
parent 8e8550c801
commit 65b3295cb4
3 changed files with 51 additions and 10 deletions

View File

@ -873,10 +873,12 @@ class _AnalyzeVisitor(_ConversionMixin):
if not isinstance(n.obj, (Signal, _WaiterList)):
self.raiseError(node, _error.UnsupportedYield)
senslist.append(n.obj)
else:
if not isinstance(n.obj, (Signal, _WaiterList, delay)):
self.raiseError(node, _error.UnsupportedYield)
elif isinstance(n.obj, (Signal, _WaiterList, delay)):
senslist = [n.obj]
elif _isMem(n.obj):
senslist = n.obj
else:
self.raiseError(node, _error.UnsupportedYield)
node.senslist = senslist
## def visitModule(self, node, *args):

View File

@ -1028,8 +1028,13 @@ class _ConvertAlwaysVisitor(_ConvertVisitor):
y = y.expr
assert isinstance(y, astNode.Yield)
sl = y.value
assert y.senslist
self.ast.senslist = y.senslist
self.write("always @(")
self.visit(sl, _context.YIELD)
for e in self.ast.senslist[:-1]:
self.write(e._toVerilog())
self.write(', ')
self.write(self.ast.senslist[-1]._toVerilog())
self.write(") begin: %s" % self.ast.name)
self.indent()
self.writeDeclarations()

View File

@ -1,13 +1,14 @@
from myhdl import *
N = 8
M= 2**N
### A first case that already worked with 5.0 list of signal constraints ###
def intbv2list():
"""Conversion between intbv and list of boolean signals."""
N = 8
M= 2**N
a = Signal(intbv(0)[N:])
b = [Signal(bool(0)) for i in range(len(a))]
z = Signal(intbv(0)[N:])
@ -47,6 +48,7 @@ def inv1(z, a):
z.next = not a
return logic
def inv2(z, a):
@always_comb
def logic():
@ -54,6 +56,15 @@ def inv2(z, a):
return logic
def inv3(z, a):
@instance
def logic():
while True:
yield a
z.next = not a
return logic
def case1(z, a, inv):
b = [Signal(bool(1)) for i in range(len(a))]
c = [Signal(bool(0)) for i in range(len(a))]
@ -73,6 +84,7 @@ def case1(z, a, inv):
return extract, inst, assemble
def case2(z, a, inv):
b = [Signal(bool(1)) for i in range(len(a))]
c = [Signal(bool(0)) for i in range(len(a))]
@ -93,15 +105,34 @@ def case2(z, a, inv):
return extract, inst, assemble
def case3(z, a, inv):
b = [Signal(bool(1)) for i in range(len(a))]
c = [Signal(bool(0)) for i in range(len(a))]
@instance
def extract():
while True:
yield a
for i in range(len(a)):
b[i].next = a[i]
inst = [None] * len(b)
for i in range(len(b)):
inst[i] = inv(c[i], b[i])
@instance
def assemble():
while True:
yield c
for i in range(len(c)):
z.next[i] = c[i]
return extract, inst, assemble
def processlist(case, inv):
"""Extract list from intbv, do some processing, reassemble."""
N = 8
M = 2**N
a = Signal(intbv(1)[N:])
b = [Signal(bool(1)) for i in range(len(a))]
c = [Signal(bool(0)) for i in range(len(a))]
z = Signal(intbv(0)[N:])
case_inst = case(z, a, inv)
@ -129,6 +160,9 @@ def test_processlist12():
def test_processlist22():
assert conversion.verify(processlist, case2, inv2) == 0
def test_processlist33():
assert conversion.verify(processlist, case3, inv3) == 0