cocotb 1.7.2__cp36-cp36m-win_amd64.whl → 1.8.0rc1__cp36-cp36m-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cocotb might be problematic. Click here for more details.

Files changed (83) hide show
  1. cocotb/__init__.py +7 -18
  2. cocotb/_sim_versions.py +16 -1
  3. cocotb/_version.py +1 -1
  4. cocotb/clock.py +8 -3
  5. cocotb/decorators.py +40 -318
  6. cocotb/ipython_support.py +3 -1
  7. cocotb/libs/cocotb.dll +0 -0
  8. cocotb/libs/cocotb.exp +0 -0
  9. cocotb/libs/cocotb.lib +0 -0
  10. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  11. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  12. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  13. cocotb/libs/cocotbutils.dll +0 -0
  14. cocotb/libs/cocotbutils.exp +0 -0
  15. cocotb/libs/cocotbutils.lib +0 -0
  16. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  17. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  18. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  19. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  20. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  21. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  22. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  23. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  24. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  25. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  26. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  27. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  28. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  29. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  30. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  31. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  32. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  33. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  34. cocotb/libs/embed.dll +0 -0
  35. cocotb/libs/embed.exp +0 -0
  36. cocotb/libs/embed.lib +0 -0
  37. cocotb/libs/gpi.dll +0 -0
  38. cocotb/libs/gpi.exp +0 -0
  39. cocotb/libs/gpi.lib +0 -0
  40. cocotb/libs/gpilog.dll +0 -0
  41. cocotb/libs/gpilog.exp +0 -0
  42. cocotb/libs/gpilog.lib +0 -0
  43. cocotb/libs/pygpilog.dll +0 -0
  44. cocotb/libs/pygpilog.exp +0 -0
  45. cocotb/libs/pygpilog.lib +0 -0
  46. cocotb/regression.py +32 -14
  47. cocotb/runner.py +538 -453
  48. cocotb/scheduler.py +35 -18
  49. cocotb/share/def/aldec.exp +0 -0
  50. cocotb/share/def/aldec.lib +0 -0
  51. cocotb/share/def/ghdl.exp +0 -0
  52. cocotb/share/def/ghdl.lib +0 -0
  53. cocotb/share/def/icarus.exp +0 -0
  54. cocotb/share/def/icarus.lib +0 -0
  55. cocotb/share/def/modelsim.def +2 -0
  56. cocotb/share/def/modelsim.exp +0 -0
  57. cocotb/share/def/modelsim.lib +0 -0
  58. cocotb/share/include/embed.h +1 -2
  59. cocotb/share/include/gpi.h +10 -15
  60. cocotb/share/include/vpi_user_ext.h +3 -0
  61. cocotb/share/lib/verilator/verilator.cpp +8 -4
  62. cocotb/share/makefiles/Makefile.inc +16 -4
  63. cocotb/share/makefiles/Makefile.sim +2 -2
  64. cocotb/share/makefiles/simulators/Makefile.icarus +19 -0
  65. cocotb/share/makefiles/simulators/Makefile.ius +12 -1
  66. cocotb/share/makefiles/simulators/Makefile.questa +2 -1
  67. cocotb/share/makefiles/simulators/Makefile.riviera +4 -0
  68. cocotb/share/makefiles/simulators/Makefile.vcs +4 -0
  69. cocotb/share/makefiles/simulators/Makefile.verilator +5 -1
  70. cocotb/share/makefiles/simulators/Makefile.xcelium +5 -1
  71. cocotb/simulator.cp36-win_amd64.exp +0 -0
  72. cocotb/simulator.cp36-win_amd64.lib +0 -0
  73. cocotb/simulator.cp36-win_amd64.pyd +0 -0
  74. cocotb/task.py +325 -0
  75. cocotb/triggers.py +23 -7
  76. cocotb/types/logic_array.py +34 -3
  77. {cocotb-1.7.2.dist-info → cocotb-1.8.0rc1.dist-info}/METADATA +24 -9
  78. cocotb-1.8.0rc1.dist-info/RECORD +120 -0
  79. cocotb-1.7.2.dist-info/RECORD +0 -119
  80. {cocotb-1.7.2.dist-info → cocotb-1.8.0rc1.dist-info}/LICENSE +0 -0
  81. {cocotb-1.7.2.dist-info → cocotb-1.8.0rc1.dist-info}/WHEEL +0 -0
  82. {cocotb-1.7.2.dist-info → cocotb-1.8.0rc1.dist-info}/entry_points.txt +0 -0
  83. {cocotb-1.7.2.dist-info → cocotb-1.8.0rc1.dist-info}/top_level.txt +0 -0
cocotb/scheduler.py CHANGED
@@ -47,9 +47,9 @@ import cocotb
47
47
  import cocotb.decorators
48
48
  from cocotb import _py_compat, outcomes
49
49
  from cocotb._deprecation import deprecated
50
- from cocotb.decorators import Task
51
50
  from cocotb.log import SimLog
52
51
  from cocotb.result import TestComplete
52
+ from cocotb.task import Task
53
53
  from cocotb.triggers import (
54
54
  Event,
55
55
  GPITrigger,
@@ -76,7 +76,7 @@ if _profiling:
76
76
  _debug = "COCOTB_SCHEDULER_DEBUG" in os.environ
77
77
 
78
78
 
79
- class InternalError(RuntimeError):
79
+ class InternalError(BaseException):
80
80
  """An error internal to scheduler. If you see this, report a bug!"""
81
81
 
82
82
  pass
@@ -265,6 +265,7 @@ class Scheduler:
265
265
  self._pending_triggers = []
266
266
  self._pending_threads = []
267
267
  self._pending_events = [] # Events we need to call set on once we've unwound
268
+ self._scheduling = []
268
269
 
269
270
  self._terminate = False
270
271
  self._test = None
@@ -437,7 +438,7 @@ class Scheduler:
437
438
  # Scheduled coroutines may append to our waiting list so the first
438
439
  # thing to do is pop all entries waiting on this trigger.
439
440
  try:
440
- scheduling = self._trigger2coros.pop(trigger)
441
+ self._scheduling = self._trigger2coros.pop(trigger)
441
442
  except KeyError:
442
443
  # GPI triggers should only be ever pending if there is an
443
444
  # associated coroutine waiting on that trigger, otherwise it would
@@ -463,19 +464,19 @@ class Scheduler:
463
464
 
464
465
  if _debug:
465
466
  debugstr = "\n\t".join(
466
- [coro._coro.__qualname__ for coro in scheduling]
467
+ [coro._coro.__qualname__ for coro in self._scheduling]
467
468
  )
468
- if len(scheduling) > 0:
469
+ if len(self._scheduling) > 0:
469
470
  debugstr = "\n\t" + debugstr
470
471
  self.log.debug(
471
472
  "%d pending coroutines for event %s%s"
472
- % (len(scheduling), str(trigger), debugstr)
473
+ % (len(self._scheduling), str(trigger), debugstr)
473
474
  )
474
475
 
475
476
  # This trigger isn't needed any more
476
477
  trigger.unprime()
477
478
 
478
- for coro in scheduling:
479
+ for coro in self._scheduling:
479
480
  if coro._outcome is not None:
480
481
  # coroutine was killed by another coroutine waiting on the same trigger
481
482
  continue
@@ -494,6 +495,8 @@ class Scheduler:
494
495
  # happened in gh-957)
495
496
  del coro
496
497
 
498
+ self._scheduling = []
499
+
497
500
  # Handle any newly queued coroutines that need to be scheduled
498
501
  while self._pending_coros:
499
502
  task = self._pending_coros.pop(0)
@@ -522,7 +525,6 @@ class Scheduler:
522
525
  # to try and avoid them being destroyed at a weird time (as
523
526
  # happened in gh-957)
524
527
  del trigger
525
- del scheduling
526
528
 
527
529
  # no more pending triggers
528
530
  self._check_termination()
@@ -579,7 +581,7 @@ class Scheduler:
579
581
  coro.log.info("Test stopped by this forked coroutine")
580
582
  e = remove_traceback_frames(e, ["_unschedule", "get"])
581
583
  self._abort_test(e)
582
- except Exception as e:
584
+ except BaseException as e:
583
585
  coro.log.error("Exception raised by this forked coroutine")
584
586
  e = remove_traceback_frames(e, ["_unschedule", "get"])
585
587
  warnings.warn(
@@ -621,7 +623,6 @@ class Scheduler:
621
623
  trigger_coros.append(coro)
622
624
 
623
625
  if not trigger.primed:
624
-
625
626
  if trigger_coros != [coro]:
626
627
  # should never happen
627
628
  raise InternalError(
@@ -696,7 +697,7 @@ class Scheduler:
696
697
  event.set()
697
698
 
698
699
  event = threading.Event()
699
- self._pending_coros.append(cocotb.decorators.Task(wrapper()))
700
+ self._pending_coros.append(Task(wrapper()))
700
701
  # The scheduler thread blocks in `thread_wait`, and is woken when we
701
702
  # call `thread_suspend` - so we need to make sure the coroutine is
702
703
  # queued before that.
@@ -849,14 +850,14 @@ class Scheduler:
849
850
  # Doing them as separate functions allows us to avoid repeating unnecessary
850
851
  # `isinstance` checks.
851
852
 
852
- def _trigger_from_started_coro(self, result: cocotb.decorators.Task) -> Trigger:
853
+ def _trigger_from_started_coro(self, result: Task) -> Trigger:
853
854
  if _debug:
854
855
  self.log.debug(
855
856
  "Joining to already running coroutine: %s" % result._coro.__qualname__
856
857
  )
857
858
  return result.join()
858
859
 
859
- def _trigger_from_unstarted_coro(self, result: cocotb.decorators.Task) -> Trigger:
860
+ def _trigger_from_unstarted_coro(self, result: Task) -> Trigger:
860
861
  self._queue(result)
861
862
  if _debug:
862
863
  self.log.debug(
@@ -865,7 +866,7 @@ class Scheduler:
865
866
  return result.join()
866
867
 
867
868
  def _trigger_from_waitable(self, result: cocotb.triggers.Waitable) -> Trigger:
868
- return self._trigger_from_unstarted_coro(cocotb.decorators.Task(result._wait()))
869
+ return self._trigger_from_unstarted_coro(Task(result._wait()))
869
870
 
870
871
  def _trigger_from_list(self, result: list) -> Trigger:
871
872
  return self._trigger_from_waitable(cocotb.triggers.First(*result))
@@ -877,14 +878,14 @@ class Scheduler:
877
878
  if isinstance(result, Trigger):
878
879
  return result
879
880
 
880
- if isinstance(result, cocotb.decorators.Task):
881
+ if isinstance(result, Task):
881
882
  if not result.has_started():
882
883
  return self._trigger_from_unstarted_coro(result)
883
884
  else:
884
885
  return self._trigger_from_started_coro(result)
885
886
 
886
887
  if inspect.iscoroutine(result):
887
- return self._trigger_from_unstarted_coro(cocotb.decorators.Task(result))
888
+ return self._trigger_from_unstarted_coro(Task(result))
888
889
 
889
890
  if isinstance(result, list):
890
891
  return self._trigger_from_list(result)
@@ -979,7 +980,6 @@ class Scheduler:
979
980
  # where a sim might change what this thread is.
980
981
 
981
982
  if self._main_thread is threading.current_thread():
982
-
983
983
  for ext in self._pending_threads:
984
984
  ext.thread_start()
985
985
  if _debug:
@@ -1062,7 +1062,7 @@ class Scheduler:
1062
1062
  Unprime all pending triggers and kill off any coroutines, stop all externals.
1063
1063
  """
1064
1064
  # copy since we modify this in kill
1065
- items = list(self._trigger2coros.items())
1065
+ items = list((k, list(v)) for k, v in self._trigger2coros.items())
1066
1066
 
1067
1067
  # reversing seems to fix gh-928, although the order is still somewhat
1068
1068
  # arbitrary.
@@ -1071,10 +1071,27 @@ class Scheduler:
1071
1071
  if _debug:
1072
1072
  self.log.debug("Killing %s" % str(coro))
1073
1073
  coro.kill()
1074
+ assert not self._trigger2coros
1075
+
1076
+ # if there are coroutines being scheduled when the test ends, kill them (gh-1347)
1077
+ for coro in self._scheduling:
1078
+ if _debug:
1079
+ self.log.debug("Killing %s" % str(coro))
1080
+ coro.kill()
1081
+ self._scheduling = []
1082
+
1083
+ # cancel outstanding triggers *before* queued coroutines (gh-3270)
1084
+ while self._pending_triggers:
1085
+ trigger = self._pending_triggers.pop(0)
1086
+ if _debug:
1087
+ self.log.debug("Unpriming %r", trigger)
1088
+ trigger.unprime()
1089
+ assert not self._pending_triggers
1074
1090
 
1075
1091
  # kill any queued coroutines
1076
1092
  for task in self._pending_coros:
1077
1093
  task.kill()
1094
+ assert not self._pending_coros
1078
1095
 
1079
1096
  if self._main_thread is not threading.current_thread():
1080
1097
  raise Exception("Cleanup() called outside of the main thread")
Binary file
Binary file
cocotb/share/def/ghdl.exp CHANGED
Binary file
cocotb/share/def/ghdl.lib CHANGED
Binary file
Binary file
Binary file
@@ -93,6 +93,8 @@ mti_Now
93
93
  mti_NowUpper
94
94
  mti_Quit
95
95
  mti_ReleaseSignal
96
+ mti_RemoveLoadDoneCB
97
+ mti_RemoveQuitCB
96
98
  mti_ScheduleWakeup
97
99
  mti_ScheduleWakeup64
98
100
  mti_Sensitize
Binary file
Binary file
@@ -47,8 +47,7 @@ extern COCOTB_EMBED_EXPORT void embed_init_python(void);
47
47
  extern COCOTB_EMBED_EXPORT void embed_sim_cleanup(void);
48
48
  extern COCOTB_EMBED_EXPORT int embed_sim_init(int argc,
49
49
  char const* const* argv);
50
- extern COCOTB_EMBED_EXPORT void embed_sim_event(gpi_event_t level,
51
- const char* msg);
50
+ extern COCOTB_EMBED_EXPORT void embed_sim_event(const char* msg);
52
51
 
53
52
  #ifdef __cplusplus
54
53
  }
@@ -101,12 +101,6 @@ typedef struct GpiIterator *gpi_iterator_hdl;
101
101
  extern "C" {
102
102
  #endif
103
103
 
104
- typedef enum gpi_event_e {
105
- SIM_INFO = 0,
106
- SIM_TEST_FAIL = 1,
107
- SIM_FAIL = 2,
108
- } gpi_event_t;
109
-
110
104
  // Functions for controlling/querying the simulation state
111
105
 
112
106
  /**
@@ -242,17 +236,18 @@ typedef enum gpi_edge {
242
236
  } gpi_edge_e;
243
237
 
244
238
  // The callback registering functions
245
- GPI_EXPORT gpi_cb_hdl gpi_register_timed_callback(
246
- int (*gpi_function)(const void *), void *gpi_cb_data, uint64_t time);
239
+ GPI_EXPORT gpi_cb_hdl gpi_register_timed_callback(int (*gpi_function)(void *),
240
+ void *gpi_cb_data,
241
+ uint64_t time);
247
242
  GPI_EXPORT gpi_cb_hdl gpi_register_value_change_callback(
248
- int (*gpi_function)(const void *), void *gpi_cb_data, gpi_sim_hdl gpi_hdl,
243
+ int (*gpi_function)(void *), void *gpi_cb_data, gpi_sim_hdl gpi_hdl,
249
244
  int edge);
250
- GPI_EXPORT gpi_cb_hdl gpi_register_readonly_callback(
251
- int (*gpi_function)(const void *), void *gpi_cb_data);
252
- GPI_EXPORT gpi_cb_hdl gpi_register_nexttime_callback(
253
- int (*gpi_function)(const void *), void *gpi_cb_data);
254
- GPI_EXPORT gpi_cb_hdl gpi_register_readwrite_callback(
255
- int (*gpi_function)(const void *), void *gpi_cb_data);
245
+ GPI_EXPORT gpi_cb_hdl
246
+ gpi_register_readonly_callback(int (*gpi_function)(void *), void *gpi_cb_data);
247
+ GPI_EXPORT gpi_cb_hdl
248
+ gpi_register_nexttime_callback(int (*gpi_function)(void *), void *gpi_cb_data);
249
+ GPI_EXPORT gpi_cb_hdl
250
+ gpi_register_readwrite_callback(int (*gpi_function)(void *), void *gpi_cb_data);
256
251
 
257
252
  // Calling convention is that 0 = success and negative numbers a failure
258
253
  // For implementers of GPI the provided macro GPI_RET(x) is provided
@@ -34,6 +34,9 @@
34
34
  extern "C" {
35
35
  #endif
36
36
 
37
+ /* used by Cadence Xcelium for packed unions */
38
+ #define vpiUnionNet 525
39
+
37
40
  /* used by Cadence Xcelium for Verilog-AMS */
38
41
  #define vpiRealNet 526
39
42
  #define vpiInterconnectNet 533
@@ -88,7 +88,7 @@ int main(int argc, char** argv) {
88
88
  bool again = true;
89
89
  while (again) {
90
90
  // Evaluate design
91
- top->eval();
91
+ top->eval_step();
92
92
 
93
93
  // Call Value Change callbacks triggered by eval()
94
94
  // These can modify signal values
@@ -101,6 +101,7 @@ int main(int argc, char** argv) {
101
101
  // These can modify signal values
102
102
  again |= settle_value_callbacks();
103
103
  }
104
+ top->eval_end_step();
104
105
 
105
106
  // Call ReadOnly callbacks
106
107
  VerilatedVpi::callCbs(cbReadOnlySynch);
@@ -110,12 +111,15 @@ int main(int argc, char** argv) {
110
111
  #endif
111
112
  // cocotb controls the clock inputs using cbAfterDelay so
112
113
  // skip ahead to the next registered callback
113
- vluint64_t next_time = VerilatedVpi::cbNextDeadline();
114
+ const vluint64_t NO_TOP_EVENTS_PENDING = static_cast<vluint64_t>(~0ULL);
115
+ vluint64_t next_time_cocotb = VerilatedVpi::cbNextDeadline();
116
+ vluint64_t next_time_timing =
117
+ top->eventsPending() ? top->nextTimeSlot() : NO_TOP_EVENTS_PENDING;
118
+ vluint64_t next_time = std::min(next_time_cocotb, next_time_timing);
114
119
 
115
120
  // If there are no more cbAfterDelay callbacks,
116
121
  // the next deadline is max value, so end the simulation now
117
- if (next_time == static_cast<vluint64_t>(~0ULL)) {
118
- vl_finish(__FILE__, __LINE__, "");
122
+ if (next_time == NO_TOP_EVENTS_PENDING) {
119
123
  break;
120
124
  } else {
121
125
  main_time = next_time;
@@ -57,9 +57,18 @@ else ifneq (, $(findstring MSYS, $(OS)))
57
57
  endif
58
58
  export OS
59
59
 
60
+ # Detects if Python is running in a virtual environment
61
+ # https://docs.python.org/3/library/venv.html
62
+ IS_VENV=$(shell $(shell cocotb-config --python-bin) -c 'import sys; print(sys.prefix != sys.base_prefix)')
63
+
60
64
  # this ensures we use the same python as the one cocotb was installed into
61
- # realpath to convert windows paths to unix paths, like cygpath -u
62
- PYTHON_BIN ?= $(realpath $(shell cocotb-config --python-bin))
65
+ ifeq ($(IS_VENV),True)
66
+ # In a virtual environment, the Python binary may be a symlink, so it should not use realpath
67
+ PYTHON_BIN ?= $(shell cocotb-config --python-bin)
68
+ else
69
+ # realpath to convert windows paths to unix paths, like cygpath -u
70
+ PYTHON_BIN ?= $(realpath $(shell cocotb-config --python-bin))
71
+ endif
63
72
 
64
73
  include $(COCOTB_SHARE_DIR)/makefiles/Makefile.deprecations
65
74
 
@@ -70,8 +79,11 @@ ifeq ($(filter $(PYTHON_ARCH),64bit 32bit),)
70
79
  $(error Unknown Python architecture: $(PYTHON_ARCH))
71
80
  endif
72
81
 
73
- # Set PYTHONHOME to properly populate sys.path in embedded python interpreter
74
- export PYTHONHOME := $(shell $(PYTHON_BIN) -c 'import sys; print(sys.prefix)')
82
+ # Changing PYTHONHOME confuses virtual environments, so only set it when not using a venv
83
+ ifeq ($(IS_VENV),False)
84
+ # Set PYTHONHOME to properly populate sys.path in embedded python interpreter
85
+ export PYTHONHOME := $(shell $(PYTHON_BIN) -c 'import sys; print(sys.prefix)')
86
+ endif
75
87
 
76
88
  ifeq ($(OS),Msys)
77
89
  to_tcl_path = $(shell cygpath -m $(1) )
@@ -57,8 +57,8 @@ SIM Selects which simulator Makefile to use
57
57
  WAVES Enable wave traces dump for Riviera-PRO and Questa
58
58
  VERILOG_SOURCES A list of the Verilog source files to include
59
59
  VHDL_SOURCES A list of the VHDL source files to include
60
- VHDL_SOURCES_<lib> VHDL source files to include in *lib* (GHDL/ModelSim/Questa/Xcelium only)
61
- VHDL_LIB_ORDER Compilation order of VHDL libraries (needed for ModelSim/Questa/Xcelium)
60
+ VHDL_SOURCES_<lib> VHDL source files to include in *lib* (GHDL/ModelSim/Questa/Xcelium/Incisive only)
61
+ VHDL_LIB_ORDER Compilation order of VHDL libraries (needed for ModelSim/Questa/Xcelium/Incisive)
62
62
  SIM_CMD_PREFIX Prefix for simulation command invocations
63
63
  COMPILE_ARGS Arguments to pass to compile stage of simulation
64
64
  SIM_ARGS Arguments to pass to execution of compiled simulation
@@ -64,11 +64,30 @@ endif
64
64
 
65
65
  COMPILE_ARGS += -f $(SIM_BUILD)/cmds.f -g2012 # Default to latest SystemVerilog standard
66
66
 
67
+ ifdef VERILOG_INCLUDE_DIRS
68
+ COMPILE_ARGS += $(addprefix -I, $(VERILOG_INCLUDE_DIRS))
69
+ endif
70
+
67
71
  # Compilation phase
72
+
73
+ ifeq ($(WAVES), 1)
74
+ VERILOG_SOURCES += $(SIM_BUILD)/cocotb_iverilog_dump.v
75
+ COMPILE_ARGS += -s cocotb_iverilog_dump
76
+ PLUSARGS += -fst
77
+ endif
78
+
68
79
  $(SIM_BUILD)/sim.vvp: $(VERILOG_SOURCES) $(CUSTOM_COMPILE_DEPS) | $(SIM_BUILD)
69
80
  @echo "+timescale+$(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION)" > $(SIM_BUILD)/cmds.f
70
81
  $(CMD) -o $(SIM_BUILD)/sim.vvp -D COCOTB_SIM=1 $(TOPMODULE_ARG) $(COMPILE_ARGS) $(EXTRA_ARGS) $(VERILOG_SOURCES)
71
82
 
83
+ $(SIM_BUILD)/cocotb_iverilog_dump.v: | $(SIM_BUILD)
84
+ @echo 'module cocotb_iverilog_dump();' > $@
85
+ @echo 'initial begin' >> $@
86
+ @echo ' $$dumpfile("$(SIM_BUILD)/$(TOPLEVEL).fst");' >> $@
87
+ @echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@
88
+ @echo 'end' >> $@
89
+ @echo 'endmodule' >> $@
90
+
72
91
  # Execution phase
73
92
 
74
93
  $(COCOTB_RESULTS_FILE): $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS)
@@ -47,6 +47,10 @@ else
47
47
  export IUS_BIN_DIR
48
48
  endif
49
49
 
50
+ ifdef VERILOG_INCLUDE_DIRS
51
+ COMPILE_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
52
+ endif
53
+
50
54
  EXTRA_ARGS += $(COMPILE_ARGS)
51
55
  EXTRA_ARGS += $(SIM_ARGS)
52
56
  EXTRA_ARGS += -licqueue
@@ -97,13 +101,20 @@ else
97
101
  $(error A valid value (verilog or vhdl) was not provided for TOPLEVEL_LANG=$(TOPLEVEL_LANG))
98
102
  endif
99
103
 
104
+ # Builds a list of arguments to support VHDL libraries specified in VHDL_SOURCES_*:
105
+ LIBS := $(foreach LIB, $(VHDL_LIB_ORDER),-makelib $(LIB) $(VHDL_SOURCES_$(LIB)) -endlib)
106
+
100
107
  $(COCOTB_RESULTS_FILE): $(HDL_SOURCES) $(CUSTOM_COMPILE_DEPS) $(CUSTOM_SIM_DEPS) | $(SIM_BUILD)
101
108
  $(RM) $(COCOTB_RESULTS_FILE)
102
109
 
110
+ # Make sure all libs in SOURCES_VHDL_* are mentioned in VHDL_LIB_ORDER and vice versa
111
+ $(foreach LIB, $(VHDL_LIB_ORDER), $(check_vhdl_sources))
112
+ $(foreach SOURCES_VAR, $(filter VHDL_SOURCES_%, $(.VARIABLES)), $(check_lib_order))
113
+
103
114
  set -o pipefail; \
104
115
  MODULE=$(MODULE) TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) GPI_EXTRA=$(GPI_EXTRA) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
105
116
  $(SIM_CMD_PREFIX) $(CMD) -timescale $(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION) \
106
- $(EXTRA_ARGS) $(GPI_ARGS) +access+rwc $(MAKE_LIB) $(HDL_SOURCES) $(PLUSARGS) 2>&1 | tee $(SIM_BUILD)/sim.log
117
+ $(EXTRA_ARGS) $(GPI_ARGS) +access+rwc $(LIBS) $(MAKE_LIB) $(HDL_SOURCES) $(PLUSARGS) 2>&1 | tee $(SIM_BUILD)/sim.log
107
118
 
108
119
  $(call check_for_results_file)
109
120
 
@@ -54,7 +54,7 @@ endif
54
54
  COMPILE_ARGS += +acc
55
55
 
56
56
  ifdef VERILOG_INCLUDE_DIRS
57
- VLOG_ARGS += +incdir+$(VERILOG_INCLUDE_DIRS)
57
+ VLOG_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
58
58
  endif
59
59
 
60
60
  # below allows for maintaining legacy syntax as well as enables using cross-simulator vars COMPILE_ARGS/SIM_ARGS
@@ -88,6 +88,7 @@ ifeq ($(filter vhpi fli,$(VHDL_GPI_INTERFACE)),)
88
88
  endif
89
89
 
90
90
  ifeq ($(TOPLEVEL_LANG),vhdl)
91
+ VSIM_ARGS += -t $(COCOTB_HDL_TIMEPRECISION)
91
92
  ifeq ($(VHDL_GPI_INTERFACE),fli)
92
93
  CUSTOM_COMPILE_DEPS += $(FLI_LIB)
93
94
  VSIM_ARGS += -foreign \"cocotb_init $(FLI_LIB)\"
@@ -57,6 +57,10 @@ endif
57
57
 
58
58
  ALOG_ARGS += -timescale $(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION)
59
59
 
60
+ ifdef VERILOG_INCLUDE_DIRS
61
+ ALOG_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
62
+ endif
63
+
60
64
  # below allows for maintaining legacy syntax as well as enables using cross-simulator vars COMPILE_ARGS/SIM_ARGS
61
65
  ALOG_ARGS += $(COMPILE_ARGS)
62
66
  ACOM_ARGS += $(COMPILE_ARGS)
@@ -53,6 +53,10 @@ else
53
53
  export VCS_BIN_DIR
54
54
  endif
55
55
 
56
+ ifdef VERILOG_INCLUDE_DIRS
57
+ COMPILE_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
58
+ endif
59
+
56
60
  ifeq ($(PYTHON_ARCH),64bit)
57
61
  EXTRA_ARGS += -full64
58
62
  endif
@@ -36,7 +36,7 @@ else
36
36
  endif
37
37
 
38
38
  ifeq ($(VERILATOR_SIM_DEBUG), 1)
39
- COMPILE_ARGS += --debug -CFLAGS "-DVL_DEBUG -g"
39
+ COMPILE_ARGS += --debug -CFLAGS "-DVL_DEBUG -DVERILATOR_SIM_DEBUG -g"
40
40
  PLUSARGS += +verilator+debug
41
41
  BUILD_ARGS += OPT_FAST=-Og OPT_SLOW=-Og OPT_GLOBAL=-Og
42
42
  endif
@@ -49,6 +49,10 @@ EXTRA_ARGS += --timescale $(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION)
49
49
 
50
50
  COMPILE_ARGS += --vpi --public-flat-rw --prefix Vtop -o Vtop -LDFLAGS "-Wl,-rpath,$(shell cocotb-config --lib-dir) -L$(shell cocotb-config --lib-dir) -lcocotbvpi_verilator"
51
51
 
52
+ ifdef VERILOG_INCLUDE_DIRS
53
+ COMPILE_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
54
+ endif
55
+
52
56
  $(SIM_BUILD)/Vtop.mk: $(VERILOG_SOURCES) $(CUSTOM_COMPILE_DEPS) $(COCOTB_SHARE_DIR)/lib/verilator/verilator.cpp | $(SIM_BUILD)
53
57
  $(CMD) -cc --exe -Mdir $(SIM_BUILD) -DCOCOTB_SIM=1 $(TOPMODULE_ARG) $(COMPILE_ARGS) $(EXTRA_ARGS) $(VERILOG_SOURCES) $(COCOTB_SHARE_DIR)/lib/verilator/verilator.cpp
54
58
 
@@ -47,6 +47,10 @@ else
47
47
  export XCELIUM_BIN_DIR
48
48
  endif
49
49
 
50
+ ifdef VERILOG_INCLUDE_DIRS
51
+ COMPILE_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
52
+ endif
53
+
50
54
  EXTRA_ARGS += $(COMPILE_ARGS)
51
55
  EXTRA_ARGS += $(SIM_ARGS)
52
56
  EXTRA_ARGS += -licqueue
@@ -73,7 +77,7 @@ else
73
77
  endif
74
78
 
75
79
  # Xcelium errors out if multiple timescales are specified on the command line.
76
- ifneq (,$(findstring timescale,$(EXTRA_ARGS)))
80
+ ifneq (,$(filter -timescale%,$(EXTRA_ARGS)))
77
81
  $(error Please use COCOTB_HDL_TIMEUNIT and COCOTB_HDL_TIMEPRECISION to specify timescale.)
78
82
  endif
79
83
 
Binary file
Binary file
Binary file