pythonvhdlghdlcocotb

Modify VHDL generic value with ghdl in cocotb


I managed to read generic module value with cocotb without problem. But if I can't manage to write it.

My VHDL generic is :

...
generic (
    ... 
    C_M00_AXI_BURST_LEN : integer   := 16;
    ...
)

I can read it in cocotb:

 self.dut.log.info("C_M00_AXI_BURST_LEN 0x{:x}".format(
                   int(self.dut.c_m00_axi_burst_len)))

But if I try to change it :

self.dut.c_m00_axi_burst_len = 32

I get this python error :

  Send raised exception: Not permissible to set values on object c_m00_axi_burst_len
File "/opt/cocotb/cocotb/decorators.py", line 197, in send
  return self._coro.send(value)
File "/usr/local/projects/axi_pattern_tester/vivado_ip/axi_pattern_tester_1.0/cocotb/test_axi_pattern_tester_v1_0.py", line 165, in axi4_master_test
  dutest.print_master_generics()
File "/usr/local/projects/axi_pattern_tester/vivado_ip/axi_pattern_tester_1.0/cocotb/test_axi_pattern_tester_v1_0.py", line 86, in print_master_generics
  self.dut.c_m00_axi_burst_len = 32
File "/opt/cocotb/cocotb/handle.py", line 239, in __setattr__
  return getattr(self, name)._setcachedvalue(value)
File "/opt/cocotb/cocotb/handle.py", line 378, in _setcachedvalue
  raise TypeError("Not permissible to set values on object %s" % (self._name))

Is there a way to do it using GHDL as simulator ?


Solution

  • In fact, user1155120, Paebbels and scary_jeff respond to the question : It's not possible.

    But it's possible to use configuration differently to solve this problem. VHDL Generic value can be configured in Makefile adding "-g" option to SIM_ARGS parameter :

    SIM_ARGS+=-gC_M00_AXI_BURST_LEN=16
    

    This value can then be read under cocotb "dut" object like any others signal and used as simulation parameter :

    C_M00_AXI_BURST_LEN = int(dut.C_M00_AXI_BURST_LEN.value)