【问题标题】:Data is not storing in array, I want to store data in arrays and feeding to the others数据未存储在数组中,我想将数据存储在数组中并提供给其他数组
【发布时间】:2019-09-23 13:43:45
【问题描述】:

我正在为 cocotb 测试平台编写代码以验证 hdl 模块,但我遇到了一些问题。我想提供从 .txt 文件中读取并存储在数组中的数据,但是当我尝试提供数据时,它显示索引错误,因为 Array 没有存储任何数据。

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()

如何将数据存储在 lin[0],lin[1],.....,lin[11] 中。向 sample_data 提供数据?

【问题讨论】:

    标签: python python-2.7 cocotb


    【解决方案1】:

    您没有调用gen_in() 来实际填充数组。 (感谢 cocotb Gitter 频道中的 Marlon 发现了这一点。)

    【讨论】:

    • 感谢您的回复。我必须在哪里调用 gen_in() 来填充数组?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    • 2018-06-29
    • 2011-11-13
    相关资源
    最近更新 更多