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.

46 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(self.key, [
  12. vsc.weight(0, 15),
  13. vsc.weight((1,2**128-2), 70),
  14. vsc.weight((2**128-1), 15)])
  15. # Stimuli covergroup
  16. @vsc.covergroup
  17. class covergroup():
  18. def __init__(self, name="bla"):
  19. self.options.name = name
  20. self.with_sample(
  21. mode = vsc.bit_t(1),
  22. key = vsc.bit_t(128)
  23. )
  24. self.enc = vsc.coverpoint(self.mode, bins=dict(
  25. enc = vsc.bin(0)))
  26. self.dec = vsc.coverpoint(self.mode, bins=dict(
  27. dec = vsc.bin(1)))
  28. self.key0 = vsc.coverpoint(self.key, bins=dict(
  29. key0 = vsc.bin(0)))
  30. self.keyF = vsc.coverpoint(self.key, bins=dict(
  31. keyF = vsc.bin(2**128-1)))
  32. self.encXkey0 = vsc.cross([self.enc, self.key0])
  33. self.encXkeyF = vsc.cross([self.enc, self.keyF])
  34. self.decXkey0 = vsc.cross([self.dec, self.key0])
  35. self.decXkeyF = vsc.cross([self.dec, self.keyF])