Skip to content
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

array_idx doesn't work for cases where the signals are a dict #86

Open
davekeeshan opened this issue Nov 14, 2024 · 1 comment
Open

Comments

@davekeeshan
Copy link
Contributor

I am not too sure if I am using the bus allocation right. I have a inout on an FPGA, ja[7:0] (thanks digilent). I have, on the fpga assigned some of those pins to a JTAG interface. I have physically verified these are working (openocd/logic analyzer).

   , inout [7:0] ja


    signals = {
        "tck": "ja[4]",
        "tms": "ja[5]",
        "tdi": "ja[6]",
        "tdo": "ja[7]",
    }

However when I try and allocate a jtag bus to this pins in the vector, the setup doesn't work. array_idx, i think, only works with one signal, and it can only be a single int, if you have two in a list or a dict ii can't be used

./cocotb-bus/src/cocotb_bus/bus.py
def __init__(self, entity, name, signals, optional_signals=[], bus_separator="_", case_insensitive=True, array_idx=None):
    """
    Args:
        ...
        array_idx (int or None, optional): Optional index when signal is an array.

I am looking at enhancing to set the array_idx locally if detected in the string supplied

    for attr_name, sig_name in _build_sig_attr_dict(signals).items():
        if g := re.search(r"(.+)\[(\d+)\]", sig_name):
            sig_name = g.group(1)
            array_idx = int(g.group(2))
        if name:
            signame = name + bus_separator + sig_name
        else:
            signame = sig_name

        self._add_signal(attr_name, signame, array_idx, case_insensitive)
        array_idx = None
@davekeeshan
Copy link
Contributor Author

I got this working on the released verison of cocotb, 1.9.2. However with the next release, 2.0, there are some changes on how indexing of an vector occur, subscriptable signals (LogicObject).

This presents is self in the cocotb-bus when one tries to:

    if array_idx is not None:
        handle = handle[array_idx]

This exception is raise when array_idx is not None.

File "/mnt/sda/projects/cocotb-bus/src/cocotb_bus/bus.py", line 99, in _add_signal
    handle = handle[array_idx]
    ~~~~~~^^^^^^^^^^^
TypeError: 'LogicObject' object is not subscriptable

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

1 participant