Need help with the error

I’m making a basic testbench of UVM using python, at first i will be generating random numbers and then printing them to verify, kindly help with the code and error. Both codes of Verilog and python and error are attached.

VERILOG CODE:


module ALU(A,B,ALU_CONTROL,SUM,COUT,Y0,Y1,Y2,RESULT);
	
  input [31:0] A,B;
  input [1:0] ALU_CONTROL;
  output [31:0] SUM,Y0,Y1,Y2;
  output COUT;
  output reg [31:0] RESULT;
  
  assign Y0=(ALU_CONTROL==2'b11) ? (~B):(ALU_CONTROL==2'b10) ? B:(ALU_CONTROL==2'b01) ? (~B):B;
  
  assign Y1=(A|B);
  assign Y2=(A & B);
  
  assign SUM=((A^Y0)^(ALU_CONTROL));
  assign COUT=((A&Y0)|((A^Y0)&(ALU_CONTROL)));
    
    always @(SUM or Y2 or Y1)
      begin
        case(ALU_CONTROL)
          2'b00: begin
            	RESULT=SUM;	
          		 end
          2'b01: begin
            	RESULT=SUM;	
          		 end
          2'b10: begin
            	RESULT=Y2;	
          		 end
          2'b11: begin
            	RESULT=Y1;	
          		 end
        endcase
      end
      
    initial
    begin
    	$dumpfile("dump.vcd");
    	$dumpvars(1,ALU);
    end
endmodule

Python Code

import cocotb
from cocotb.triggers import Timer
import random
import pyuvm
import pandas as pd

@cocotb.test()
async def CODE_AA(dut):
 for i in range (10):
  dut.A = random.randint(0, 1000)
  print(dut.A) 
  await Timer(20, units = "ns")
  
  dut.B = random.randint(0, 1000)
  print(dut.B)
  await Timer(20, units = "ns")
  
  dut.ALU_CONTROL.value = random.randint(0,3)
   #dut.ALU_CONTROL.value = ALU_CONTROL 
   #ALU_CONTROL = [0, 1, 2, 3]
  print(dut.ALU_CONTROL)
  
 a = random.choice(dut.ALU_CONTROL)
 print(a)
  
 listA = [dut.A]
 print(listA)
 listB = [dut.B]
 print(listB)

# ALU_CONTROL = [0, 1, 2, 3]

 await Timer(20, units = "ns")

 b = dut.SUM
 c = dut.Y0
 d = dut.Y1
 e = dut.Y2
 f = dut.COUT
 result = dut.RESULT
 print(result)

# print(dut.A)
# print(dut.B)
 print(f)
 print(b)
 print(Y0)
 print(Y1)
 print(Y2)

And the error is:
orry: Icarus does not currently support vpi_get_handle_by_index() for vpiNet objects (ALU_CONTROL).
400.00ns WARNING Failed to find a handle at index 1 via any registered implementation
400.00ns INFO CODE_AA failed
Traceback (most recent call last):
File “/home/muneeb/Testbench_Class/BASIC_TB/Test/basic.py”, line 23, in CODE_AA
a = random.choice(dut.ALU_CONTROL)
File “/usr/lib/python3.8/random.py”, line 291, in choice
return seq[i]
File “/usr/local/lib/python3.8/dist-packages/cocotb/handle.py”, line 609, in getitem
raise IndexError(“%s contains no object at index %d” % (self._fullname, index))
IndexError: ALU_CONTROL(GPI_NET) contains no object at index 1
400.00ns INFO **************************************************************************************
** TEST STATUS SIM TIME (ns) REAL TIME (s) RATIO (ns/s) **
**************************************************************************************
** basic.CODE_AA FAIL 400.00 0.01 28118.15 **
**************************************************************************************
** TESTS=1 PASS=0 FAIL=1 SKIP=0 400.00 1.17 341.24 **
**************************************************************************************

make[1]: Leaving directory ‘/home/muneeb/Testbench_Class/BASIC_TB/Test’

In reply to Muneeb Ur Rehman:

As the error states, the Icarus simulator doesn’t support the vpi_get_handle_by_index() function. You will need to use a simulator that supports this function.