3

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 ?

FabienM
  • 3,421
  • 23
  • 45
  • 3
    Changing a generic value needs a complete re-elaboration of the design (complete compilation and linking). So you can't change the value without a complete restart. Why would you change the generic value in a running design? – Paebbels May 18 '17 at 09:08
  • In fact, I don't want to change value in «running design» but in the python test function. The objective is to have all tests parameters configured in the test_module.py, instead of modifying some VHDL. – FabienM May 18 '17 at 09:21
  • 2
    You can change the value of a `generic` post-compilation (but not during run-time) using the `configuration` construct. I don't know if cocotb or GHDL support it, but it is possible in VHDL. – scary_jeff May 18 '17 at 09:45
  • 2
    ghdl supports configuration declarations and you can elaborate and simulate configurations. *The objective is to have all tests parameters configured in the test_module.py, instead of modifying some VHDL.* You might imagine test parameters are adapted to the hardware being tested, not the other way way around. Otherwise C_M00_AXI_BURST_LEN wouldn't be a (generic) constant. –  May 18 '17 at 12:15

1 Answers1

1

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)
FabienM
  • 3,421
  • 23
  • 45