ruby-vpi 16.0.1 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/LICENSE +19 -19
  2. data/README +1 -1
  3. data/Rakefile +35 -32
  4. data/bin/convert.rb +28 -0
  5. data/bin/generate/design.rb +16 -0
  6. data/bin/generate/proto.rb +13 -0
  7. data/bin/generate/runner.rake +33 -0
  8. data/bin/generate/spec.rb +45 -0
  9. data/bin/generate.rb +177 -0
  10. data/bin/ruby-vpi +56 -0
  11. data/doc/Rakefile +20 -4
  12. data/doc/common.css +92 -33
  13. data/doc/common.inc +13 -0
  14. data/doc/common.tpl +42 -28
  15. data/doc/history.doc +11 -11
  16. data/doc/history.html +769 -248
  17. data/doc/history.inc +909 -0
  18. data/doc/history.rb +9 -0
  19. data/doc/history.yaml +69 -0
  20. data/doc/intro.inc +170 -178
  21. data/doc/lib/doc_format.rb +57 -144
  22. data/doc/lib/doc_proxy.rb +504 -88
  23. data/doc/lib/erb_content.rb +8 -8
  24. data/doc/lib/erb_proxy.rb +17 -17
  25. data/doc/manual.doc +626 -777
  26. data/doc/manual.html +1541 -1031
  27. data/doc/memo.doc +38 -36
  28. data/doc/memo.html +64 -28
  29. data/doc/readme.doc +4 -31
  30. data/doc/readme.html +221 -163
  31. data/doc/rss.erb +1 -1
  32. data/doc/rss.xml +73 -1761
  33. data/ext/Rakefile +6 -5
  34. data/ext/main.c +17 -15
  35. data/ext/relay.c +4 -7
  36. data/ext/relay.h +2 -2
  37. data/ext/swig_vpi.h +2 -2
  38. data/ext/swig_vpi.i +1 -2
  39. data/ext/swig_wrap.cin +12 -16
  40. data/ext/vlog.c +5 -5
  41. data/ext/vlog.h +2 -2
  42. data/lib/ruby-vpi/erb.rb +3 -3
  43. data/lib/ruby-vpi/float.rb +2 -2
  44. data/lib/ruby-vpi/rcov.rb +5 -7
  45. data/lib/ruby-vpi/runner.rb +43 -41
  46. data/lib/ruby-vpi/runner_boot_loader.rb +117 -0
  47. data/lib/ruby-vpi/runner_proxy.rb +6 -8
  48. data/lib/ruby-vpi/util.rb +10 -0
  49. data/lib/ruby-vpi/verilog_parser.rb +28 -56
  50. data/lib/ruby-vpi/vpi.rb +168 -123
  51. data/lib/ruby-vpi.rb +22 -143
  52. data/ref/c/annotated.html +1 -1
  53. data/ref/c/common_8h.html +1 -1
  54. data/ref/c/files.html +1 -1
  55. data/ref/c/functions.html +1 -1
  56. data/ref/c/functions_vars.html +1 -1
  57. data/ref/c/globals.html +1 -1
  58. data/ref/c/globals_0x63.html +1 -1
  59. data/ref/c/globals_0x65.html +1 -1
  60. data/ref/c/globals_0x66.html +1 -1
  61. data/ref/c/globals_0x6d.html +1 -1
  62. data/ref/c/globals_0x70.html +1 -1
  63. data/ref/c/globals_0x72.html +1 -1
  64. data/ref/c/globals_0x73.html +1 -1
  65. data/ref/c/globals_0x74.html +1 -1
  66. data/ref/c/globals_0x76.html +1 -1
  67. data/ref/c/globals_0x78.html +1 -1
  68. data/ref/c/globals_defs.html +1 -1
  69. data/ref/c/globals_defs_0x65.html +1 -1
  70. data/ref/c/globals_defs_0x70.html +1 -1
  71. data/ref/c/globals_defs_0x76.html +1 -1
  72. data/ref/c/globals_defs_0x78.html +1 -1
  73. data/ref/c/globals_enum.html +1 -1
  74. data/ref/c/globals_eval.html +1 -1
  75. data/ref/c/globals_func.html +1 -1
  76. data/ref/c/globals_type.html +1 -1
  77. data/ref/c/globals_vars.html +1 -1
  78. data/ref/c/index.html +1 -1
  79. data/ref/c/main_8c.html +1 -1
  80. data/ref/c/main_8h.html +1 -1
  81. data/ref/c/relay_8c.html +1 -1
  82. data/ref/c/relay_8h.html +1 -1
  83. data/ref/c/structt__cb__data.html +1 -1
  84. data/ref/c/structt__vpi__delay.html +1 -1
  85. data/ref/c/structt__vpi__error__info.html +1 -1
  86. data/ref/c/structt__vpi__strengthval.html +1 -1
  87. data/ref/c/structt__vpi__systf__data.html +1 -1
  88. data/ref/c/structt__vpi__time.html +1 -1
  89. data/ref/c/structt__vpi__value.html +1 -1
  90. data/ref/c/structt__vpi__vecval.html +1 -1
  91. data/ref/c/structt__vpi__vlog__info.html +1 -1
  92. data/ref/c/verilog_8h.html +1 -1
  93. data/ref/c/vlog_8c.html +1 -1
  94. data/ref/c/vlog_8h.html +1 -1
  95. data/ref/c/vpi__user_8h.html +1 -1
  96. data/ref/ruby/classes/ERB.html +5 -5
  97. data/ref/ruby/classes/ERB.src/{M000024.html → M000026.html} +0 -0
  98. data/ref/ruby/classes/FileUtils.html +11 -11
  99. data/ref/ruby/classes/FileUtils.src/{M000025.html → M000027.html} +0 -0
  100. data/ref/ruby/classes/FileUtils.src/{M000026.html → M000028.html} +0 -0
  101. data/ref/ruby/classes/Float.html +6 -6
  102. data/ref/ruby/classes/Float.src/{M000020.html → M000021.html} +0 -0
  103. data/ref/ruby/classes/Integer.html +65 -65
  104. data/ref/ruby/classes/Integer.src/M000009.html +12 -5
  105. data/ref/ruby/classes/Integer.src/M000010.html +5 -5
  106. data/ref/ruby/classes/Integer.src/M000011.html +5 -5
  107. data/ref/ruby/classes/Integer.src/M000012.html +5 -5
  108. data/ref/ruby/classes/Integer.src/M000013.html +5 -5
  109. data/ref/ruby/classes/Integer.src/M000014.html +18 -0
  110. data/ref/ruby/classes/Integer.src/M000017.html +12 -18
  111. data/ref/ruby/classes/Integer.src/M000018.html +18 -12
  112. data/ref/ruby/classes/Integer.src/M000019.html +12 -17
  113. data/ref/ruby/classes/Integer.src/M000020.html +30 -0
  114. data/ref/ruby/classes/RDoc.html +5 -5
  115. data/ref/ruby/classes/RDoc.src/{M000053.html → M000058.html} +0 -0
  116. data/ref/ruby/classes/{RubyVpi/Config.html → RubyVPI.html} +20 -6
  117. data/ref/ruby/classes/String.html +34 -15
  118. data/ref/ruby/classes/String.src/M000022.html +5 -28
  119. data/ref/ruby/classes/String.src/M000023.html +5 -5
  120. data/ref/ruby/classes/String.src/{M000021.html → M000024.html} +0 -0
  121. data/ref/ruby/classes/String.src/M000025.html +41 -0
  122. data/ref/ruby/classes/VerilogParser/Module/Port.html +16 -36
  123. data/ref/ruby/classes/VerilogParser/Module/Port.src/M000006.html +10 -5
  124. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000004.html → M000007.html} +4 -4
  125. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000005.html → M000008.html} +4 -4
  126. data/ref/ruby/classes/VerilogParser/Module.html +28 -9
  127. data/ref/ruby/classes/VerilogParser/Module.src/M000005.html +29 -0
  128. data/ref/ruby/classes/VerilogParser.html +5 -39
  129. data/ref/ruby/classes/VerilogParser.src/M000004.html +26 -0
  130. data/ref/ruby/classes/Vpi/Handle.html +179 -77
  131. data/ref/ruby/classes/Vpi/Handle.src/M000035.html +18 -0
  132. data/ref/ruby/classes/Vpi/Handle.src/M000036.html +5 -5
  133. data/ref/ruby/classes/Vpi/Handle.src/M000037.html +5 -5
  134. data/ref/ruby/classes/Vpi/Handle.src/M000038.html +5 -5
  135. data/ref/ruby/classes/Vpi/Handle.src/M000039.html +5 -5
  136. data/ref/ruby/classes/Vpi/Handle.src/M000040.html +5 -8
  137. data/ref/ruby/classes/Vpi/Handle.src/M000041.html +5 -8
  138. data/ref/ruby/classes/Vpi/Handle.src/M000042.html +5 -9
  139. data/ref/ruby/classes/Vpi/Handle.src/M000043.html +8 -31
  140. data/ref/ruby/classes/Vpi/Handle.src/M000044.html +8 -74
  141. data/ref/ruby/classes/Vpi/Handle.src/M000045.html +9 -17
  142. data/ref/ruby/classes/Vpi/Handle.src/M000046.html +31 -11
  143. data/ref/ruby/classes/Vpi/Handle.src/M000047.html +86 -0
  144. data/ref/ruby/classes/Vpi/Handle.src/M000048.html +17 -18
  145. data/ref/ruby/classes/Vpi/Handle.src/M000050.html +18 -0
  146. data/ref/ruby/classes/Vpi/Handle.src/M000051.html +24 -0
  147. data/ref/ruby/classes/Vpi/Handle.src/M000053.html +31 -0
  148. data/ref/ruby/classes/Vpi/Handle.src/M000054.html +89 -0
  149. data/ref/ruby/classes/Vpi/S_vpi_time.html +16 -16
  150. data/ref/ruby/classes/Vpi/S_vpi_time.src/{M000050.html → M000055.html} +4 -4
  151. data/ref/ruby/classes/Vpi/S_vpi_time.src/{M000051.html → M000056.html} +5 -5
  152. data/ref/ruby/classes/Vpi/S_vpi_value.html +15 -15
  153. data/ref/ruby/classes/Vpi/S_vpi_value.src/{M000035.html → M000032.html} +5 -5
  154. data/ref/ruby/classes/Vpi/S_vpi_value.src/M000033.html +5 -5
  155. data/ref/ruby/classes/Vpi/S_vpi_value.src/M000034.html +5 -5
  156. data/ref/ruby/classes/Vpi.html +6 -42
  157. data/ref/ruby/classes/Vpi.src/M000029.html +15 -5
  158. data/ref/ruby/classes/Vpi.src/M000030.html +24 -24
  159. data/ref/ruby/classes/Vpi.src/M000031.html +6 -8
  160. data/ref/ruby/created.rid +1 -1
  161. data/ref/ruby/files/bin/{header_to_ruby_rb.html → convert_rb.html} +5 -5
  162. data/ref/ruby/files/bin/{generate_test_rb.html → generate_rb.html} +8 -21
  163. data/ref/ruby/files/lib/ruby-vpi/erb_rb.html +1 -1
  164. data/ref/ruby/files/lib/ruby-vpi/float_rb.html +1 -1
  165. data/ref/ruby/files/lib/ruby-vpi/integer_rb.html +1 -1
  166. data/ref/ruby/files/lib/ruby-vpi/rake_rb.html +1 -1
  167. data/ref/ruby/files/lib/ruby-vpi/rcov_rb.html +1 -1
  168. data/ref/ruby/files/lib/ruby-vpi/rdoc_rb.html +1 -1
  169. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.html +197 -0
  170. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.src/M000001.html +17 -0
  171. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.src/M000002.html +18 -0
  172. data/ref/ruby/files/lib/ruby-vpi/runner_proxy_rb.html +1 -1
  173. data/ref/ruby/files/lib/ruby-vpi/runner_rb.html +6 -19
  174. data/ref/ruby/files/lib/ruby-vpi/util_rb.html +101 -0
  175. data/ref/ruby/files/lib/ruby-vpi/verilog_parser_rb.html +8 -1
  176. data/ref/ruby/files/lib/ruby-vpi/vpi_rb.html +1 -1
  177. data/ref/ruby/files/lib/ruby-vpi_rb.html +2 -14
  178. data/ref/ruby/fr_class_index.html +1 -3
  179. data/ref/ruby/fr_file_index.html +4 -2
  180. data/ref/ruby/fr_method_index.html +56 -51
  181. data/ref/ruby/index.html +1 -1
  182. data/samp/counter/RSpec/Rakefile +1 -0
  183. data/samp/counter/RSpec/counter_design.rb +15 -0
  184. data/samp/counter/RSpec/counter_proto.rb +10 -0
  185. data/samp/counter/RSpec/counter_runner.rake +44 -0
  186. data/samp/counter/RSpec/counter_spec.rb +39 -0
  187. data/samp/counter/Rakefile +1 -1
  188. data/samp/counter/counter.v +7 -7
  189. data/samp/counter/xUnit/Rakefile +1 -0
  190. data/samp/counter/xUnit/counter_bench.rb +95 -0
  191. data/samp/counter/{counter_xunit_bench.v → xUnit/counter_bench.v} +0 -0
  192. data/samp/counter/xUnit/counter_design.rb +15 -0
  193. data/samp/counter/xUnit/counter_proto.rb +10 -0
  194. data/samp/counter/xUnit/counter_runner.rake +44 -0
  195. data/samp/counter/{counter_xunit_spec.rb → xUnit/counter_spec.rb} +9 -9
  196. data/samp/pipelined_alu/Rakefile +1 -1
  197. data/samp/pipelined_alu/TestHw5UnitModel.rb +4 -5
  198. data/samp/pipelined_alu/hw5_unit.v +55 -85
  199. data/samp/pipelined_alu/hw5_unit_design.rb +51 -0
  200. data/samp/pipelined_alu/hw5_unit_proto.rb +4 -0
  201. data/samp/pipelined_alu/hw5_unit_runner.rake +43 -0
  202. data/samp/pipelined_alu/hw5_unit_spec.rb +64 -0
  203. data/samp/register_file/LICENSE +20 -0
  204. data/samp/register_file/README +4 -0
  205. data/samp/register_file/Rakefile +1 -0
  206. data/samp/register_file/register_file.v +18 -0
  207. data/samp/register_file/register_file_design.rb +11 -0
  208. data/samp/register_file/register_file_proto.rb +11 -0
  209. data/samp/register_file/register_file_runner.rake +43 -0
  210. data/samp/register_file/register_file_spec.rb +58 -0
  211. metadata +78 -66
  212. data/bin/generate_test.rb +0 -200
  213. data/bin/generate_test_tpl/bench.rb +0 -89
  214. data/bin/generate_test_tpl/bench.v +0 -26
  215. data/bin/generate_test_tpl/design.rb +0 -11
  216. data/bin/generate_test_tpl/proto.rb +0 -16
  217. data/bin/generate_test_tpl/runner.rake +0 -42
  218. data/bin/generate_test_tpl/spec.rb +0 -37
  219. data/bin/header_to_ruby.rb +0 -27
  220. data/ref/ruby/classes/Integer.src/M000008.html +0 -25
  221. data/ref/ruby/classes/Integer.src/M000016.html +0 -25
  222. data/ref/ruby/classes/RubyVpi.html +0 -199
  223. data/ref/ruby/classes/RubyVpi.src/M000027.html +0 -121
  224. data/ref/ruby/classes/VerilogParser/Module/Parameter.html +0 -160
  225. data/ref/ruby/classes/VerilogParser/Module/Parameter.src/M000007.html +0 -19
  226. data/ref/ruby/classes/VerilogParser/Module/Port.src/M000003.html +0 -21
  227. data/ref/ruby/classes/VerilogParser/Module.src/M000002.html +0 -34
  228. data/ref/ruby/classes/VerilogParser.src/M000001.html +0 -34
  229. data/ref/ruby/classes/Vpi/Handle.src/M000049.html +0 -69
  230. data/ref/ruby/classes/Vpi.src/M000028.html +0 -28
  231. data/ref/ruby/classes/Vpi.src/M000032.html +0 -22
  232. data/samp/counter/counter_rspec_bench.rb +0 -86
  233. data/samp/counter/counter_rspec_bench.v +0 -9
  234. data/samp/counter/counter_rspec_design.rb +0 -8
  235. data/samp/counter/counter_rspec_proto.rb +0 -13
  236. data/samp/counter/counter_rspec_runner.rake +0 -52
  237. data/samp/counter/counter_rspec_spec.rb +0 -39
  238. data/samp/counter/counter_xunit_bench.rb +0 -86
  239. data/samp/counter/counter_xunit_design.rb +0 -8
  240. data/samp/counter/counter_xunit_proto.rb +0 -13
  241. data/samp/counter/counter_xunit_runner.rake +0 -52
  242. data/samp/pipelined_alu/hw5_unit_test_bench.rb +0 -86
  243. data/samp/pipelined_alu/hw5_unit_test_bench.v +0 -14
  244. data/samp/pipelined_alu/hw5_unit_test_design.rb +0 -61
  245. data/samp/pipelined_alu/hw5_unit_test_proto.rb +0 -7
  246. data/samp/pipelined_alu/hw5_unit_test_runner.rake +0 -52
  247. data/samp/pipelined_alu/hw5_unit_test_spec.rb +0 -68
data/ext/Rakefile CHANGED
@@ -35,16 +35,17 @@ end
35
35
 
36
36
  file 'swig_vpi.i' => 'swig_vpi.h'
37
37
 
38
- # avoid compilation problems due to va_list, which is used in the SWIG-generated
39
- # wrapper for VPI vprintf functions
38
+ # avoid compilation errors due to va_list, which is used
39
+ # in the SWIG-generated wrapper for VPI vprintf functions
40
40
  file 'swig_vpi.h' => 'vpi_user.h' do |t|
41
41
  src, dst = t.prerequisites[0], t.name
42
42
 
43
43
  File.open(dst, 'w') do |f|
44
- f << File.read(src).gsub(/\bva_list\b/, 'int')
44
+ f << File.read(src).gsub(/\bva_list\b/, 'void*')
45
45
  end
46
46
  end
47
47
 
48
- # NOTE: since SWIG is not a requirement for users, we should not clobber these
49
- # generated files
48
+ # NOTE: since SWIG is not a requirement for users,
49
+ # we should not clobber these generated files
50
+ #
50
51
  #CLOBBER.include 'swig_wrap.cin', 'swig_vpi.h'
data/ext/main.c CHANGED
@@ -23,22 +23,24 @@ void main_init() {
23
23
  rb_define_module_function(mVpi, "relay_verilog", main_relay_verilog, 0);
24
24
  rb_define_module_function(mVpi, "relay_ruby_reason", main_relay_ruby_reason, 0);
25
25
 
26
- // initialize the Ruby bench
27
- char* benchFile = getenv("RUBYVPI_BOOTSTRAP");
28
-
29
- if (benchFile != NULL) {
30
- ruby_script(benchFile);
31
- rb_load_file(benchFile);
32
- }
33
- else {
34
- common_printf("error: environment variable RUBY_VPI__RUBY_BENCH_FILE is uninitialized.");
35
- exit(EXIT_FAILURE);
36
- }
37
-
38
- // run the test bench
39
- ruby_run();
26
+ // some compilers have trouble with pointers to the va_list
27
+ // type. See ext/Rakefile and the user manual for details
28
+ rb_define_alias(mVpi, "vpi_vprintf", "vpi_printf");
29
+ rb_define_alias(mVpi, "vpi_mcd_vprintf", "vpi_mcd_printf");
30
+
40
31
 
41
- ruby_finalize();
32
+ char* bootLoader = getenv("RUBYVPI_BOOT_LOADER");
33
+ char* bootTarget = getenv("RUBYVPI_BOOT_TARGET");
34
+
35
+ if (bootLoader != NULL && bootTarget != NULL) {
36
+ ruby_script(bootTarget);
37
+ rb_load_file(bootLoader);
38
+ ruby_run();
39
+ }
40
+ else {
41
+ common_printf("error: the RUBYVPI_BOOT_LOADER and RUBYVPI_BOOT_TARGET environment variables are not initialized.");
42
+ exit(EXIT_FAILURE);
43
+ }
42
44
  }
43
45
 
44
46
  VALUE main_relay_verilog(VALUE arSelf) {
data/ext/relay.c CHANGED
@@ -13,7 +13,7 @@ pthread_t relay__rubyThread;
13
13
  pthread_mutex_t relay__rubyLock;
14
14
  pthread_mutex_t relay__verilogLock;
15
15
 
16
- // Body of the ruby thread.
16
+ // body of the ruby thread
17
17
  void* relay_ruby_thread(void* dummy) {
18
18
  main_init();
19
19
  return NULL;
@@ -25,12 +25,9 @@ void relay_init() {
25
25
  pthread_mutex_init(&relay__verilogLock, NULL);
26
26
  pthread_mutex_lock(&relay__verilogLock);
27
27
 
28
- // start the ruby thread
29
- pthread_create(&relay__rubyThread, NULL, relay_ruby_thread, NULL);
30
-
31
- // XXX: freezee verilog because RubyVpi.init_bench will call relay_verilog
32
- // (which assumes that verilog is frozen)
33
- pthread_mutex_lock(&relay__verilogLock);
28
+ // begin by putting the ruby thread in control
29
+ pthread_create(&relay__rubyThread, NULL, relay_ruby_thread, NULL);
30
+ pthread_mutex_lock(&relay__verilogLock);
34
31
  }
35
32
 
36
33
  void relay_ruby() {
data/ext/relay.h CHANGED
@@ -13,8 +13,8 @@
13
13
  #include "common.h"
14
14
 
15
15
  /**
16
- Initialize the relay mechanism, which enables Verilog to transfer control to
17
- Ruby and vice versa, and start Ruby.
16
+ Initialize the relay mechanism, which enables Verilog to
17
+ transfer control to Ruby and vice versa, and start Ruby.
18
18
  */
19
19
  void relay_init();
20
20
 
data/ext/swig_vpi.h CHANGED
@@ -880,10 +880,10 @@ XXTERN void *vpi_get_userdata PROTO_PARAMS((vpiHandle obj));
880
880
  XXTERN PLI_INT32 vpi_put_userdata PROTO_PARAMS((vpiHandle obj,
881
881
  void *userdata));
882
882
  XXTERN PLI_INT32 vpi_vprintf PROTO_PARAMS((PLI_BYTE8 *format,
883
- int ap));
883
+ void* ap));
884
884
  XXTERN PLI_INT32 vpi_mcd_vprintf PROTO_PARAMS((PLI_UINT32 mcd,
885
885
  PLI_BYTE8 *format,
886
- int ap));
886
+ void* ap));
887
887
  XXTERN PLI_INT32 vpi_flush PROTO_PARAMS((void));
888
888
  XXTERN PLI_INT32 vpi_mcd_flush PROTO_PARAMS((PLI_UINT32 mcd));
889
889
  XXTERN PLI_INT32 vpi_control PROTO_PARAMS((PLI_INT32 operation,
data/ext/swig_vpi.i CHANGED
@@ -1,13 +1,12 @@
1
1
  %module vpi
2
2
 
3
-
4
3
  /* Parse the header file to generate wrappers */
5
4
  %{
6
5
  #include "swig_vpi.h"
7
6
  %}
8
7
  %include "swig_vpi.h"
9
8
 
10
- /* allows us to set S_cb_data.cb_rtn = Vpi::Vlog_relay_ruby from Ruby */
9
+ /* allows us to set S_cb_data.cb_rtn = Vpi::Vlog_relay_ruby in Ruby */
11
10
  %{
12
11
  #include "vlog.h"
13
12
  %}
data/ext/swig_wrap.cin CHANGED
@@ -5910,13 +5910,12 @@ fail:
5910
5910
  SWIGINTERN VALUE
5911
5911
  _wrap_vpi_vprintf(int argc, VALUE *argv, VALUE self) {
5912
5912
  PLI_BYTE8 *arg1 = (PLI_BYTE8 *) 0 ;
5913
- int arg2 ;
5913
+ void *arg2 = (void *) 0 ;
5914
5914
  PLI_INT32 result;
5915
5915
  int res1 ;
5916
5916
  char *buf1 = 0 ;
5917
5917
  int alloc1 = 0 ;
5918
- int val2 ;
5919
- int ecode2 = 0 ;
5918
+ int res2 ;
5920
5919
  VALUE vresult = Qnil;
5921
5920
 
5922
5921
  if ((argc < 2) || (argc > 2)) {
@@ -5927,11 +5926,10 @@ _wrap_vpi_vprintf(int argc, VALUE *argv, VALUE self) {
5927
5926
  SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "vpi_vprintf" "', argument " "1"" of type '" "PLI_BYTE8 *""'");
5928
5927
  }
5929
5928
  arg1 = (PLI_BYTE8 *)(buf1);
5930
- ecode2 = SWIG_AsVal_int(argv[1], &val2);
5931
- if (!SWIG_IsOK(ecode2)) {
5932
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "vpi_vprintf" "', argument " "2"" of type '" "int""'");
5933
- }
5934
- arg2 = (int)(val2);
5929
+ res2 = SWIG_ConvertPtr(argv[1],SWIG_as_voidptrptr(&arg2), 0, 0);
5930
+ if (!SWIG_IsOK(res2)) {
5931
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "vpi_vprintf" "', argument " "2"" of type '" "void *""'");
5932
+ }
5935
5933
  result = (PLI_INT32)vpi_vprintf(arg1,arg2);
5936
5934
  vresult = SWIG_From_int((int)(result));
5937
5935
  if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
@@ -5946,15 +5944,14 @@ SWIGINTERN VALUE
5946
5944
  _wrap_vpi_mcd_vprintf(int argc, VALUE *argv, VALUE self) {
5947
5945
  PLI_UINT32 arg1 ;
5948
5946
  PLI_BYTE8 *arg2 = (PLI_BYTE8 *) 0 ;
5949
- int arg3 ;
5947
+ void *arg3 = (void *) 0 ;
5950
5948
  PLI_INT32 result;
5951
5949
  unsigned int val1 ;
5952
5950
  int ecode1 = 0 ;
5953
5951
  int res2 ;
5954
5952
  char *buf2 = 0 ;
5955
5953
  int alloc2 = 0 ;
5956
- int val3 ;
5957
- int ecode3 = 0 ;
5954
+ int res3 ;
5958
5955
  VALUE vresult = Qnil;
5959
5956
 
5960
5957
  if ((argc < 3) || (argc > 3)) {
@@ -5970,11 +5967,10 @@ _wrap_vpi_mcd_vprintf(int argc, VALUE *argv, VALUE self) {
5970
5967
  SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "vpi_mcd_vprintf" "', argument " "2"" of type '" "PLI_BYTE8 *""'");
5971
5968
  }
5972
5969
  arg2 = (PLI_BYTE8 *)(buf2);
5973
- ecode3 = SWIG_AsVal_int(argv[2], &val3);
5974
- if (!SWIG_IsOK(ecode3)) {
5975
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "vpi_mcd_vprintf" "', argument " "3"" of type '" "int""'");
5976
- }
5977
- arg3 = (int)(val3);
5970
+ res3 = SWIG_ConvertPtr(argv[2],SWIG_as_voidptrptr(&arg3), 0, 0);
5971
+ if (!SWIG_IsOK(res3)) {
5972
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "vpi_mcd_vprintf" "', argument " "3"" of type '" "void *""'");
5973
+ }
5978
5974
  result = (PLI_INT32)vpi_mcd_vprintf(arg1,arg2,arg3);
5979
5975
  vresult = SWIG_From_int((int)(result));
5980
5976
  if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
data/ext/vlog.c CHANGED
@@ -33,11 +33,11 @@ s_cb_data* vlog_relay_ruby_reason() {
33
33
  void vlog_startup() {
34
34
  s_cb_data call;
35
35
 
36
- call.reason = cbStartOfSimulation;
37
- call.cb_rtn = vlog_relay_init;
38
- call.obj = NULL;
39
- call.time = NULL;
40
- call.value = NULL;
36
+ call.reason = cbStartOfSimulation;
37
+ call.cb_rtn = vlog_relay_init;
38
+ call.obj = NULL;
39
+ call.time = NULL;
40
+ call.value = NULL;
41
41
  call.user_data = NULL;
42
42
 
43
43
  vpi_free_object(vpi_register_cb(&call));
data/ext/vlog.h CHANGED
@@ -18,8 +18,8 @@
18
18
  verilog_cb_funcSig(vlog_relay_ruby);
19
19
 
20
20
  /**
21
- Returns the data corresponding to the callback that caused the relay from
22
- Verilog to Ruby.
21
+ Returns the data corresponding to the callback
22
+ that caused the relay from Verilog to Ruby.
23
23
  */
24
24
  s_cb_data* vlog_relay_ruby_reason();
25
25
 
data/lib/ruby-vpi/erb.rb CHANGED
@@ -5,9 +5,9 @@
5
5
 
6
6
  require 'erb'
7
7
 
8
- # A version of ERB whose embedding tags behave like those of PHP. That is, only
9
- # <%= ... %> tags produce output, whereas <% ... %> tags do *not* produce any
10
- # output.
8
+ # A version of ERB whose embedding tags behave like those
9
+ # of PHP. That is, only <%= ... %> tags produce output,
10
+ # whereas <% ... %> tags do *not* produce any output.
11
11
  class ERB
12
12
  alias original_initialize initialize
13
13
 
@@ -4,8 +4,8 @@
4
4
  # See the file named LICENSE for details.
5
5
 
6
6
  class String
7
- # Converts this string into a floating point number using the given radix.
8
- # The default radix is 10.
7
+ # Converts this string into a floating point number
8
+ # using the given radix. The default radix is 10.
9
9
  def to_f aRadix = 10
10
10
  whole, frac = split('.', 2)
11
11
  whole = whole.to_i(aRadix).to_f
data/lib/ruby-vpi/rcov.rb CHANGED
@@ -23,7 +23,7 @@ require 'rcov'
23
23
  require 'rcov/report'
24
24
 
25
25
 
26
- module RubyVpi
26
+ module RubyVPI
27
27
  COVERAGE_ANALYSIS = Rcov::CodeCoverageAnalyzer.new
28
28
  COVERAGE_ANALYSIS.install_hook
29
29
 
@@ -37,11 +37,9 @@ module RubyVpi
37
37
  end
38
38
  end
39
39
 
40
- # Invokes the given block, which yields COVERAGE_ANALYSIS, after code coverage
41
- # analysis has completed.
42
- def RubyVpi.with_coverage_analysis &aBlock # :nodoc:
43
- if aBlock
44
- COVERAGE_ANALYSIS_HANDLERS << aBlock
45
- end
40
+ # Invokes the given block, which yields COVERAGE_ANALYSIS,
41
+ # after code coverage analysis has completed.
42
+ def RubyVPI.with_coverage_analysis &aBlock # :nodoc:
43
+ COVERAGE_ANALYSIS_HANDLERS << aBlock if aBlock
46
44
  end
47
45
  end
@@ -1,34 +1,44 @@
1
- # A template to simplify building and running examples. This file is meant to be
2
- # embedded in another Rakefile, which bears the responsibility of defining the
3
- # following variables.
1
+ # A template to simplify building and running examples. This
2
+ # file is meant to be embedded in another Rakefile, which bears
3
+ # the responsibility of defining the following variables.
4
4
  #
5
5
  # = Required variables
6
6
  #
7
- # SIMULATOR_SOURCES:: Array of paths to source files needed by the simulator.
7
+ # SIMULATOR_SOURCES:: Array of paths to (1) source files or (2)
8
+ # directories that contain source files
9
+ # which must be loaded by the simulator.
8
10
  #
9
- # SIMULATOR_TARGET:: Name of the Verilog module to be simulated.
11
+ # SIMULATOR_ARGUMENTS:: A hash table containing keys for each simulator task
12
+ # (same as Rakefile task names) and values containing
13
+ # command-line arguments for each simulator.
10
14
  #
11
- # SIMULATOR_ARGUMENTS:: A hash containing keys for each simulator task (same as
12
- # Rakefile task names) and values containing command-line
13
- # arguments for each simulator.
14
15
  #--
15
16
  # Copyright 2006-2007 Suraj N. Kurapati
16
17
  # See the file named LICENSE for details.
17
18
 
19
+ require 'ruby-vpi/util'
20
+
18
21
  # check for required variables
19
- raise ArgumentError, "All required variables must be defined." unless
20
- defined?(SIMULATOR_SOURCES) &&
21
- defined?(SIMULATOR_TARGET) &&
22
- defined?(SIMULATOR_ARGUMENTS)
22
+ vars = %w[SIMULATOR_SOURCES SIMULATOR_ARGUMENTS]
23
+
24
+ unless vars.all? {|v| eval "defined? #{v}"}
25
+ raise ArgumentError, "#{vars.join(' and ')} must be defined."
26
+ end
23
27
 
24
- SIMULATOR_INCLUDES = [] unless defined? SIMULATOR_INCLUDES
28
+ # auto-detect and set default parameters
29
+ runnerPath = caller.reject {|s| s =~ /:in \`/}.first.rstrip_from(':')
30
+ @target = File.basename(runnerPath).rstrip_from('_')
25
31
 
26
32
  task :setup
27
33
 
28
34
  # resolve paths to sources by searching include directories
29
- SIMULATOR_SOURCES.map! do |src|
35
+ @sources = SIMULATOR_SOURCES.to_a.uniq
36
+ @incdirs = @sources.select {|s| File.directory? s}
37
+ @sources -= @incdirs
38
+
39
+ @sources.map! do |src|
30
40
  unless File.exist? src
31
- SIMULATOR_INCLUDES.each do |dir|
41
+ @incdirs.each do |dir|
32
42
  path = File.join(dir, src)
33
43
 
34
44
  if File.exist? path
@@ -42,17 +52,16 @@
42
52
  end
43
53
 
44
54
  # prepare hook for rb_load_file() in main.c
45
- ENV['RUBYVPI_BOOTSTRAP'] = SIMULATOR_TARGET + '.rb'
55
+ ENV['RUBYVPI_BOOT_LOADER'] = File.join(File.dirname(__FILE__), 'runner_boot_loader.rb')
56
+ ENV['RUBYVPI_BOOT_TARGET'] = @target
46
57
 
47
58
 
48
59
  require 'rake/clean'
49
60
  require 'ruby-vpi'
50
61
  require 'ruby-vpi/rake'
51
62
 
52
- include RubyVpi::Config
53
-
54
63
  OBJECT_PATH = File.join(File.dirname(__FILE__), '..', '..', 'obj')
55
- BOOTSTAP_FUNC = 'vlog_startup_routines_bootstrap'
64
+ LOADER_FUNC = 'vlog_startup_routines_bootstrap'
56
65
 
57
66
 
58
67
  # Returns the path to the Ruby-VPI object file for the given simulator.
@@ -60,23 +69,16 @@ def object_file_path aSimId # :nodoc:
60
69
  path = File.join(OBJECT_PATH, aSimId.to_s)
61
70
 
62
71
  unless File.exist? path
63
- raise "Object file #{path.inspect} is missing. Rebuild #{PROJECT_NAME}."
72
+ raise "Object file #{path.inspect} is missing. Rebuild Ruby-VPI."
64
73
  end
65
74
 
66
75
  path
67
76
  end
68
77
 
69
78
  # Returns an array of include-directory options.
70
- def expand_include_dir_options aSimId, aIncludes = SIMULATOR_INCLUDES # :nodoc:
71
- prefix = case aSimId
72
- when :ivl
73
- '-I'
74
-
75
- else
76
- '+incdir+'
77
- end
78
-
79
- aIncludes.map {|i| prefix + i}
79
+ def expand_include_dir_options aSimId # :nodoc:
80
+ prefix = aSimId == :ivl ? '-I' : '+incdir+'
81
+ @incdirs.map {|i| prefix + i}
80
82
  end
81
83
 
82
84
 
@@ -87,46 +89,46 @@ task :default do
87
89
  end
88
90
 
89
91
 
90
- desc "Simulate with #{SIMULATORS[:cver].name}."
92
+ desc "Simulate with #{RubyVPI::SIMULATORS[:cver].name}."
91
93
  task :cver => :setup do
92
- sh 'cver', SIMULATOR_ARGUMENTS[:cver], "+loadvpi=#{object_file_path(:cver)}:#{BOOTSTAP_FUNC}", expand_include_dir_options(:cver), SIMULATOR_SOURCES
94
+ sh 'cver', SIMULATOR_ARGUMENTS[:cver], "+loadvpi=#{object_file_path(:cver)}:#{LOADER_FUNC}", expand_include_dir_options(:cver), @sources
93
95
  end
94
96
 
95
97
  CLOBBER.include 'verilog.log'
96
98
 
97
99
 
98
- desc "Simulate with #{SIMULATORS[:ivl].name}."
100
+ desc "Simulate with #{RubyVPI::SIMULATORS[:ivl].name}."
99
101
  task :ivl => :setup do
100
102
  cp object_file_path(:ivl), 'ruby-vpi.vpi'
101
- sh 'iverilog', SIMULATOR_ARGUMENTS[:ivl], '-mruby-vpi', expand_include_dir_options(:ivl), SIMULATOR_SOURCES
103
+ sh 'iverilog', SIMULATOR_ARGUMENTS[:ivl], '-mruby-vpi', expand_include_dir_options(:ivl), @sources
102
104
  sh 'vvp -M. a.out'
103
105
  end
104
106
 
105
107
  CLEAN.include 'ruby-vpi.vpi', 'a.out'
106
108
 
107
109
 
108
- desc "Simulate with #{SIMULATORS[:vcs].name}."
110
+ desc "Simulate with #{RubyVPI::SIMULATORS[:vcs].name}."
109
111
  task :vcs => :setup do
110
- sh %w(vcs -R +v2k +vpi), SIMULATOR_ARGUMENTS[:vcs], '-load', "#{object_file_path(:vcs)}:#{BOOTSTAP_FUNC}", expand_include_dir_options(:vcs), SIMULATOR_SOURCES
112
+ sh %w(vcs -R +v2k +vpi), SIMULATOR_ARGUMENTS[:vcs], '-load', "#{object_file_path(:vcs)}:#{LOADER_FUNC}", expand_include_dir_options(:vcs), @sources
111
113
  end
112
114
 
113
115
  CLEAN.include 'csrc', 'simv*'
114
116
 
115
117
 
116
- desc "Simulate with #{SIMULATORS[:vsim].name}."
118
+ desc "Simulate with #{RubyVPI::SIMULATORS[:vsim].name}."
117
119
  task :vsim => :setup do
118
120
  sh 'vlib work'
119
- sh 'vlog', expand_include_dir_options(:vsim), SIMULATOR_SOURCES
120
- sh 'vsim', SIMULATOR_ARGUMENTS[:vsim], '-c', SIMULATOR_TARGET, '-pli', object_file_path(:vsim), '-do', 'run -all'
121
+ sh 'vlog', expand_include_dir_options(:vsim), @sources
122
+ sh 'vsim', SIMULATOR_ARGUMENTS[:vsim], '-c', @target, '-pli', object_file_path(:vsim), '-do', 'run -all'
121
123
  end
122
124
 
123
125
  CLEAN.include 'work'
124
126
  CLOBBER.include 'transcript'
125
127
 
126
128
 
127
- desc "Simulate with #{SIMULATORS[:ncsim].name}."
129
+ desc "Simulate with #{RubyVPI::SIMULATORS[:ncsim].name}."
128
130
  task :ncsim => :setup do
129
- sh 'ncverilog', SIMULATOR_ARGUMENTS[:ncsim], "+loadvpi=#{object_file_path(:ncsim)}:#{BOOTSTAP_FUNC}", '+access+rwc', expand_include_dir_options(:ncsim), SIMULATOR_SOURCES
131
+ sh 'ncverilog', SIMULATOR_ARGUMENTS[:ncsim], "+loadvpi=#{object_file_path(:ncsim)}:#{LOADER_FUNC}", '+access+rwc', expand_include_dir_options(:ncsim), @sources
130
132
  end
131
133
 
132
134
  CLEAN.include 'INCA_libs'
@@ -0,0 +1,117 @@
1
+ # Initializes the test bench by setting up code
2
+ # coverage, the interactive debugger, and so on:
3
+ #
4
+ # 1. loads the design.rb file
5
+ # 2. loads the proto.rb file if prototyping is enabled
6
+ # 3. loads the spec.rb file
7
+
8
+ require 'rubygems'
9
+ require 'ruby-vpi'
10
+ require 'ruby-vpi/util'
11
+
12
+ designName = ENV['RUBYVPI_BOOT_TARGET']
13
+
14
+ useDebugger = ENV['DEBUGGER'].to_i == 1
15
+ useCoverage = ENV['COVERAGE'].to_i == 1
16
+ usePrototype = ENV['PROTOTYPE'].to_i == 1
17
+
18
+ # set up code coverage analysis
19
+
20
+ require 'ruby-vpi/vpi' # XXX: this is loaded *before* RCov to
21
+ # prevent coverage statistics about it
22
+
23
+ if useCoverage
24
+ require 'ruby-vpi/rcov'
25
+
26
+ RubyVPI.with_coverage_analysis do |a|
27
+ a.dump_coverage_info [
28
+ Rcov::TextReport.new,
29
+ Rcov::HTMLCoverage.new(:destdir => "#{designName}_coverage")
30
+ ]
31
+ end
32
+
33
+ RubyVPI.say 'coverage analysis is enabled'
34
+ end
35
+
36
+ # set up the interactive debugger
37
+ if useDebugger
38
+ require 'ruby-debug'
39
+
40
+ Debugger.start
41
+ Debugger.post_mortem
42
+
43
+ RubyVPI.say 'debugger is enabled'
44
+ end
45
+
46
+ # suppress undefined method errors when debugger is not enabled
47
+ unless Kernel.respond_to? :debugger
48
+ Kernel.class_eval do
49
+ # Starts an interactive debugging session.
50
+ def debugger
51
+ end
52
+ end
53
+ end
54
+
55
+ # set up the VPI utility layer
56
+ Object.class_eval do
57
+ include Vpi
58
+ end
59
+
60
+ # load the design under test
61
+ unless designHandle = vpi_handle_by_name(designName, nil)
62
+ raise "cannot access the design under test: #{designName.inspect}"
63
+ end
64
+
65
+ # create a module to wrap the DUT, so that inner classes and modules
66
+ # and constants defined in the design.rb and proto.rb files are
67
+ # accessible in spec.rb through the namespace resolution operator (::)
68
+ design = Module.new do
69
+ @@design = designHandle
70
+
71
+ # delegate all instance methods to the DUT
72
+ instance_eval do
73
+ def method_missing(*a, &b)
74
+ @@design.__send__(*a, &b)
75
+ end
76
+
77
+ alias const_missing method_missing
78
+
79
+ # so that #inspect executes on the DUT instead of this wrapper
80
+ undef to_s
81
+ undef inspect
82
+ end
83
+
84
+ # make module parameters available as constants
85
+ @@design[VpiParameter, VpiLocalParam].each do |var|
86
+ const_set(var.name.to_ruby_const_name, var.intVal)
87
+ end
88
+
89
+ # methods in design.rb & proto.rb must execute on the DUT
90
+ @@design.extend(self)
91
+ end
92
+
93
+ Kernel.const_set(designName.to_ruby_const_name, design)
94
+
95
+ f = "#{designName}_design.rb"
96
+ design.module_eval(File.read(f), f) if File.exist? f
97
+
98
+ # load the design's prototype
99
+ if usePrototype
100
+ f = "#{designName}_proto.rb"
101
+ design.module_eval(File.read(f), f) if File.exist? f
102
+
103
+ Vpi.module_eval do
104
+ define_method :advance_time do |*args|
105
+ design.feign!
106
+ end
107
+
108
+ def vpi_register_cb #:nodoc:
109
+ warn "vpi_register_cb: callbacks are ignored when prototype is enabled"
110
+ end
111
+ end
112
+
113
+ RubyVPI.say 'prototype is enabled'
114
+ end
115
+
116
+ # load the design's specification
117
+ require "#{designName}_spec.rb"
@@ -1,5 +1,5 @@
1
- # A template to simplify running multiple tests for an examples. This file is
2
- # meant to be embedded in another Rakefile.
1
+ # A template to simplify running multiple tests for an examples.
2
+ # This file is meant to be embedded in another Rakefile.
3
3
  #--
4
4
  # Copyright 2006-2007 Suraj N. Kurapati
5
5
  # See the file named LICENSE for details.
@@ -13,13 +13,11 @@
13
13
 
14
14
  # invoke each test runner with the command-line args
15
15
  at_exit do
16
- unless ARGV.empty?
17
- FileList['**/*.rake'].each do |path|
18
- parent, runner = File.dirname(path), File.basename(path)
16
+ FileList['**/*.rake'].each do |path|
17
+ parent, runner = File.dirname(path), File.basename(path)
19
18
 
20
- cd parent do
21
- sh 'rake', '-f', runner, *ARGV
22
- end
19
+ cd parent do
20
+ sh 'rake', '-f', runner, *ARGV
23
21
  end
24
22
  end
25
23
  end
@@ -0,0 +1,10 @@
1
+ class String
2
+ # Converts this string into a valid Ruby constant name.
3
+ def to_ruby_const_name
4
+ self[0, 1].upcase << self[1..-1]
5
+ end
6
+
7
+ def rstrip_from a
8
+ sub(/#{a}[^#{a}]*$/, '')
9
+ end
10
+ end