8000 ConcatSignal misbehavior converting to hdl · Issue #364 · myhdl/myhdl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ConcatSignal misbehavior converting to hdl #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rafaelcorsi opened this issue Mar 29, 2022 · 2 comments
Open

ConcatSignal misbehavior converting to hdl #364

rafaelcorsi opened this issue Mar 29, 2022 · 2 comments

Comments

@rafaelcorsi
Copy link
Contributor
rafaelcorsi commented Mar 29, 2022

On simulation ConcatSignal requires more than one argument 1 but it gives a error when converting to vhdl/verilog.

Not supported: extra positional arguments

System information

MyHDL Version: 0.11
Python Version: 3.10.2 (I also tested on python2)

Test Modules:

@block
def bar(a, y):
    @always_comb
    def comb():
        y.next = a

    return comb


@block
def foo(x, q, n=4):
    sig_x = [x(i) for i in range(n)]
    sig_q = [Signal(bool(0)) for i in range(n)]

    bar_list = [None for i in range(n)]
    for i in range(n):
        bar_list[i] = bar(sig_x[i], sig_q[i])

    @always_comb
    def comb():
        q.next = ConcatSignal(*reversed(sig_q))

    return instances()

Simulation works fine:

@block
def test_foo():
    x = Signal(intbv(0))
    q = Signal(intbv(0))

    foo_1 = foo(x, q)

    @instance
    def stimulus():
        x.next = 2
        yield delay(10)
        print(q)

    return foo_1, stimulus

Converting to vhdl gives an error

def convert_foo(hdl):
    x, q = [Signal(intbv(0)[15:0]) for i in range(2)]
    add_1 = foo(x, q)
    add_1.convert(hdl=hdl)

⚠️ Erro:

  File "/home/corsi/.local/lib/python3.10/site-packages/myhdl/conversion/_analyze.py", line 299, in visit_Call
    self.raiseError(node, _error.NotSupported, "extra positional arguments")
  File "/home/corsi/.local/lib/python3.10/site-packages/myhdl/conversion/_misc.py", line 148, in raiseError
    raise ConversionError(kind, msg, info)
myhdl.ConversionError: in file /home/corsi/work/ElementosBCC/MyHDL/z01/c-ula/modulos.py, line 48:
    Not supported: extra positional arguments
@rafaelcorsi
Copy link
Contributor Author
rafaelcorsi commented Mar 29, 2022

here is a implementation that works, is there a easy/ compact way to do this?

@block
def foo(x, q, n=4):
    sig_x = [x(i) for i in range(n)]
    sig_q = [Signal(bool(0)) for i in range(n)]

    bar_list = [None for i in range(n)]
    for i in range(n):
        bar_list[i] = bar(sig_x[i], sig_q[i])

    out_q = ConcatSignal(*reversed(sig_q))

    @always_comb
    def comb():
        q.next = out_q

    return instances()

@josyb josyb removed the bug label Jul 30, 2022
@josyb
Copy link
Contributor
josyb commented Jul 30, 2022

You found out the right way to use ConcatSignal(). The simulation of the original description works fine as it simply creates a new ConcatSignal at every run of the @always_comb generator.
In theory one could expect that the convertor be able to handle it, but it is incompatible with the current flow of the conversion process. A possible option could be to expand concat() to handle a list of Signals; then you could write:

    @always_comb
    def comb():
        q.next = concat(*reversed(sig_q))

This enhancement is easy for simulation but hard to add to conversion :(

You can do without the sig_x list by using a ShadowSignal() in the call to bar

@block
def foo(x, q, n=4):
    sig_q = [Signal(bool(0)) for i in range(n)]

    bar_list = [None for i in range(n)]
    for i in range(n):
        bar_list[i] = bar(sig_x(i), sig_q[i])

    out_q = ConcatSignal(*reversed(sig_q))

    @always_comb
    def comb():
        q.next = out_q

    return instances()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0