mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
removed error on reading back outputs of always_comb
process (#368)
* removed error on reading back outputs of `always_comb` process * Update _always_comb.py * removed tests for SignalAsInout in AlwaysComb
This commit is contained in:
parent
0247603e82
commit
212b4b294e
@ -29,6 +29,8 @@ from myhdl._always import _Always
|
||||
|
||||
class _error:
|
||||
pass
|
||||
|
||||
|
||||
_error.ArgType = "always_comb argument should be a classic function"
|
||||
_error.NrOfArgs = "always_comb argument should be a function without arguments"
|
||||
_error.Scope = "always_comb argument should be a local function"
|
||||
@ -55,10 +57,6 @@ class _AlwaysComb(_Always):
|
||||
senslist = []
|
||||
super(_AlwaysComb, self).__init__(func, senslist, callinfo=callinfo)
|
||||
|
||||
inouts = self.inouts | self.inputs.intersection(self.outputs)
|
||||
if inouts:
|
||||
raise AlwaysCombError(_error.SignalAsInout % inouts)
|
||||
|
||||
if self.embedded_func:
|
||||
raise AlwaysCombError(_error.EmbeddedFunction)
|
||||
|
||||
@ -80,3 +78,5 @@ class _AlwaysComb(_Always):
|
||||
while 1:
|
||||
func()
|
||||
yield senslist
|
||||
|
||||
|
||||
|
@ -29,13 +29,13 @@ from helpers import raises_kind
|
||||
|
||||
# random.seed(3) # random, but deterministic
|
||||
|
||||
|
||||
QUIET=1
|
||||
QUIET = 1
|
||||
|
||||
|
||||
def g():
|
||||
pass
|
||||
|
||||
|
||||
x = Signal(0)
|
||||
|
||||
|
||||
@ -47,24 +47,28 @@ class TestAlwaysCombCompilation:
|
||||
always_comb(h)
|
||||
|
||||
def testArgIsNormalFunction(self):
|
||||
|
||||
def h():
|
||||
yield None
|
||||
|
||||
with raises_kind(AlwaysCombError, _error.ArgType):
|
||||
always_comb(h)
|
||||
|
||||
def testArgHasNoArgs(self):
|
||||
|
||||
def h(n):
|
||||
return n
|
||||
|
||||
with raises_kind(AlwaysCombError, _error.NrOfArgs):
|
||||
always_comb(h)
|
||||
|
||||
## def testScope(self):
|
||||
## try:
|
||||
## always_comb(g)
|
||||
## except AlwaysCombError, e:
|
||||
## self.assertEqual(e.kind, _error.Scope)
|
||||
## else:
|
||||
## self.fail()
|
||||
# # def testScope(self):
|
||||
# # try:
|
||||
# # always_comb(g)
|
||||
# # except AlwaysCombError, e:
|
||||
# # self.assertEqual(e.kind, _error.Scope)
|
||||
# # else:
|
||||
# # self.fail()
|
||||
|
||||
def testInfer1(self):
|
||||
a, b, c, d = [Signal(0) for i in range(4)]
|
||||
@ -73,6 +77,7 @@ class TestAlwaysCombCompilation:
|
||||
def h():
|
||||
c.next = a
|
||||
v = u
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a'])
|
||||
@ -85,6 +90,7 @@ class TestAlwaysCombCompilation:
|
||||
def h():
|
||||
c.next = x
|
||||
g = a
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a', 'x'])
|
||||
@ -97,6 +103,7 @@ class TestAlwaysCombCompilation:
|
||||
def h():
|
||||
c.next = a + x + u
|
||||
a = 1
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['x'])
|
||||
@ -109,34 +116,36 @@ class TestAlwaysCombCompilation:
|
||||
def h():
|
||||
c.next = a + x + u
|
||||
x = 1
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a'])
|
||||
assert i.inputs == expected
|
||||
|
||||
def testInfer5(self):
|
||||
a, b, c, d = [Signal(0) for i in range(4)]
|
||||
|
||||
def h():
|
||||
c.next += 1
|
||||
a += 1
|
||||
with raises_kind(AlwaysCombError, _error.SignalAsInout % set('c')):
|
||||
g = always_comb(h).gen
|
||||
|
||||
def testInfer6(self):
|
||||
a, b, c, d = [Signal(0) for i in range(4)]
|
||||
|
||||
def h():
|
||||
c.next = a
|
||||
x.next = c
|
||||
with raises_kind(AlwaysCombError, _error.SignalAsInout % set('c')):
|
||||
g = always_comb(h).gen
|
||||
# def testInfer5(self):
|
||||
# a, b, c, d = [Signal(0) for i in range(4)]
|
||||
#
|
||||
# def h():
|
||||
# c.next += 1
|
||||
# a += 1
|
||||
# with raises_kind(AlwaysCombError, _error.SignalAsInout % set('c')):
|
||||
# g = always_comb(h).gen
|
||||
#
|
||||
# def testInfer6(self):
|
||||
# a, b, c, d = [Signal(0) for i in range(4)]
|
||||
#
|
||||
# def h():
|
||||
# c.next = a
|
||||
# x.next = c
|
||||
# with raises_kind(AlwaysCombError, _error.SignalAsInout % set('c')):
|
||||
# g = always_comb(h).gen
|
||||
|
||||
def testInfer7(self):
|
||||
a, b, c, d = [Signal(0) for i in range(4)]
|
||||
|
||||
def h():
|
||||
c.next[a:0] = x[b:0]
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a', 'b', 'x'])
|
||||
@ -148,7 +157,8 @@ class TestAlwaysCombCompilation:
|
||||
|
||||
def h():
|
||||
v = 2
|
||||
c.next[8:1+a+v] = x[4:b*3+u]
|
||||
c.next[8:1 + a + v] = x[4:b * 3 + u]
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a', 'b', 'x'])
|
||||
@ -158,7 +168,8 @@ class TestAlwaysCombCompilation:
|
||||
a, b, c, d = [Signal(0) for i in range(4)]
|
||||
|
||||
def h():
|
||||
c.next[a-1] = x[b-1]
|
||||
c.next[a - 1] = x[b - 1]
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a', 'b', 'x'])
|
||||
@ -171,7 +182,8 @@ class TestAlwaysCombCompilation:
|
||||
return 0
|
||||
|
||||
def h():
|
||||
c.next = f(a, 2*b, d*x)
|
||||
c.next = f(a, 2 * b, d * x)
|
||||
|
||||
g = always_comb(h).gen
|
||||
i = g.gi_frame.f_locals['self']
|
||||
expected = set(['a', 'b', 'd', 'x'])
|
||||
@ -182,11 +194,14 @@ class TestAlwaysCombCompilation:
|
||||
u = 1
|
||||
|
||||
def h():
|
||||
|
||||
def g():
|
||||
e = b
|
||||
return e
|
||||
|
||||
c.next = x
|
||||
g = a
|
||||
|
||||
with raises_kind(AlwaysCombError, _error.EmbeddedFunction):
|
||||
g = always_comb(h)
|
||||
|
||||
@ -235,31 +250,41 @@ class TestAlwaysCombSimulation1:
|
||||
return instances()
|
||||
|
||||
def testAnd(self):
|
||||
|
||||
def andFunction(a, b, c, d):
|
||||
return a & b & c & d
|
||||
|
||||
Simulation(self.bench(andFunction)).run(quiet=QUIET)
|
||||
|
||||
def testOr(self):
|
||||
|
||||
def orFunction(a, b, c, d):
|
||||
return a | b | c | d
|
||||
|
||||
Simulation(self.bench(orFunction)).run(quiet=QUIET)
|
||||
|
||||
def testXor(self):
|
||||
|
||||
def xorFunction(a, b, c, d):
|
||||
return a ^ b ^ c ^ d
|
||||
|
||||
Simulation(self.bench(xorFunction)).run(quiet=QUIET)
|
||||
|
||||
def testMux(self):
|
||||
|
||||
def muxFunction(a, b, c, d):
|
||||
if c:
|
||||
return a
|
||||
else:
|
||||
return b
|
||||
|
||||
Simulation(self.bench(muxFunction)).run(quiet=QUIET)
|
||||
|
||||
def testLogic(self):
|
||||
|
||||
def function(a, b, c, d):
|
||||
return not (a & (not b)) | ((not c) & d)
|
||||
|
||||
Simulation(self.bench(function)).run(quiet=QUIET)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user