ruby-vpi 12.1.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/bin/generate_test.rb +4 -5
  2. data/bin/generate_test_tpl/bench.rb +2 -0
  3. data/bin/generate_test_tpl/bench.v +4 -11
  4. data/bin/header_to_ruby.rb +0 -1
  5. data/doc/history.html +281 -206
  6. data/doc/history.rb +1 -1
  7. data/doc/history.yml +66 -35
  8. data/doc/manual.html +3 -3
  9. data/doc/memo.doc +2 -0
  10. data/doc/memo.html +5 -0
  11. data/doc/readme.doc +16 -8
  12. data/doc/readme.html +19 -13
  13. data/doc/rss.xml +7 -0
  14. data/ext/common.h +1 -0
  15. data/ext/{swig.c → main.c} +32 -6
  16. data/ext/{swig.h → main.h} +8 -7
  17. data/ext/relay.c +7 -83
  18. data/ext/relay.h +7 -5
  19. data/ext/swig_vpi.i +10 -3
  20. data/ext/swig_wrap.cin +4 -1
  21. data/ext/verilog.h +26 -10
  22. data/ext/vlog.c +16 -23
  23. data/ext/vlog.h +5 -19
  24. data/lib/ruby-vpi/rcov.rb +3 -3
  25. data/lib/ruby-vpi/runner.rb +5 -2
  26. data/lib/ruby-vpi/vpi.rb +1 -1
  27. data/lib/ruby-vpi.rb +57 -5
  28. data/ref/c/annotated.html +1 -7
  29. data/ref/c/common_8h.html +2 -1
  30. data/ref/c/files.html +3 -5
  31. data/ref/c/functions.html +24 -46
  32. data/ref/c/functions_vars.html +24 -46
  33. data/ref/c/globals.html +5 -210
  34. data/ref/c/globals_0x63.html +32 -48
  35. data/ref/c/globals_0x65.html +3 -9
  36. data/ref/c/globals_0x66.html +3 -19
  37. data/ref/c/globals_0x6d.html +5 -10
  38. data/ref/c/globals_0x70.html +19 -25
  39. data/ref/c/globals_0x72.html +8 -18
  40. data/ref/c/globals_0x73.html +11 -198
  41. data/ref/c/globals_0x74.html +2 -8
  42. data/ref/c/globals_0x76.html +419 -427
  43. data/ref/c/globals_0x78.html +3 -9
  44. data/ref/c/globals_defs.html +30 -35
  45. data/ref/c/globals_defs_0x65.html +2 -7
  46. data/ref/c/globals_defs_0x70.html +3 -8
  47. data/ref/c/globals_defs_0x76.html +416 -420
  48. data/ref/c/globals_defs_0x78.html +2 -7
  49. data/ref/c/globals_enum.html +1 -1
  50. data/ref/c/globals_eval.html +1 -1
  51. data/ref/c/globals_func.html +13 -173
  52. data/ref/c/globals_type.html +26 -29
  53. data/ref/c/globals_vars.html +4 -88
  54. data/ref/c/index.html +1 -1
  55. data/ref/c/{swig_8c.html → main_8c.html} +16 -14
  56. data/ref/c/{swig_8h.html → main_8h.html} +15 -14
  57. data/ref/c/relay_8c.html +25 -38
  58. data/ref/c/relay_8h.html +16 -15
  59. data/ref/c/structt__cb__data.html +6 -23
  60. data/ref/c/structt__vpi__delay.html +3 -20
  61. data/ref/c/structt__vpi__error__info.html +3 -71
  62. data/ref/c/structt__vpi__strengthval.html +3 -3
  63. data/ref/c/structt__vpi__systf__data.html +12 -46
  64. data/ref/c/structt__vpi__time.html +3 -3
  65. data/ref/c/structt__vpi__value.html +3 -113
  66. data/ref/c/structt__vpi__vecval.html +3 -3
  67. data/ref/c/structt__vpi__vlog__info.html +3 -54
  68. data/ref/c/verilog_8h.html +69 -3
  69. data/ref/c/vlog_8c.html +16 -61
  70. data/ref/c/vlog_8h.html +14 -57
  71. data/ref/c/vpi__user_8h.html +16 -16
  72. data/ref/ruby/classes/ERB.html +5 -5
  73. data/ref/ruby/classes/ERB.src/{M000032.html → M000026.html} +0 -0
  74. data/ref/ruby/classes/FileUtils.html +10 -10
  75. data/ref/ruby/classes/FileUtils.src/{M000034.html → M000027.html} +0 -0
  76. data/ref/ruby/classes/FileUtils.src/{M000035.html → M000028.html} +0 -0
  77. data/ref/ruby/classes/Float.html +5 -5
  78. data/ref/ruby/classes/Float.src/{M000027.html → M000022.html} +0 -0
  79. data/ref/ruby/classes/Integer.html +68 -68
  80. data/ref/ruby/classes/Integer.src/M000008.html +25 -0
  81. data/ref/ruby/classes/Integer.src/M000009.html +18 -0
  82. data/ref/ruby/classes/Integer.src/{M000014.html → M000010.html} +0 -0
  83. data/ref/ruby/classes/Integer.src/{M000015.html → M000011.html} +0 -0
  84. data/ref/ruby/classes/Integer.src/M000012.html +5 -12
  85. data/ref/ruby/classes/Integer.src/M000013.html +5 -5
  86. data/ref/ruby/classes/Integer.src/M000016.html +9 -5
  87. data/ref/ruby/classes/Integer.src/M000017.html +9 -5
  88. data/ref/ruby/classes/Integer.src/{M000022.html → M000018.html} +0 -0
  89. data/ref/ruby/classes/Integer.src/{M000023.html → M000019.html} +0 -0
  90. data/ref/ruby/classes/Integer.src/M000020.html +12 -9
  91. data/ref/ruby/classes/Integer.src/M000021.html +17 -9
  92. data/ref/ruby/classes/RDoc.html +5 -5
  93. data/ref/ruby/classes/RDoc.src/{M000050.html → M000041.html} +0 -0
  94. data/ref/ruby/classes/RubyVpi.html +29 -24
  95. data/ref/ruby/classes/RubyVpi.src/M000029.html +142 -0
  96. data/ref/ruby/classes/String.html +15 -15
  97. data/ref/ruby/classes/String.src/{M000029.html → M000023.html} +0 -0
  98. data/ref/ruby/classes/String.src/{M000030.html → M000024.html} +0 -0
  99. data/ref/ruby/classes/String.src/{M000031.html → M000025.html} +0 -0
  100. data/ref/ruby/classes/VerilogParser/Module/Parameter.html +5 -5
  101. data/ref/ruby/classes/VerilogParser/Module/Parameter.src/{M000011.html → M000007.html} +0 -0
  102. data/ref/ruby/classes/VerilogParser/Module/Port.html +20 -20
  103. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000007.html → M000003.html} +0 -0
  104. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000008.html → M000004.html} +0 -0
  105. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000009.html → M000005.html} +0 -0
  106. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000010.html → M000006.html} +0 -0
  107. data/ref/ruby/classes/VerilogParser/Module.html +5 -5
  108. data/ref/ruby/classes/VerilogParser/Module.src/{M000006.html → M000002.html} +0 -0
  109. data/ref/ruby/classes/VerilogParser.html +5 -5
  110. data/ref/ruby/classes/VerilogParser.src/{M000005.html → M000001.html} +0 -0
  111. data/ref/ruby/classes/Vpi/Handle.html +56 -62
  112. data/ref/ruby/classes/Vpi/Handle.src/M000030.html +18 -0
  113. data/ref/ruby/classes/Vpi/Handle.src/{M000039.html → M000031.html} +0 -0
  114. data/ref/ruby/classes/Vpi/Handle.src/M000032.html +18 -0
  115. data/ref/ruby/classes/Vpi/Handle.src/{M000041.html → M000033.html} +0 -0
  116. data/ref/ruby/classes/Vpi/Handle.src/{M000042.html → M000034.html} +0 -0
  117. data/ref/ruby/classes/Vpi/Handle.src/{M000043.html → M000035.html} +0 -0
  118. data/ref/ruby/classes/Vpi/Handle.src/{M000044.html → M000036.html} +0 -0
  119. data/ref/ruby/classes/Vpi/Handle.src/{M000045.html → M000037.html} +0 -0
  120. data/ref/ruby/classes/Vpi/Handle.src/M000038.html +11 -5
  121. data/ref/ruby/classes/Vpi/Handle.src/M000040.html +55 -5
  122. data/ref/ruby/created.rid +1 -1
  123. data/ref/ruby/files/bin/generate_test_rb.html +1 -49
  124. data/ref/ruby/files/bin/header_to_ruby_rb.html +1 -1
  125. data/ref/ruby/files/lib/ruby-vpi/rcov_rb.html +1 -1
  126. data/ref/ruby/files/lib/ruby-vpi/runner_rb.html +1 -48
  127. data/ref/ruby/files/lib/ruby-vpi/vpi_rb.html +1 -1
  128. data/ref/ruby/files/lib/ruby-vpi_rb.html +1 -1
  129. data/ref/ruby/fr_class_index.html +0 -5
  130. data/ref/ruby/fr_method_index.html +41 -50
  131. data/samp/counter/counter_rspec_bench.rb +2 -0
  132. data/samp/counter/counter_rspec_bench.v +4 -11
  133. data/samp/counter/counter_rspec_design.rb +2 -2
  134. data/samp/counter/counter_xunit_bench.rb +2 -0
  135. data/samp/counter/counter_xunit_bench.v +4 -11
  136. data/samp/counter/counter_xunit_design.rb +2 -2
  137. data/samp/pipelined_alu/hw5_unit_test_bench.rb +2 -0
  138. data/samp/pipelined_alu/hw5_unit_test_bench.v +4 -11
  139. metadata +37 -85
  140. data/ref/c/globals_0x62.html +0 -62
  141. data/ref/c/globals_0x67.html +0 -64
  142. data/ref/c/globals_0x69.html +0 -62
  143. data/ref/c/globals_0x6c.html +0 -64
  144. data/ref/c/globals_0x6e.html +0 -63
  145. data/ref/c/globals_0x75.html +0 -63
  146. data/ref/c/globals_defs_0x6c.html +0 -57
  147. data/ref/c/globals_defs_0x6e.html +0 -56
  148. data/ref/c/globals_defs_0x72.html +0 -57
  149. data/ref/c/globals_defs_0x73.html +0 -164
  150. data/ref/c/globals_defs_0x75.html +0 -56
  151. data/ref/c/globals_func_0x66.html +0 -62
  152. data/ref/c/globals_func_0x67.html +0 -55
  153. data/ref/c/globals_func_0x69.html +0 -53
  154. data/ref/c/globals_func_0x70.html +0 -53
  155. data/ref/c/globals_func_0x72.html +0 -57
  156. data/ref/c/globals_func_0x73.html +0 -114
  157. data/ref/c/globals_func_0x76.html +0 -57
  158. data/ref/c/structrelay____RubyOptions____def.html +0 -73
  159. data/ref/c/structswig__cast__info.html +0 -98
  160. data/ref/c/structswig__class.html +0 -115
  161. data/ref/c/structswig__module__info.html +0 -132
  162. data/ref/c/structswig__type__info.html +0 -132
  163. data/ref/c/swig__vpi_8h.html +0 -8739
  164. data/ref/c/swig__wrap_8cin.html +0 -11556
  165. data/ref/c/unions__vpi__value__value.html +0 -166
  166. data/ref/ruby/classes/Integer.src/M000024.html +0 -25
  167. data/ref/ruby/classes/Integer.src/M000025.html +0 -30
  168. data/ref/ruby/classes/OutputInfo.html +0 -294
  169. data/ref/ruby/classes/OutputInfo.src/M000026.html +0 -50
  170. data/ref/ruby/classes/RubyVpi.src/M000036.html +0 -107
  171. data/ref/ruby/classes/RubyVpi.src/M000037.html +0 -20
  172. data/ref/ruby/classes/Template.html +0 -158
  173. data/ref/ruby/classes/Template.src/M000028.html +0 -18
  174. data/ref/ruby/classes/Vpi/Handle/Property.html +0 -130
  175. data/ref/ruby/classes/Vpi/Handle/Property.src/M000049.html +0 -80
  176. data/ref/ruby/classes/Vpi/Handle.src/M000046.html +0 -24
  177. data/ref/ruby/classes/Vpi/Handle.src/M000048.html +0 -68
  178. data/ref/ruby/classes/XX/XMLish.html +0 -138
  179. data/ref/ruby/classes/XX/XMLish.src/M000033.html +0 -18
  180. data/ref/ruby/classes/XX.html +0 -111
  181. data/ref/ruby/files/bin/generate_test_rb.src/M000001.html +0 -18
  182. data/ref/ruby/files/bin/generate_test_rb.src/M000002.html +0 -38
  183. data/ref/ruby/files/lib/ruby-vpi/runner_rb.src/M000003.html +0 -24
  184. data/ref/ruby/files/lib/ruby-vpi/runner_rb.src/M000004.html +0 -26
data/ext/relay.c CHANGED
@@ -20,12 +20,8 @@
20
20
  */
21
21
 
22
22
  #include "relay.h"
23
-
24
- #include "swig.h"
25
- #include "common.h"
23
+ #include "main.h"
26
24
  #include <pthread.h>
27
- #include <ruby.h>
28
- #include <assert.h>
29
25
 
30
26
 
31
27
  pthread_t relay__rubyThread;
@@ -49,86 +45,14 @@ void relay_verilog() {
49
45
  pthread_mutex_lock(&relay__rubyLock);
50
46
  }
51
47
 
52
- /**
53
- Stores command-line options for the Ruby interpreter.
54
- */
55
- typedef struct {
56
- PLI_BYTE8** mArgs; /// Array of command-line arguments.
57
- unsigned int mCount; /// Number of command-line arguments.
58
- } relay__RubyOptions__def;
59
-
60
- /**
61
- @param apRubyOptions relay__RubyOptions__def structure which contains command-line options passsed to the Ruby interpreter.
62
- @note The structure will be freed *deeply* after use.
63
- */
64
- void* ruby_run_handshake(void* apRubyOptions) {
65
- ruby_init();
66
- ruby_init_loadpath();
67
-
68
- swig_init();
69
-
70
- // pass command-line arguments to the interpreter
71
- relay__RubyOptions__def* pRubyOptions = (relay__RubyOptions__def*) apRubyOptions;
72
-
73
- PLI_BYTE8** argv = pRubyOptions->mArgs;
74
- unsigned int argc = pRubyOptions->mCount;
75
-
76
- ruby_options(argc, argv);
77
-
78
- // free the memory used by command-line options
79
- unsigned int i;
80
- for (i = 0; i < argc; i++) {
81
- free(argv[i]);
82
- }
83
-
84
- free(argv);
85
- free(pRubyOptions);
86
-
87
- ruby_run();
88
- ruby_finalize();
89
-
48
+ void* relay_main_handshake(void* aDummy) {
49
+ main_init();
90
50
  return NULL;
91
51
  }
92
52
 
93
- void relay_ruby_run() {
94
- relay__RubyOptions__def* pRubyOptions = malloc(sizeof(relay__RubyOptions__def));
95
-
96
- if (pRubyOptions) {
97
- pRubyOptions->mArgs = NULL;
98
- pRubyOptions->mCount = 0;
99
-
100
- // transform the arguments passed to this function by Verilog into command-line arguments for Ruby interpeter
101
- vpiHandle vCall = vpi_handle(vpiSysTfCall, NULL);
102
-
103
- if (vCall) {
104
- vpiHandle vCallArgs = vpi_iterate(vpiArgument, vCall);
105
-
106
- if (vCallArgs) {
107
- vpiHandle vArg;
108
- s_vpi_value argVal;
109
- argVal.format = vpiStringVal;
110
-
111
- while (vArg = vpi_scan(vCallArgs)) {
112
- pRubyOptions->mCount++;
53
+ void relay_main() {
54
+ pthread_create(&relay__rubyThread, 0, relay_main_handshake, NULL);
113
55
 
114
- // grow the options struct to hold more options
115
- if (pRubyOptions->mArgs == NULL)
116
- pRubyOptions->mArgs = malloc(sizeof(PLI_BYTE8*) * pRubyOptions->mCount);
117
- else
118
- pRubyOptions->mArgs = realloc(pRubyOptions->mArgs, sizeof(PLI_BYTE8*) * pRubyOptions->mCount);
119
-
120
- assert(pRubyOptions->mArgs != NULL);
121
-
122
- vpi_get_value(vArg, &argVal);
123
- pRubyOptions->mArgs[pRubyOptions->mCount - 1] = strdup(argVal.value.str);
124
- }
125
- }
126
- }
127
-
128
- pthread_create(&relay__rubyThread, 0, ruby_run_handshake, pRubyOptions);
129
- return;
130
- }
131
-
132
- common_printf("error: unable to allocate memory for Ruby's command-line arguments.");
133
- exit(EXIT_FAILURE);
56
+ // XXX: freezee verilog because RubyVpi.init_bench will call relay_verilog (which assumes that verilog is frozen)
57
+ pthread_mutex_lock(&relay__verilogLock);
134
58
  }
data/ext/relay.h CHANGED
@@ -25,24 +25,26 @@
25
25
  #ifndef RELAY_H
26
26
  #define RELAY_H
27
27
 
28
+ #include "common.h"
29
+
28
30
  /**
29
- Initialize the relay mechanism, which enables Verilog code to transfer control to Ruby code and vice versa.
31
+ Initialize the relay mechanism, which enables Verilog to transfer control to Ruby and vice versa.
30
32
  */
31
33
  void relay_init();
32
34
 
33
35
  /**
34
- Transfers control to Ruby code.
36
+ Transfers control to Ruby.
35
37
  */
36
38
  void relay_ruby();
37
39
 
38
40
  /**
39
- Transfers control to Verilog code.
41
+ Transfers control to Verilog.
40
42
  */
41
43
  void relay_verilog();
42
44
 
43
45
  /**
44
- Starts the Ruby interpreter.
46
+ Transfers control to the main layer.
45
47
  */
46
- inline void relay_ruby_run();
48
+ void relay_main();
47
49
 
48
50
  #endif
data/ext/swig_vpi.i CHANGED
@@ -1,8 +1,15 @@
1
1
  %module vpi
2
+
3
+
4
+ /* Parse the header file to generate wrappers */
2
5
  %{
3
- /* Includes the header in the wrapper code */
4
6
  #include "swig_vpi.h"
5
7
  %}
6
-
7
- /* Parse the header file to generate wrappers */
8
8
  %include "swig_vpi.h"
9
+
10
+
11
+ /* allows us to set S_cb_data.cb_rtn = Vpi::Vlog_relay_ruby from Ruby */
12
+ %{
13
+ #include "vlog.h"
14
+ %}
15
+ %constant PLI_INT32 vlog_relay_ruby(struct t_cb_data *);
data/ext/swig_wrap.cin CHANGED
@@ -1511,7 +1511,6 @@ static VALUE mVpi;
1511
1511
  #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1512
1512
 
1513
1513
 
1514
- /* Includes the header in the wrapper code */
1515
1514
  #include "swig_vpi.h"
1516
1515
 
1517
1516
 
@@ -1766,6 +1765,9 @@ SWIG_FromCharPtr(const char *cptr)
1766
1765
  return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
1767
1766
  }
1768
1767
 
1768
+
1769
+ #include "vlog.h"
1770
+
1769
1771
  swig_class cS_vpi_time;
1770
1772
 
1771
1773
  SWIGINTERN VALUE
@@ -7127,5 +7129,6 @@ SWIGEXPORT void Init_vpi(void) {
7127
7129
  rb_define_module_function(mVpi, "vpi_handle_by_multi_index", _wrap_vpi_handle_by_multi_index, -1);
7128
7130
  rb_define_singleton_method(mVpi, "vlog_startup_routines", vlog_startup_routines_get, 0);
7129
7131
  rb_define_singleton_method(mVpi, "vlog_startup_routines=", vlog_startup_routines_set, 1);
7132
+ rb_define_const(mVpi, "Vlog_relay_ruby", SWIG_NewFunctionPtrObj((void *)vlog_relay_ruby, SWIGTYPE_p_f_p_struct_t_cb_data__int));
7130
7133
  }
7131
7134
 
data/ext/verilog.h CHANGED
@@ -22,25 +22,31 @@
22
22
  */
23
23
 
24
24
  #ifndef VERILOG_H
25
- #define VERILOG_H
25
+ #define VERILOG_H
26
26
 
27
- // Use our verbatim copy of the official IEEE Std. 1364-2005 header file, which was obtained from this URL: <http://www.boydtechinc.com/ptf/archive/ptf_2005/0737.html>
27
+ /*
28
+ Use our verbatim copy of the official IEEE Std. 1364-2005 header file, which was obtained from this URL: <http://www.boydtechinc.com/ptf/archive/ptf_2005/0737.html>
29
+ */
28
30
  #include "vpi_user.h"
29
31
 
30
- // Adjust for the peculiarities of the Verilog simulator being used.
32
+ /*
33
+ Adjust for the peculiarities of the Verilog simulator being used.
34
+ */
31
35
  #ifdef SYNOPSYS_VCS
32
36
  #define VERILOG_LENIENT
33
37
  #endif
34
38
 
35
- // Do we want to enforce strict compliance with IEEE Std. 1364-2001? If so, Ruby-VPI might not work with Synopsys VCS, but that's not our fault. ;-)
36
- #define verilog_tf_funcPtr_strict(aPtrName) \
39
+ /*
40
+ Do we want to enforce strict compliance with IEEE Std. 1364-2001? If so, Ruby-VPI might not work with Synopsys VCS, but that's not our fault. ;-)
41
+ */
42
+ #define verilog_tf_funcPtr_strict(aPtrName) \
37
43
  PLI_INT32 (*aPtrName)(PLI_BYTE8*)
38
44
 
39
45
  #ifdef VERILOG_LENIENT
40
- #define verilog_tf_funcPtr(aPtrName) \
46
+ #define verilog_tf_funcPtr(aPtrName) \
41
47
  void (*aPtrName)(void)
42
48
 
43
- #define verilog_tf_funcSig(aFuncName) \
49
+ #define verilog_tf_funcSig(aFuncName) \
44
50
  void aFuncName(void)
45
51
 
46
52
  #define verilog_tf_funcReturn(aReturnVal) \
@@ -48,11 +54,21 @@
48
54
  #else
49
55
  #define verilog_tf_funcPtr verilog_tf_funcPtr_strict
50
56
 
51
- #define verilog_tf_funcSig(aFuncName) \
52
- PLI_INT32 aFuncName(PLI_BYTE8* aDummy)
57
+ #define verilog_tf_funcSig(aFuncName) \
58
+ PLI_INT32 aFuncName(PLI_BYTE8* aArg)
53
59
 
54
- #define verilog_tf_funcReturn(aReturnVal) \
60
+ #define verilog_tf_funcReturn(aReturnVal) \
55
61
  return aReturnVal
56
62
  #endif
57
63
 
64
+
65
+ #define verilog_cb_funcPtr(aPtrName) \
66
+ PLI_INT32 (*aPtrName)(p_cb_data)
67
+
68
+ #define verilog_cb_funcSig(aFuncName) \
69
+ PLI_INT32 aFuncName(p_cb_data aArg)
70
+
71
+ #define verilog_cb_funcReturn(aReturnVal) \
72
+ return aReturnVal
73
+
58
74
  #endif
data/ext/vlog.c CHANGED
@@ -20,42 +20,35 @@
20
20
  */
21
21
 
22
22
  #include "vlog.h"
23
-
24
23
  #include "relay.h"
25
- #include <stdlib.h>
26
24
 
27
25
 
28
- verilog_tf_funcSig(vlog_ruby_init) {
26
+ verilog_cb_funcSig(vlog_relay_main) {
29
27
  relay_init();
30
- relay_ruby_run();
31
- verilog_tf_funcReturn(0);
28
+ relay_main();
29
+ verilog_cb_funcReturn(0);
32
30
  }
33
31
 
34
- verilog_tf_funcSig(vlog_ruby_relay) {
32
+ verilog_cb_funcSig(vlog_relay_ruby) {
35
33
  relay_ruby();
36
- verilog_tf_funcReturn(0);
34
+ verilog_cb_funcReturn(0);
37
35
  }
38
36
 
39
- void vlog_bind_task(PLI_BYTE8* apTaskName, verilog_tf_funcPtr(apTaskDef)) {
40
- s_vpi_systf_data tf;
41
-
42
- tf.type = vpiSysTask;
43
- tf.sysfunctype = 0;
44
- tf.tfname = apTaskName;
45
- tf.calltf = (verilog_tf_funcPtr_strict())apTaskDef;
46
- tf.compiletf = NULL;
47
- tf.sizetf = NULL;
48
- tf.user_data = NULL;
49
-
50
- vpi_register_systf(&tf);
51
- }
52
37
 
53
38
  /**
54
- Binds the default VPI tasks (provided by Ruby-VPI) before the Verilog simulator begins to simulate.
39
+ Registers a callback at start of simulation to vlog_relay_main();
55
40
  */
56
41
  void vlog_startup() {
57
- vlog_bind_task("$ruby_init", vlog_ruby_init);
58
- vlog_bind_task("$ruby_relay", vlog_ruby_relay);
42
+ s_cb_data call;
43
+
44
+ call.reason = cbStartOfSimulation;
45
+ call.cb_rtn = vlog_relay_main;
46
+ call.obj = NULL;
47
+ call.time = NULL;
48
+ call.value = NULL;
49
+ call.user_data = NULL;
50
+
51
+ vpi_free_object(vpi_register_cb(&call));
59
52
  }
60
53
 
61
54
  void (*vlog_startup_routines[])() = { vlog_startup, 0 };
data/ext/vlog.h CHANGED
@@ -24,31 +24,17 @@
24
24
  #ifndef VLOG_H
25
25
  #define VLOG_H
26
26
 
27
+ #include "common.h"
27
28
  #include "verilog.h"
28
29
 
29
-
30
- /**
31
- Callback for the $ruby_relay VPI task. Transfers control from Verilog to Ruby code.
32
- */
33
- verilog_tf_funcSig(vlog_ruby_relay);
34
-
35
30
  /**
36
- Callback for the $ruby_init VPI task. Initializes and starts the Ruby interpreter with the same arguments as those given to the VPI task-call.
37
-
38
- For example, to start the Ruby interpreter with the "-w" option and with the "hello_world.rb" script, the Verilog code would have a statement like this:
39
- - <tt>$ruby_init("-w", "hello_world.rb");</tt>
31
+ Relays control to the main layer.
40
32
  */
41
- verilog_tf_funcSig(vlog_ruby_init);
33
+ verilog_cb_funcSig(vlog_relay_main);
42
34
 
43
35
  /**
44
- Binds a C function to a VPI task, so that Verilog code can invoke the C function by calling the VPI task.
45
-
46
- For example, if we bound a VPI task named "$hello_world" to the C function hello_world(), then the hello_world() function would be invoked whenever Verilog code called the "$hello_world" VPI task.
47
-
48
- @param apTaskName Name of the VPI task. For example, "$hello_world".
49
-
50
- @param apTaskDef The C function which you want to associate with the given VPI task. For example, hello_world().
36
+ Relays control from Verilog to Ruby.
51
37
  */
52
- void vlog_bind_task(PLI_BYTE8* apTaskName, verilog_tf_funcPtr(apTaskDef));
38
+ verilog_cb_funcSig(vlog_relay_ruby);
53
39
 
54
40
  #endif
data/lib/ruby-vpi/rcov.rb CHANGED
@@ -24,7 +24,7 @@ require 'rcov'
24
24
  # satisfy dependencies of 'rcov/report'
25
25
  require 'xx'
26
26
 
27
- module XX
27
+ module XX # :nodoc: all
28
28
  module XMLish
29
29
  include Markup
30
30
 
@@ -53,8 +53,8 @@ module RubyVpi
53
53
  end
54
54
  end
55
55
 
56
- # Invokes the given block after code coverage analysis has completed.
57
- def RubyVpi.with_coverage_analysis &aBlock # :yields: Rcov::CodeCoverageAnalyzer
56
+ # Invokes the given block, which yields COVERAGE_ANALYSIS, after code coverage analysis has completed.
57
+ def RubyVpi.with_coverage_analysis &aBlock # :nodoc:
58
58
  if aBlock
59
59
  COVERAGE_ANALYSIS_HANDLERS << aBlock
60
60
  end
@@ -51,6 +51,9 @@
51
51
  src
52
52
  end
53
53
 
54
+ # prepare hook for rb_load_file() in main.c
55
+ ENV['RUBY_VPI__RUBY_BENCH_FILE'] = SIMULATOR_TARGET + '.rb'
56
+
54
57
 
55
58
  require 'rake/clean'
56
59
  require 'ruby-vpi'
@@ -63,7 +66,7 @@ BOOTSTAP_FUNC = 'vlog_startup_routines_bootstrap'
63
66
 
64
67
 
65
68
  # Returns the path to the Ruby-VPI object file for the given simulator.
66
- def object_file_path aSimId
69
+ def object_file_path aSimId # :nodoc:
67
70
  path = File.join(OBJECT_PATH, "#{PROJECT_ID}.#{aSimId}.so")
68
71
 
69
72
  unless File.exist? path
@@ -74,7 +77,7 @@ def object_file_path aSimId
74
77
  end
75
78
 
76
79
  # Returns an array of include-directory options.
77
- def expand_include_dir_options aSimId, aIncludes = SIMULATOR_INCLUDES
80
+ def expand_include_dir_options aSimId, aIncludes = SIMULATOR_INCLUDES # :nodoc:
78
81
  prefix = case aSimId
79
82
  when :ivl
80
83
  '-I'
data/lib/ruby-vpi/vpi.rb CHANGED
@@ -277,7 +277,7 @@ module Vpi
277
277
  Property = Struct.new :type, :name, :operation, :accessor, :assignment
278
278
 
279
279
  # Resolves the given shorthand name into a description of its VPI property.
280
- def Property.resolve aName
280
+ def Property.resolve aName # :nodoc:
281
281
  # parse the given property name
282
282
  tokens = aName.to_s.split(/_/)
283
283
 
data/lib/ruby-vpi.rb CHANGED
@@ -26,20 +26,36 @@ module RubyVpi
26
26
  #
27
27
  # aDesignId:: The name of the Ruby design object.
28
28
  # aSpecFormat:: The format being used by the specification.
29
- def RubyVpi.init_bench aDesignId, aSpecFormat
29
+ # aClockTrigger:: When the return value of this block is +true+, then the relay_verilog method returns. This block is given one argument: a handle to the clock signal that drives the design under test. If this block is not specified, relay_verilog will always return upon the next positive edge of the clock signal.
30
+ #
31
+ # # return upon positive edge
32
+ # RubyVpi.init_bench ... |clk|
33
+ # clk.intVal == 1
34
+ # end
35
+ #
36
+ # # return upon negative edge
37
+ # RubyVpi.init_bench ... do |clk|
38
+ # clk.intVal == 0
39
+ # end
40
+ #
41
+ # # return whenever clock changes
42
+ # RubyVpi.init_bench ... do |clk|
43
+ # true
44
+ # end
45
+ #
46
+ def RubyVpi.init_bench aDesignId, aSpecFormat, &aClockTrigger # :yields: clock_signal
30
47
  if caller.find {|s| s =~ /^(.*?)_bench.rb:/}
31
48
  testName = $1
32
49
  else
33
50
  raise 'Unable to determine name of test.'
34
51
  end
35
52
 
53
+ aClockTrigger ||= lambda {|clk| clk.intVal == 1}
54
+
36
55
  useDebugger = !(ENV['DEBUG'] || '').empty?
37
56
  useCoverage = !(ENV['COVERAGE'] || '').empty?
38
57
  usePrototype = !(ENV['PROTOTYPE'] || '').empty?
39
58
 
40
- # service the $ruby_init() task
41
- Vpi::relay_verilog
42
-
43
59
  # set up code coverage analysis
44
60
  if useCoverage
45
61
  require 'ruby-vpi/rcov'
@@ -106,13 +122,49 @@ module RubyVpi
106
122
  if usePrototype
107
123
  require "#{testName}_proto.rb"
108
124
 
109
- Vpi.class_eval do
125
+ Vpi.module_eval do
110
126
  define_method :relay_verilog do
111
127
  design.simulate!
112
128
  end
113
129
  end
114
130
 
115
131
  Vpi::vpi_printf "#{Config::PROJECT_NAME}: prototype is enabled for test #{testName.inspect}\n"
132
+
133
+ # trigger relay_verilog according to aClockTrigger
134
+ else
135
+ regs = design[VpiReg].sort_by {|h| h.lineNo}
136
+ clock = regs.first
137
+
138
+ Vpi.module_eval do
139
+ # register callback for relay_verilog
140
+ time = S_vpi_time.new
141
+ time.type = VpiSuppressTime
142
+
143
+ value = S_vpi_value.new
144
+ value.format = VpiSuppressVal
145
+
146
+ alarm = S_cb_data.new
147
+ alarm.reason = CbValueChange
148
+ alarm.cb_rtn = Vlog_relay_ruby
149
+ alarm.obj = clock
150
+ alarm.time = time
151
+ alarm.value = value
152
+ alarm.index = 0
153
+ alarm.user_data = nil
154
+
155
+ vpi_free_object(vpi_register_cb(alarm))
156
+
157
+ alias_method :relay_verilog_old, :relay_verilog
158
+
159
+ define_method :relay_verilog do
160
+ begin
161
+ relay_verilog_old
162
+ end until aClockTrigger.call(clock)
163
+ end
164
+ end
165
+
166
+ # XXX: this completes the handshake with pthread_mutex_lock() in relay_main() in the C extension
167
+ relay_verilog_old
116
168
  end
117
169
 
118
170
  # load the design's specification
data/ref/c/annotated.html CHANGED
@@ -17,12 +17,6 @@
17
17
  <li><a href="functions.html"><span>Data&nbsp;Fields</span></a></li>
18
18
  </ul></div>
19
19
  <h1>Ruby-VPI Data Structures</h1>Here are the data structures with brief descriptions:<table>
20
- <tr><td class="indexkey"><a class="el" href="structrelay____RubyOptions____def.html">relay__RubyOptions__def</a></td><td class="indexvalue">Stores command-line options for the Ruby interpreter </td></tr>
21
- <tr><td class="indexkey"><a class="el" href="unions__vpi__value__value.html">s_vpi_value_value</a></td><td class="indexvalue"></td></tr>
22
- <tr><td class="indexkey"><a class="el" href="structswig__cast__info.html">swig_cast_info</a></td><td class="indexvalue"></td></tr>
23
- <tr><td class="indexkey"><a class="el" href="structswig__class.html">swig_class</a></td><td class="indexvalue"></td></tr>
24
- <tr><td class="indexkey"><a class="el" href="structswig__module__info.html">swig_module_info</a></td><td class="indexvalue"></td></tr>
25
- <tr><td class="indexkey"><a class="el" href="structswig__type__info.html">swig_type_info</a></td><td class="indexvalue"></td></tr>
26
20
  <tr><td class="indexkey"><a class="el" href="structt__cb__data.html">t_cb_data</a></td><td class="indexvalue"></td></tr>
27
21
  <tr><td class="indexkey"><a class="el" href="structt__vpi__delay.html">t_vpi_delay</a></td><td class="indexvalue"></td></tr>
28
22
  <tr><td class="indexkey"><a class="el" href="structt__vpi__error__info.html">t_vpi_error_info</a></td><td class="indexvalue"></td></tr>
@@ -33,7 +27,7 @@
33
27
  <tr><td class="indexkey"><a class="el" href="structt__vpi__vecval.html">t_vpi_vecval</a></td><td class="indexvalue"></td></tr>
34
28
  <tr><td class="indexkey"><a class="el" href="structt__vpi__vlog__info.html">t_vpi_vlog_info</a></td><td class="indexvalue"></td></tr>
35
29
  </table>
36
- <hr size="1"><address style="align: right;"><small>Generated on Fri Dec 22 21:43:02 2006 for Ruby-VPI by&nbsp;
30
+ <hr size="1"><address style="align: right;"><small>Generated on Wed Dec 27 22:29:46 2006 for Ruby-VPI by&nbsp;
37
31
  <a href="http://www.doxygen.org/index.html">
38
32
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
39
33
  </body>
data/ref/c/common_8h.html CHANGED
@@ -18,6 +18,7 @@
18
18
  </ul></div>
19
19
  <h1>common.h File Reference</h1>Things common to all Ruby-VPI code. <a href="#_details">More...</a>
20
20
  <p>
21
+ <code>#include &lt;stddef.h&gt;</code><br>
21
22
  <code>#include &quot;<a class="el" href="verilog_8h.html">verilog.h</a>&quot;</code><br>
22
23
  <table border="0" cellpadding="0" cellspacing="0">
23
24
  <tr><td></td></tr>
@@ -139,7 +140,7 @@ Pass aroung this value instead of zero and non-zero integers. <dl compact><dt><b
139
140
 
140
141
  </div>
141
142
  </div><p>
142
- <hr size="1"><address style="align: right;"><small>Generated on Fri Dec 22 21:43:02 2006 for Ruby-VPI by&nbsp;
143
+ <hr size="1"><address style="align: right;"><small>Generated on Wed Dec 27 22:29:46 2006 for Ruby-VPI by&nbsp;
143
144
  <a href="http://www.doxygen.org/index.html">
144
145
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
145
146
  </body>
data/ref/c/files.html CHANGED
@@ -18,18 +18,16 @@
18
18
  </ul></div>
19
19
  <h1>Ruby-VPI File List</h1>Here is a list of all files with brief descriptions:<table>
20
20
  <tr><td class="indexkey"><a class="el" href="common_8h.html">common.h</a></td><td class="indexvalue">Things common to all Ruby-VPI code </td></tr>
21
+ <tr><td class="indexkey"><a class="el" href="main_8c.html">main.c</a></td><td class="indexvalue"></td></tr>
22
+ <tr><td class="indexkey"><a class="el" href="main_8h.html">main.h</a></td><td class="indexvalue">The C extension for Ruby-VPI </td></tr>
21
23
  <tr><td class="indexkey"><a class="el" href="relay_8c.html">relay.c</a></td><td class="indexvalue"></td></tr>
22
24
  <tr><td class="indexkey"><a class="el" href="relay_8h.html">relay.h</a></td><td class="indexvalue">Logic for transferring control between Ruby and Verilog </td></tr>
23
- <tr><td class="indexkey"><a class="el" href="swig_8c.html">swig.c</a></td><td class="indexvalue"></td></tr>
24
- <tr><td class="indexkey"><a class="el" href="swig_8h.html">swig.h</a></td><td class="indexvalue">C interface to the SWIG-generated VPI interface </td></tr>
25
- <tr><td class="indexkey"><a class="el" href="swig__vpi_8h.html">swig_vpi.h</a></td><td class="indexvalue"></td></tr>
26
- <tr><td class="indexkey"><a class="el" href="swig__wrap_8cin.html">swig_wrap.cin</a></td><td class="indexvalue"></td></tr>
27
25
  <tr><td class="indexkey"><a class="el" href="verilog_8h.html">verilog.h</a></td><td class="indexvalue">A proxy for all Verilog headers of interest to us </td></tr>
28
26
  <tr><td class="indexkey"><a class="el" href="vlog_8c.html">vlog.c</a></td><td class="indexvalue"></td></tr>
29
27
  <tr><td class="indexkey"><a class="el" href="vlog_8h.html">vlog.h</a></td><td class="indexvalue">Interface between C and Verilog code </td></tr>
30
28
  <tr><td class="indexkey"><a class="el" href="vpi__user_8h.html">vpi_user.h</a></td><td class="indexvalue"></td></tr>
31
29
  </table>
32
- <hr size="1"><address style="align: right;"><small>Generated on Fri Dec 22 21:43:02 2006 for Ruby-VPI by&nbsp;
30
+ <hr size="1"><address style="align: right;"><small>Generated on Wed Dec 27 22:29:46 2006 for Ruby-VPI by&nbsp;
33
31
  <a href="http://www.doxygen.org/index.html">
34
32
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
35
33
  </body>