cocotb: driving certain bits of verilog packed array

Viewed 78

I'm using cocotb 1.6.2 and icarus.

I have a inout packed array signal that I can slice read it but I can't slice write to it.

RTL signal

inout [31:0] io

I can slice read it through

read_val = self.dut.io.value[low:high]

I tried to slice write to it using the following:

1.

self.dut.io[low:high].value = data # error: Slice indexing is not supported 
self.dut.io.value[low:high] = data # error: BinaryValue slices only accept string or integer values
self.dut.io.value = f'zzzzz{data}zzz' # no error but the bits I assigned with z changed to z ( i need them to stay the same) 
old_val = self.dut.io.value 
olf_val[low:high] = data 
self.dut.io.value = old_val # worked but I'm afraid this may cause some race if value of bits that I don't need to drive is suppose to be change by the hardware(RTL) at the same cycle 

Is there a way that I can deal with the packed array like the unpacked array to drive specific slice bits ?

0 Answers
Related