0

I am writing the code for cocotb testbench for verify the hdl modules, but I have some problems. I want to feed the data, which is reading from the .txt files and storing in an array but when I tried to feed the data, it shows index error because Array is not storing any data.

class expample():
    def __init__(self):
        self.lin  = [[],[]]
        self.lout = []
    def gen_in():
        lin_files =  ['prach_din1.txt',  'prach_din2.txt',  'prach_din3.txt', 'prach_din4.txt', 'prach_din5.txt',  'prach_din6.txt', 'prach_din7.txt','prach_din8.txt','prach_din9.txt', 'prach_din10.txt', 'prach_din11.txt', 'prach_din12.txt']
            for antenna_num in lin_files:
                in_file = open( antenna_num,'r').readlines()
                self.lin = [ int(i) for i in in_file ]
                print(self.lin)


class tb_expample(object):


    expample_obj = expample()

    @cocotb.coroutine
    def drive_antenna(self, num):
        for ant_num in range(4):
            for samp_num in (self.expample_obj.lin[ant_num]):
                    self.dut.osample_data[ant_num]   = samp_num
                    self.dut.osample_enable[ant_num] = 1
                    self.dut.oframe_strobe[ant_num]  = 1


@cocotb.test()
def test_expample_processor(dut):
    test = tb_expample(dut)
     yield test.drive_antenna()

How can I store the data in lin[0],lin[1],.....,lin[11]. for feeding data to sample_data?

Eric
  • 95,302
  • 53
  • 242
  • 374
Anurag
  • 9
  • 1

1 Answers1

0

You are not calling gen_in() to actually populate the array. (Credits go to Marlon in the cocotb Gitter channel for spotting this.)

cmarqu
  • 493
  • 3
  • 10