Skip to content

Passing array as an output from Python to System verilog  #32

@naveensrinat

Description

@naveensrinat

Hi,
I want to pass an array as output from Python to SV and get it as a dynamic array in SV.

My code is as below :

@sv(A_in=DataType.IntArray[1], return_type=DataType.IntArray[1])
def pass_array(A_in):
#A_out = []
A_out = arr.array('i',[])

print("Array Lenght=%d"%(len(A_in)))

#input
for ii in range(0,len(A_in)):
    print("%d"%(A_in[ii]))

#output
print("Output gen")
for ii in range(0,len(A_in)):
    print(ii)
    A_out.append(ii+10)

return A_out

When I tried running it i got the below error ::
(py_3_10_4) [283] ip-10-2-26-119 ../MY_SVTB > python3 my_test.py
/grid/common/pkgs/python/v3.10.4/lib/python3.10
/projects/cascade/cln12ffcll_a0/work/naveenna/cascade_plus_01052024/cascade/design/mpu/mpu_tb/MY_SVTB/pysv/init.py
Traceback (most recent call last):
File "/projects/cascade/cln12ffcll_a0/work/naveenna/cascade_plus_01052024/cascade/design/mpu/mpu_tb/MY_SVTB/my_test.py", line 22, in
@sv(A_in=DataType.IntArray[1], return_type=DataType.IntArray[1])
File "/projects/cascade/cln12ffcll_a0/work/naveenna/cascade_plus_01052024/cascade/design/mpu/mpu_tb/MY_SVTB/pysv/function.py", line 70, in init
assert self.return_type != DataType.IntArray, "Returning an array is not supported"
AssertionError: Returning an array is not supported

Can u please help resolve the error ? Does PYSV allow passing array as output from Py->SV ?

Thanks
Naveen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions