cocotb: access arrays of instances signals

731 Views Asked by At

I have modules that initialized like that

RTL

slave slaves[1:0] (some inputs / outputs) 

I need to access some internal data from slaves instances which have the following hdl hierarchy

top.slaves[0].internal_data
top.slaves[1].internal_data

when I tried the following code in cocotb

signal_0 = self.dut.slaves[0].internal_data.value
signal_1 = self.dut.slaves[1].internal_data.value

I get this error:

AttributeError: dut contains no object named slaves

The output of print(dir(self.dut)) are:

[...,'module', 'ne', 'new', 'reduce', 'reduce_ex', ... , 'clock',..., 'salves[0]', 'slaves[1]',....]

clearly it can't see the [0] or [1] as part of the instance name. How can I access signals like these ?

2

There are 2 best solutions below

0
cmarqu On BEST ANSWER

Does it work with self.dut._id("slaves[0]", extended=False).value?

0
scafir On

If using GHDL:

  1. Make sure you are running an up-to-date version and NOT 0.38
  2. Accessing constant arrays through VPI is not supported as of Jan 6, 2023. Check this issue.

P.S: to add my grain of salt to the original post, it seems that there was a typo (salves instead of slaves).