Examples of using cocotb for functional verification of VHDL designs with GHDL.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  1. import vsc
  2. # Random stimuli model class
  3. @vsc.randobj
  4. class constraints:
  5. def __init__(self):
  6. self.key = vsc.rand_bit_t(128)
  7. self.data = vsc.rand_bit_t(128)
  8. @vsc.constraint
  9. def c(self):
  10. self.data >= 0 and self.data <= 2**128 - 1
  11. vsc.dist(
  12. self.key,
  13. [
  14. vsc.weight(0, 15),
  15. vsc.weight((1, 2**128 - 2), 70),
  16. vsc.weight((2**128 - 1), 15),
  17. ],
  18. )
  19. # Stimuli covergroup
  20. @vsc.covergroup
  21. class covergroup:
  22. def __init__(self, name="bla"):
  23. self.options.name = name
  24. self.with_sample(mode=vsc.bit_t(1), key=vsc.bit_t(128))
  25. self.enc = vsc.coverpoint(self.mode, bins=dict(enc=vsc.bin(0)))
  26. self.dec = vsc.coverpoint(self.mode, bins=dict(dec=vsc.bin(1)))
  27. self.key0 = vsc.coverpoint(self.key, bins=dict(key0=vsc.bin(0)))
  28. self.keyF = vsc.coverpoint(self.key, bins=dict(keyF=vsc.bin(2**128 - 1)))
  29. self.encXkey0 = vsc.cross([self.enc, self.key0])
  30. self.encXkeyF = vsc.cross([self.enc, self.keyF])
  31. self.decXkey0 = vsc.cross([self.dec, self.key0])
  32. self.decXkeyF = vsc.cross([self.dec, self.keyF])