Search code examples
verificationcocotb

cocotb: access arrays of instances signals


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 ?


Solution

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