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/doc/manual.html CHANGED
@@ -5,166 +5,140 @@
5
5
  <link rel="stylesheet" type="text/css" href="common.css" media="screen" />
6
6
  <link rel="stylesheet" type="text/css" href="print.css" media="print" />
7
7
  <link rel="alternate" type="application/rss+xml" href="http://ruby-vpi.rubyforge.org/doc/rss.xml" title="RSS feed for this project." />
8
- <title>Ruby-VPI user manual</title>
8
+ <title>Ruby-VPI 17.0.0 user manual</title>
9
9
  </head>
10
10
  <body>
11
- <h1 style="margin-top: 0">Ruby-VPI user manual</h1>
12
-
13
- <p style="text-align:center;"><a href="readme.html"><img src="images/tango/home.png" title="Return to main page" alt="Return to main page" /></a></p>
14
-
15
- <div id="menu">
16
- <a href="#index">Contents</a> &middot; <a href="#figures">Figures</a> &middot; <a href="#tables">Tables</a> &middot; <a href="#examples">Examples</a> &middot; <a href="#tips">Tips</a> &middot; <a href="#notes">Notes</a> &middot; <a href="#importants">Importants</a>
11
+ <div id="toc-links">
12
+ <a href="#toc:contents">Contents</a> &middot;
13
+ <a href="#toc:tip">Tips</a> &middot;
14
+ <a href="#toc:note">Notes</a> &middot;
15
+ <a href="#toc:caution">Cautions</a> &middot;
16
+ <a href="#toc:figure">Figures</a> &middot;
17
+ <a href="#toc:table">Tables</a> &middot;
18
+ <a href="#toc:example">Examples</a> &middot;
19
+
20
+ <a href="readme.html" style="color: green; font-size: larger;">Home page</a>
17
21
  </div>
22
+
23
+ <div id="body">
24
+ <hr style="display: none"/>
18
25
 
19
- <div id="index">
20
- <h1>Contents</h1>
21
- <ul><li><a id="a-607892658" href="#Ruby-VPI_user_manual">Ruby-VPI user manual</a><ul><li><a id="a-607893938" href="#legal">Legalities</a></li></ul></li><li><a id="a-607894868" href="#intro">Introduction</a><ul><li><a id="a-607895718" href="#Resources">Resources</a></li><li><a id="a-607896658" href="#intro.features">Features</a></li><li><a id="a-607897688" href="#intro.reqs">Requirements</a></li><li><a id="a-607898638" href="#intro.applications">Applications</a></li><li><a id="a-607899748" href="#intro.appetizers">Appetizers</a></li><li><a id="a-607900808" href="#intro.license">License</a></li><li><a id="a-607901818" href="#intro.related-works">Related works</a><ul><li><a id="a-607903008" href="#intro.related-works.pli">Ye olde <span class="caps">PLI</span></a></li></ul></li></ul></li><li><a id="a-607904308" href="#background">Background</a><ul><li><a id="a-607905318" href="#background.methodology">Methodology</a></li><li><a id="a-607906508" href="#background.vocab">Terminology</a></li><li><a id="a-607907578" href="#background.org">Organization</a></li><li><a id="a-607908608" href="#background.relay">Ruby/Verilog interaction</a></li></ul></li><li><a id="a-607909748" href="#setup">Setup</a><ul><li><a id="a-607910668" href="#setup.manifest">Manifest</a></li><li><a id="a-607911698" href="#setup.reqs">Requirements</a></li><li><a id="a-607912638" href="#setup.recom">Recommendations</a><ul><li><a id="a-607913678" href="#setup.recom.merger">Text merging tool</a></li></ul></li><li><a id="a-607914868" href="#setup.installation">Installation</a><ul><li><a id="a-607916038" href="#setup.installation.windows">Installing on Windows</a></li></ul></li><li><a id="a-607917378" href="#setup.maintenance">Maintenance</a></li></ul></li><li><a id="a-607918548" href="#usage">Usage</a><ul><li><a id="a-607919458" href="#usage.vpi"><span class="caps">VPI</span> in Ruby</a><ul><li><a id="a-607920448" href="#usage.vpi.handles">Handles</a><ul><li><a id="a-607921548" href="#Accessing_a_handle__8217_s_relatives">Accessing a handle&#8217;s relatives</a></li><li><a id="a-607922938" href="#Accessing_a_handle__8217_s_properties">Accessing a handle&#8217;s properties</a></li></ul></li><li><a id="a-607924498" href="#usage.vpi.callbacks">Callbacks</a></li></ul></li><li><a id="a-607925708" href="#usage.prototyping">Prototyping</a></li><li><a id="a-607926808" href="#usage.debugger">Debugging</a><ul><li><a id="a-607927888" href="#usage.debugger.init">Advanced initialization</a></li></ul></li><li><a id="a-607929098" href="#usage.test-runner">Test runner</a><ul><li><a id="a-607930258" href="#usage.test-runner.env-vars">Environment variables</a></li></ul></li><li><a id="a-607931608" href="#usage.examples">Sample tests</a></li><li><a id="a-607932628" href="#usage.tools">Tools</a><ul><li><a id="a-607933658" href="#usage.tools.generate-test">Automated test generation</a></li><li><a id="a-607934908" href="#usage.tools.verilog-ruby-conv">Verilog to Ruby conversion</a></li></ul></li><li><a id="a-607936328" href="#usage.tutorial">Tutorial</a><ul><li><a id="a-607937408" href="#usage.tutorial.declare-design">Start with a design</a></li><li><a id="a-607938748" href="#usage.tutorial.generate-test">Generate a test</a></li><li><a id="a-607940058" href="#usage.tutorial.specification">Specify your expectations</a></li><li><a id="a-607941368" href="#usage.tutorial.implement-proto">Implement the prototype</a></li><li><a id="a-607942708" href="#usage.tutorial.test-proto">Verify the prototype</a></li><li><a id="a-607943958" href="#usage.tutorial.implement-design">Implement the design</a></li><li><a id="a-607945338" href="#usage.tutorial.test-design">Verify the design</a></li></ul></li></ul></li><li><a id="a-607946678" href="#hacking">Hacking</a><ul><li><a id="a-607947628" href="#hacking.scm">Getting the source code</a></li><li><a id="a-607948608" href="#hacking.release-packages">Building release packages</a></li></ul></li><li><a id="a-607949918" href="#problems">Known problems</a><ul><li><a id="a-607950878" href="#problems.ruby">Ruby</a><ul><li><a id="a-607951958" href="#problems.ruby.SystemStackError">SystemStackError</a></li><li><a id="a-607953298" href="#problems.ruby.xUnit">test/unit</a></li></ul></li><li><a id="a-607954508" href="#problem.ivl">Icarus Verilog</a><ul><li><a id="a-607955538" href="#problems.ivl.vpi_handle_by_name">Vpi::vpi_handle_by_name</a><ul><li><a id="a-607956978" href="#problems.ivl.vpi_handle_by_name.absolute-paths">Give full paths to Verilog objects</a></li><li><a id="a-607958638" href="#problems.ivl.vpi_handle_by_name.connect-registers">Registers must be connected</a></li></ul></li><li><a id="a-607960458" href="#problems.ivl.vpi_reset">Vpi::reset</a></li></ul></li><li><a id="a-607961718" href="#problems.vsim">Mentor Modelsim</a><ul><li><a id="a-607962798" href="#problems.vsim.ruby_run">ruby_run();</a></li></ul></li></ul></li><li><a id="a-607964068" href="#glossary">Glossary</a><ul><li><a id="a-607965038" href="#glossary.bench">Bench</a></li><li><a id="a-607966068" href="#glossary.BDD">Behavior driven development (BDD)</a></li><li><a id="a-607967048" href="#glossary.design">Design</a></li><li><a id="a-607968108" href="#glossary.expectation">Expectation</a></li><li><a id="a-607969248" href="#glossary.handle">Handle</a></li><li><a id="a-607970298" href="#glossary.rake">Rake</a></li><li><a id="a-607971318" href="#glossary.rspec">rSpec</a></li><li><a id="a-607972348" href="#glossary.specification">Specification</a></li><li><a id="a-607973538" href="#glossary.TDD">Test driven development (TDD)</a></li><li><a id="a-607974518" href="#glossary.test">Test</a></li><li><a id="a-607975528" href="#glossary.test_bench">Test bench</a></li></ul></li></ul>
26
+ <div id="Ruby-VPI_17.0.0_user_manual" class="front_cover">
27
+ <h1 class="title"><big>Ruby-VPI 17.0.0 user manual</big></h1>
22
28
 
23
- <h1>Formals</h1>
29
+ <h2 class="author">Suraj N. Kurapati</h2>
24
30
 
25
- <h2 id="figures">Figures</h2>
26
- <ol>
27
- <li><a href="#fig..organization">Overall organization of a test</a></li>
28
- <li><a href="#fig..organization.detail">Detailed organization of a test</a></li>
29
- <li><a href="#fig..ruby_relay">Interaction between Ruby and Verilog</a></li>
30
- <li><a href="#figure4">Method naming format for accessing a handle&#8217;s properties</a></li>
31
- </ol>
32
- <h2 id="tables">Tables</h2>
33
- <ol>
34
- <li><a href="#tbl..accessors">Possible accessors and their implications</a></li>
35
- </ol>
36
- <h2 id="examples">Examples</h2>
37
- <ol>
38
- <li><a href="#ex..properties">Examples of accessing a handle&#8217;s properties</a></li>
39
- <li><a href="#ex..callback">Using a callback for value change notification</a></li>
40
- <li><a href="#example3">Seeing what a test runner can do</a></li>
41
- <li><a href="#example4">Running a test with environment variables</a></li>
42
- <li><a href="#fig..counter.v_decl">Declaration of a simple up-counter with synchronous reset</a></li>
43
- <li><a href="#fig..generate-test.rspec">Generating a test with specification in rSpec format</a></li>
44
- <li><a href="#fig..generate-test.unit-test">Generating a test with specification in xUnit format</a></li>
45
- <li><a href="#fig..counter_rspec_spec.rb">Specification implemented in rSpec format</a></li>
46
- <li><a href="#fig..counter_xunit_spec.rb">Specification implemented in xUnit format</a></li>
47
- <li><a href="#fig..counter_proto.rb">Ruby prototype of our Verilog design</a></li>
48
- <li><a href="#fig..test-proto.rspec">Running a test with specification in rSpec format</a></li>
49
- <li><a href="#fig..test-proto.unit-test">Running a test with specification in xUnit format</a></li>
50
- <li><a href="#fig..counter.v_impl">Implementation of a simple up-counter with synchronous reset</a></li>
51
- <li><a href="#fig..test-design.rspec">Running a test with specification in rSpec format</a></li>
52
- <li><a href="#fig..test-design.unit-test">Running a test with specification in xUnit format</a></li>
53
- <li><a href="#ex..TestFoo">Part of a bench which instantiates a Verilog design</a></li>
54
- <li><a href="#ex..TestFoo_bad">Bad design with unconnected registers</a></li>
55
- <li><a href="#ex..TestFoo_fix">Fixed design with wired registers</a></li>
56
- </ol>
57
- <h1>Admonitions</h1>
58
-
59
- <h2 id="tips">Tips</h2>
60
- <ol>
61
- <li><a href="#tip1">Add support for your Verilog simulator</a></li>
62
- <li><a href="#tip2">Running multiple tests at once.</a></li>
63
- <li><a href="#tip3">Using <strong>kdiff3</strong> with the automated test generator.</a></li>
64
- <li><a href="#tip4">What can the test runner do?</a></li>
65
- </ol>
66
- <h2 id="notes">Notes</h2>
67
- <ol>
68
- <li><a href="#note1">Glossary has definitions</a></li>
69
- <li><a href="#note2">Undefined symbols in Windows</a></li>
70
- <li><a href="#note3">No capitalization for <span class="caps">VPI</span> functions</a></li>
71
- <li><a href="#note4"><code>Vpi::Handle</code> heritage</a></li>
72
- <li><a href="#note5">note5</a></li>
73
- <li><a href="#note6">Fixed in 2.0.0.</a></li>
74
- <li><a href="#note7">Fixed in 2.0.0.</a></li>
75
- <li><a href="#note8">Fixed in 2.0.0.</a></li>
76
- </ol>
77
- <h2 id="importants">Importants</h2>
78
- <ol>
79
- <li><a href="#important1">Before we continue&#8230;</a></li>
80
- <li><a href="#important2">Before we continue&#8230;</a></li>
81
- <li><a href="#important3">Before we continue&#8230;</a></li>
82
- <li><a href="#important4">Before we continue&#8230;</a></li>
83
- </ol>
84
- </div>
85
- <h1><a id="Ruby-VPI_user_manual" href="#a-607892658">1</a> &nbsp; Ruby-VPI user manual</h1>
86
31
 
32
+ <h3 class="date">22 July 2007</h3>
87
33
 
88
- <p>This manual was last updated on Sun May 27 14:47:38 -0700 2007.</p>
89
34
 
35
+ <p>
36
+ <div id="About_this_manual" class="paragraph">
37
+ <p class="title">About this manual</p>
38
+ <p>This manual is meant to be read in conjunction with the <a href="../ref/ruby/index.html">reference documentation for Ruby-VPI</a>. In addition, if you are new to <a href="http://www.ruby-lang.org">the Ruby language</a>, you are encouraged to <a href="http://www.ruby-lang.org/en/documentation/">explore its documentation</a> as necessary.</p>
90
39
 
91
- <p>It is meant to be read in conjunction with the <a href="../ref/ruby/index.html">reference documentation for Ruby-VPI</a>. In addition, if you are new to <a href="http://www.ruby-lang.org">the Ruby language</a>, you are encouraged to <a href="http://www.ruby-lang.org/en/documentation/">explore its documentation</a> alongside this manual.</p>
92
40
 
41
+ <p>In this manual, you will notice that the numbers of chapters, sections, figures, admonitions, etc. are hyperlinks that take you back to the corresponding place in the table of contents. These links make it easy to navigate this manual, especially for users of text-only web browsers.</p>
93
42
 
94
- <p>You can give feedback about this manual and, in general, any aspect of the Ruby-VPI project on the <a href="http://rubyforge.org/forum/?group_id=1339">project forums</a>.</p>
95
43
 
44
+ <p>In addition, this manual is distributed as one big HTML file so that you can easily search for a particular topic using nothing more than your web browser&#8217;s built-in text search mechanism. This facilitates offline reading, where an Internet search engine is not available.</p>
96
45
 
97
- <p><em>Happy reading!</em></p>
98
46
 
47
+ <p>You can give feedback about this manual and, in general, any aspect of the Ruby-VPI project on the <a href="http://rubyforge.org/forum/?group_id=1339">project forums</a>. Furthermore, you can <a href="#hacking.manual">edit this manual</a> and contribute your improvements to the <a href="http://rubyforge.org/tracker/?group_id=1339">project patches</a>. Finally, you can find the newest version of this manual at the <a href="http://ruby-vpi.rubyforge.org">Ruby-VPI project website</a>.</p>
48
+ </div>
49
+
99
50
 
100
- <h2 ><a id="legal" href="#a-607893938">1.1</a> &nbsp; Legalities</h2>
51
+ <div id="Legal_notice" class="paragraph">
52
+ <p class="title">Legal notice</p>
53
+ <p>This manual is distributed under <a href="#intro.license">the same license as Ruby-VPI</a>.</p>
101
54
 
102
55
 
103
- <p>This manual is distributed under <a href="#intro.license">the same license as Ruby-VPI</a>.</p>
56
+ <p>The admonition graphics used in this manual are Copyright 2005, 2006 <a href="http://tango.freedesktop.org">Tango Desktop Project</a> and are distributed under <a href="./images/tango/LICENSE">these terms</a>.</p>
57
+ </div>
58
+ </p>
104
59
 
60
+ </div>
61
+
105
62
 
106
- <p>The admonition and navigation graphics used in this manual are Copyright&#169; 2005, 2006 <a href="http://tango.freedesktop.org">Tango Desktop Project</a> and are licensed under <a href="./images/tango/LICENSE">these terms</a>.</p>
63
+ <hr style="display: none"/>
107
64
 
65
+ <div id="intro" class="chapter">
66
+ <h1 class="title">
67
+ Chapter <a href="#a-607687748">2</a>
108
68
 
109
- <h1 ><a id="intro" href="#a-607894868">2</a> &nbsp; Introduction</h1>
69
+ <br/><br/>
110
70
 
71
+ <big>Welcome</big>
72
+ </h1>
111
73
 
112
- <p>Ruby-VPI is a platform for unit testing, rapid prototyping, and systems integration of Verilog modules through the <a href="http://www.ruby-lang.org">Ruby programming language</a>. It lets you:</p>
74
+ <p>Ruby-VPI is a platform for unit testing, rapid prototyping, and systems integration of Verilog modules through the <a href="http://www.ruby-lang.org">Ruby programming language</a>. It lets you:</p>
113
75
 
114
76
 
115
77
  <ul>
116
- <li>Access the <em>entire</em> <a href="http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=33945"><span class="caps">IEEE 1364</span>-2005 Verilog <span class="caps">VPI</span></a> interface from Ruby.</li>
78
+ <li>Access the <em>entire</em> <a href="http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=33945"><span class="caps">IEEE 1364</span>-2005 Verilog VPI</a> interface from Ruby.</li>
117
79
  <li>Create complex Verilog test benches easily and wholly in Ruby.</li>
118
80
  <li>Apply agile software development practices to develop hardware.</li>
119
- <li>Perform <a href="http://ruby-vpi.rubyforge.org/papers/masters_thesis.html">specification-driven functional verification</a> (<a href="http://ruby-vpi.rubyforge.org/papers/masters_thesis.pdf"><span class="caps">PDF</span> version</a>).</li>
81
+ <li>Perform <a href="http://ruby-vpi.rubyforge.org/papers/masters_thesis.html">specification-driven functional verification</a> (<a href="http://ruby-vpi.rubyforge.org/papers/masters_thesis.pdf">PDF version</a>).</li>
120
82
  </ul>
121
83
 
122
84
 
123
85
  <p>Ruby-VPI is <a href="http://en.wikipedia.org/wiki/Open_source_software">open source software</a> released under <a href="#intro.license">this license</a>.</p>
124
86
 
125
87
 
126
- <div id="resources">
88
+ <p>
89
+ <hr style="display: none"/>
127
90
 
128
- <h2><a id="Resources" href="#a-607895718">2.1</a> &nbsp; Resources</h2>
91
+ <div id="resources" class="section">
92
+ <h2 class="title">
93
+ <a href="#a-607624238">2.1</a>
129
94
 
95
+ &nbsp;
130
96
 
131
- <p class="title">Records</p>
97
+ Resources
98
+ </h2>
132
99
 
133
-
134
- <p><a type="application/rss+xml" href="http://ruby-vpi.rubyforge.org/doc/rss.xml"><img src="images/feed-icon-28x28.png" alt="RSS feed for release notifications" style="float: right"/></a></p>
100
+
101
+ <div id="Records" class="paragraph">
102
+ <p class="title">Records</p>
103
+ <a type="application/rss+xml" href="http://ruby-vpi.rubyforge.org/doc/rss.xml"><img src="images/feed-icon-28x28.png" alt="RSS feed for release notifications" style="float: right"/></a>
135
104
 
136
105
 
137
106
  <ul>
138
- <li><a href="history.html">What&#8217;s new?</a>
139
- &#8211; a record of all release notes.</li>
107
+ <li><a href="history.html">What&#8217;s new</a>
108
+ &#8211; a history of all release notes.</li>
140
109
  <li><a href="memo.html">Plans</a>
141
110
  &#8211; pending tasks for future releases.</li>
142
111
  <li><a href="http://ruby-vpi.rubyforge.org/talks/">Talks</a>
143
112
  &#8211; materials from presentations and seminars.</li>
144
113
  <li><a href="http://ruby-vpi.rubyforge.org/papers/">Papers</a>
145
114
  &#8211; research publications.</li>
115
+ <li><a href="http://ruby-vpi.rubyforge.org/papers/masters_thesis.html#tth_sEc5.2">Motivation</a>
116
+ &#8211; why does Ruby-VPI exist?</li>
146
117
  </ul>
118
+ </div>
119
+
147
120
 
148
-
149
- <p class="title">Documentation</p>
150
-
151
-
121
+ <div id="Documentation" class="paragraph">
122
+ <p class="title">Documentation</p>
123
+ <ul>
124
+ <li><a href="manual.html">User manual</a>
125
+ &#8211; complete documentation for users. <em>Start here!</em>
152
126
  <ul>
153
127
  <li><a href="manual.html#usage.tutorial">Tutorial</a>
154
128
  &#8211; learn how to use Ruby-VPI quickly.</li>
155
- <li><a href="manual.html">Manual</a>
156
- &#8211; complete documentation for users. <em>Start here!</em></li>
129
+ </ul>
130
+ </li>
157
131
  <li><a href="../ref/">Reference</a>
158
- &#8211; <span class="caps">API</span> documentation for Ruby libraries and C extension.</li>
132
+ &#8211; API documentation for Ruby libraries and C extension.</li>
159
133
  </ul>
134
+ </div>
135
+
160
136
 
161
-
162
- <p class="title">Facilities</p>
163
-
164
-
165
- <ul>
137
+ <div id="Facilities" class="paragraph">
138
+ <p class="title">Facilities</p>
139
+ <ul>
166
140
  <li><a href="http://rubyforge.org/frs/?group_id=1339">Downloads</a>
167
- &#8211; obtain release packages.</li>
141
+ &#8211; obtain release packages</li>
168
142
  <li><a href="http://ruby-vpi.rubyforge.org/src/ruby-vpi">Source code</a>
169
143
  &#8211; browse online or obtain with <a href="http://darcs.net">Darcs</a>.</li>
170
144
  <li><a href="http://rubyforge.org/forum/?group_id=1339">Forums</a>
@@ -178,27 +152,39 @@
178
152
  <li><a href="http://rubyforge.org/projects/ruby-vpi">Project portal</a>
179
153
  &#8211; hosted generously by <a href="http://rubyforge.org">RubyForge</a>.</li>
180
154
  </ul>
155
+ </div>
156
+
181
157
 
158
+ </div>
159
+ </p>
182
160
 
183
- </div>
184
161
 
185
- <h2 ><a id="intro.features" href="#a-607896658">2.2</a> &nbsp; Features</h2>
162
+ <p>
163
+ <hr style="display: none"/>
186
164
 
165
+ <div id="intro.features" class="section">
166
+ <h2 class="title">
167
+ <a href="#a-607636548">2.2</a>
187
168
 
188
- <p class="title">Portable</p>
169
+ &nbsp;
189
170
 
171
+ Features
172
+ </h2>
190
173
 
191
- <ul>
192
- <li>Supports the <em>entire</em> <a href="http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=33945"><span class="caps">IEEE 1364</span>-2005 Verilog <span class="caps">VPI</span></a> standard.</li>
174
+
175
+ <div id="Portable" class="paragraph">
176
+ <p class="title">Portable</p>
177
+ <ul>
178
+ <li>Supports the <em>entire</em> <a href="http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=33945"><span class="caps">IEEE 1364</span>-2005 Verilog VPI</a> standard.</li>
193
179
  <li>Works with all <a href="#intro.reqs">major Verilog simulators</a> available today.</li>
194
180
  <li>Compiled <em>just once</em> during <a href="manual.html#setup.installation">installation</a> and used forever!</li>
195
181
  </ul>
182
+ </div>
183
+
196
184
 
197
-
198
- <p class="title">Agile</p>
199
-
200
-
201
- <ul>
185
+ <div id="Agile" class="paragraph">
186
+ <p class="title">Agile</p>
187
+ <ul>
202
188
  <li>Enables <a href="http://agilemanifesto.org/">agile practices</a> such as
203
189
  <ul>
204
190
  <li><a href="http://www.testdriven.com">test-driven</a> development</li>
@@ -216,12 +202,12 @@
216
202
  <li>There is absolutely <em>no compiling</em>!</li>
217
203
  </ul></li>
218
204
  </ul>
205
+ </div>
206
+
219
207
 
220
-
221
- <p class="title">Powerful</p>
222
-
223
-
224
- <ul>
208
+ <div id="Powerful" class="paragraph">
209
+ <p class="title">Powerful</p>
210
+ <ul>
225
211
  <li>Inherits the <a href="http://www.ruby-lang.org/en/about/">power and elegance</a> of Ruby:
226
212
  <ul>
227
213
  <li>Unlimited length integers</li>
@@ -237,94 +223,94 @@
237
223
  <li>Uses <a href="http://rubyforge.org/projects/ruby-debug/">ruby-debug</a> for <a href="manual.html#usage.debugger">interactive debugging</a>.</li>
238
224
  <li>Uses <a href="http://eigenclass.org/hiki.rb?rcov">rcov</a> for test <a href="manual.html#usage.test-runner.env-vars">coverage analysis and report generation</a>.</li>
239
225
  </ul>
226
+ </div>
227
+
240
228
 
241
-
242
- <h2 ><a id="intro.reqs" href="#a-607897688">2.3</a> &nbsp; Requirements</h2>
229
+ </div>
230
+ </p>
243
231
 
244
232
 
245
- <p>The following software is necessary in order to use Ruby-VPI.</p>
233
+ <p>
234
+ <hr style="display: none"/>
246
235
 
236
+ <div id="intro.reqs" class="section">
237
+ <h2 class="title">
238
+ <a href="#a-607648378">2.3</a>
247
239
 
248
- <p class="title">Verilog simulator</p>
240
+ &nbsp;
249
241
 
242
+ Requirements
243
+ </h2>
250
244
 
251
- <p>Ruby-VPI is known to work with the following simulators. However, you should be able to use it with any Verilog simulator that supports <span class="caps">VPI</span>.</p>
245
+ <p>The following software is necessary in order to use Ruby-VPI.</p>
252
246
 
253
247
 
254
- <ul>
255
- <li><a href="http://www.synopsys.com/products/simulation/simulation.html">Synopsys <span class="caps">VCS</span></a>
256
- &#8211; any version that supports the <tt>-load</tt> option is acceptable.</li>
257
- </ul>
248
+ <p>
249
+ <div id="Verilog_simulator" class="paragraph">
250
+ <p class="title">Verilog simulator</p>
251
+ Ruby-VPI is known to work with the following simulators. However, you should be able to use it with any Verilog simulator that supports VPI.
258
252
 
259
253
 
260
254
  <ul>
261
- <li><a href="http://www.model.com">Mentor Modelsim</a>
255
+ <li><a href="http://www.synopsys.com/products/simulation/simulation.html">Synopsys VCS</a>
256
+ &#8211; any version that supports the <tt>-load</tt> option is acceptable.</li>
257
+ <li><a href="http://www.model.com">Mentor Modelsim</a>
262
258
  &#8211; any version that supports the <tt>-pli</tt> option is acceptable.</li>
263
- </ul>
264
-
265
-
266
- <ul>
267
- <li><a href="http://www.cadence.com/products/functional_ver/nc-verilog/">Cadence NC-Sim / NC-Verilog</a>
259
+ <li><a href="http://www.cadence.com/products/functional_ver/nc-verilog/">Cadence NC-Sim / NC-Verilog</a>
268
260
  &#8211; any version that supports the <tt>+loadvpi</tt> option is acceptable.</li>
269
- </ul>
270
-
271
-
272
- <ul>
273
- <li><a href="http://www.pragmatic-c.com/gpl-cver/"><span class="caps">GPL</span> Cver</a>
261
+ <li><a href="http://www.pragmatic-c.com/gpl-cver/">GPL Cver</a>
274
262
  &#8211; version 2.11a or newer is acceptable.</li>
263
+ <li><a href="http://www.icarus.com/eda/Verilog/">Icarus Verilog</a>
264
+ &#8211; version 0.8 is <em>mostly</em> acceptable&#8212;you <strong>will not</strong> be able to <a href="manual.html#background.org.vpi.util">access child handles through method calls</a>. The reason for this limitation is explained <a href="manual.html#problems.ivl.vpi_handle_by_name.absolute-paths">in the user manual</a>.</li>
275
265
  </ul>
266
+ </div>
267
+
276
268
 
277
-
278
- <ul>
279
- <li><a href="http://www.icarus.com/eda/Verilog/">Icarus Verilog</a>
280
- &#8211; version 0.8 is <em>mostly</em> acceptable&#8212;you <strong>will not</strong> be able to <a href="manual.html#background.org.vpi.util">access child handles through method calls</a>. The reason for this limitation is explained <a href="#problems.ivl.vpi_handle_by_name.absolute-paths">in the user manual</a>.</li>
281
- </ul>
282
-
283
-
284
- <p class="title">Compilers</p>
285
-
286
-
287
- <ul>
269
+ <div id="Compilers" class="paragraph">
270
+ <p class="title">Compilers</p>
271
+ <ul>
288
272
  <li><a href="http://en.wikipedia.org/wiki/Make">make</a>
289
273
  &#8211; any flavor should be acceptable.</li>
290
- </ul>
291
-
292
-
293
- <ul>
294
- <li>C compiler
295
- &#8211; the <a href="http://www.gnu.org/software/gcc/" title="GCC"><span class="caps">GNU</span> Compiler Collection</a> is preferred, but any C compiler should be acceptable.</li>
296
- </ul>
297
-
298
-
299
- <ul>
300
- <li><a href="http://www.ruby-lang.org">Ruby</a>
274
+ <li>C compiler
275
+ &#8211; the <a href="http://www.gnu.org/software/gcc/" title="GCC">GNU Compiler Collection</a> is preferred, but any C compiler should be acceptable.</li>
276
+ <li><a href="http://www.ruby-lang.org">Ruby</a>
301
277
  &#8211; version 1.8 or newer, including header and linkable object files for building extensions, is necessary. You can install Ruby by following <a href="http://www.rubygarden.org/faq/section/show/3">these instructions</a>.</li>
302
278
  </ul>
279
+ </div>
280
+
303
281
 
304
-
305
- <p class="title">Libraries</p>
306
-
307
-
308
- <ul>
309
- <li><a href="http://en.wikipedia.org/wiki/Pthreads" title="pthreads"><span class="caps">POSIX</span> threads</a>
282
+ <div id="Libraries" class="paragraph">
283
+ <p class="title">Libraries</p>
284
+ <ul>
285
+ <li><a href="http://en.wikipedia.org/wiki/Pthreads" title="pthreads">POSIX threads</a>
310
286
  &#8211; header and linkable object files, and operating system support for this library are necessary.</li>
287
+ <li><a href="http://rubyforge.org/frs/?group_id=126">RubyGems</a>
288
+ &#8211; any recent version should be acceptable. You can install RubyGems by following <a href="http://www.rubygems.org/read/chapter/3">these instructions</a>.</li>
311
289
  </ul>
290
+ </div>
291
+ </p>
312
292
 
293
+ </div>
294
+ </p>
313
295
 
314
- <ul>
315
- <li><a href="http://rubyforge.org/frs/?group_id=126">RubyGems</a>
316
- &#8211; any recent version should be acceptable. You can install RubyGems by following <a href="http://www.rubygems.org/read/chapter/3">these instructions</a>.</li>
317
- </ul>
318
296
 
297
+ <p>
298
+ <hr style="display: none"/>
299
+
300
+ <div id="intro.applications" class="section">
301
+ <h2 class="title">
302
+ <a href="#a-607650938">2.4</a>
319
303
 
320
- <h2 ><a id="intro.applications" href="#a-607898638">2.4</a> &nbsp; Applications</h2>
304
+ &nbsp;
321
305
 
306
+ Applications
307
+ </h2>
322
308
 
323
- <p>Examples of tasks that can be performed with Ruby-VPI are:</p>
309
+ Examples of tasks that can be performed with Ruby-VPI are:
324
310
 
325
311
 
326
312
  <ul>
327
- <li>From the second edition of <a href="http://www.sutherland-hdl.com/publications.html"><em>The Verilog <span class="caps">PLI</span> Handbook</em></a>:
313
+ <li>From the second edition of <a href="http://www.sutherland-hdl.com/publications.html"><em>The Verilog PLI Handbook</em></a>:
328
314
  <ul>
329
315
  <li>C language bus-functional models</li>
330
316
  <li>Reading test vector files</li>
@@ -350,11 +336,23 @@
350
336
  </ul></li>
351
337
  </ul>
352
338
 
339
+ </div>
340
+ </p>
353
341
 
354
- <h2 ><a id="intro.appetizers" href="#a-607899748">2.5</a> &nbsp; Appetizers</h2>
355
342
 
343
+ <p>
344
+ <hr style="display: none"/>
356
345
 
357
- <p>Here is a tiny sampling of code to whet your appetite. See <a href="manual.html#usage.tutorial">the tutorial</a> for more samples.</p>
346
+ <div id="intro.appetizers" class="section">
347
+ <h2 class="title">
348
+ <a href="#a-607653538">2.5</a>
349
+
350
+ &nbsp;
351
+
352
+ Appetizers
353
+ </h2>
354
+
355
+ <p>Here is a tiny sampling of code to whet your appetite. See <a href="manual.html#usage.tutorial">the tutorial</a> for more samples.</p>
358
356
 
359
357
 
360
358
  <ul>
@@ -363,7 +361,7 @@
363
361
 
364
362
 
365
363
  <blockquote>
366
- <p><code class="code">some_register.intVal = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#00D; font-weight:bold">2048</span></code></p>
364
+ <p><code class="code">your_register.intVal = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#00D; font-weight:bold">2048</span></code></p>
367
365
  </blockquote>
368
366
 
369
367
 
@@ -373,7 +371,7 @@
373
371
 
374
372
 
375
373
  <blockquote>
376
- <p><code class="code">some_module.all_net? { |net| net.z? }</code></p>
374
+ <p><code class="code">your_module.all_net? { |net| net.z? }</code></p>
377
375
  </blockquote>
378
376
 
379
377
 
@@ -383,457 +381,690 @@
383
381
 
384
382
 
385
383
  <blockquote>
386
- <p><code class="code">puts some_register</code></p>
384
+ <p><code class="code">puts your_register</code></p>
385
+ </blockquote>
386
+
387
+
388
+ <ul>
389
+ <li>Access the first five elements in a memory:</li>
390
+ </ul>
391
+
392
+
393
+ <blockquote>
394
+ <p><code class="code">your_memory.memoryWord_a[<span style="color:#00D; font-weight:bold">0</span>..<span style="color:#00D; font-weight:bold">4</span>]</code></p>
387
395
  </blockquote>
388
396
 
389
397
 
390
398
  <ul>
391
- <li>Simulate fifteen clock cycles:</li>
399
+ <li>Clear a memory by filling it with zeroes:</li>
392
400
  </ul>
393
401
 
394
402
 
395
403
  <blockquote>
396
- <p><code class="code"><span style="color:#00D; font-weight:bold">15</span>.times { simulate }</code></p>
404
+ <p><code class="code">your_memory.each_memoryWord {|w| w.intVal = <span style="color:#00D; font-weight:bold">0</span>}</code></p>
397
405
  </blockquote>
398
406
 
407
+ </div>
408
+ </p>
399
409
 
400
- <h2 ><a id="intro.license" href="#a-607900808">2.6</a> &nbsp; License</h2>
401
410
 
411
+ <p>
412
+ <hr style="display: none"/>
402
413
 
403
- <p>Copyright&#169; 2006-2007 Suraj N. Kurapati</p>
414
+ <div id="intro.license" class="section">
415
+ <h2 class="title">
416
+ <a href="#a-607656258">2.6</a>
404
417
 
418
+ &nbsp;
405
419
 
406
- <p>Permission is hereby granted, free of charge, to any person obtaining a
407
- copy of this software and associated documentation files (the &#8220;Software&#8221;),
408
- to deal in the Software without restriction, including without limitation the
409
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
410
- sell copies of the Software, and to permit persons to whom the Software is
411
- furnished to do so, subject to the following conditions:</p>
420
+ License
421
+ </h2>
412
422
 
423
+ <p>Copyright 2006 Suraj N. Kurapati &lt;snk@gna.org&gt;</p>
413
424
 
414
- <p>All copies and portions of the Software (together the &#8220;Derivatives&#8221;) and
415
- their corresponding machine-readable source code (the &#8220;Code&#8221;) must include the
416
- above copyright notice and this permission notice. The Code must reflect all
417
- modifications made to the Derivatives. The Derivatives must be distributed
418
- either with the Code or, if the Code is obtainable for no more than the cost
419
- of distribution plus a nominal fee, with information on how to obtain the Code.</p>
420
425
 
426
+ <p>Permission is hereby granted, free of charge, to any person obtaining a copy of
427
+ this software and associated documentation files (the &quot;Software&quot;), to deal in
428
+ the Software without restriction, including without limitation the rights to
429
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
430
+ the Software, and to permit persons to whom the Software is furnished to do so,
431
+ subject to the following conditions:</p>
421
432
 
422
- <p><span class="caps">THE SOFTWARE IS PROVIDED</span> &#8220;AS IS&#8221;, <span class="caps">WITHOUT WARRANTY OF ANY KIND</span>, EXPRESS OR
423
- <span class="caps">IMPLIED</span>, INCLUDING <span class="caps">BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY</span>,
424
- <span class="caps">FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT</span>. <span class="caps">IN NO EVENT SHALL</span>
425
- <span class="caps">THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM</span>, DAMAGES <span class="caps">OR OTHER</span>
426
- <span class="caps">LIABILITY</span>, WHETHER <span class="caps">IN AN ACTION OF CONTRACT</span>, TORT <span class="caps">OR OTHERWISE</span>, ARISING <span class="caps">FROM</span>,
427
- <span class="caps">OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
428
- <span class="caps">THE SOFTWARE</span>.</p>
429
433
 
434
+ <p>1. All modified and unmodified copies and substantial portions of the Software
435
+ (the &quot;Derivatives&quot;) and their corresponding machine-readable source code (the
436
+ &quot;Code&quot;) must include the above copyright notice and this permission notice.</p>
430
437
 
431
- <h2 ><a id="intro.related-works" href="#a-607901818">2.7</a> &nbsp; Related works</h2>
432
438
 
439
+ <p>2. Upon distribution, the Derivatives must be accompanied either by the Code or,
440
+ if the Code is obtainable for no more than the cost of distribution plus a
441
+ nominal fee, by information on how to obtain the Code.</p>
433
442
 
434
- <ul>
435
- <li><a href="http://jove.sourceforge.net"><span class="caps">JOVE</span></a> is a Java interface to <span class="caps">VPI</span>.</li>
436
- <li><a href="http://teal.sourceforge.net">Teal</a> is a C++ interface to <span class="caps">VPI</span>.</li>
437
- <li><a href="http://embedded.eecs.berkeley.edu/Alumni/pinhong/scriptEDA/">ScriptEDA</a> is a Perl, Python, and Tcl interface to <span class="caps">VPI</span>.</li>
438
- <li><a href="http://rhdl.rubyforge.org"><span class="caps">RHDL</span></a> is a hardware description and verification language based on Ruby.</li>
439
- <li><a href="http://myhdl.jandecaluwe.com">MyHDL</a> is a hardware description and verification language based on Python, which features conversion to Verilog and co-simulation.</li>
440
- </ul>
441
443
 
444
+ <p><span class="caps">THE SOFTWARE IS PROVIDED</span> &quot;AS IS&quot;, <span class="caps">WITHOUT WARRANTY OF ANY KIND</span>, EXPRESS OR
445
+ IMPLIED, INCLUDING <span class="caps">BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY</span>, FITNESS
446
+ <span class="caps">FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT</span>. IN <span class="caps">NO EVENT SHALL THE AUTHORS OR</span>
447
+ <span class="caps">COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM</span>, DAMAGES <span class="caps">OR OTHER LIABILITY</span>, WHETHER
448
+ <span class="caps">IN AN ACTION OF CONTRACT</span>, TORT <span class="caps">OR OTHERWISE</span>, ARISING FROM, OUT <span class="caps">OF OR IN</span>
449
+ <span class="caps">CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE</span>.</p>
442
450
 
443
- <h3 ><a id="intro.related-works.pli" href="#a-607903008">2.7.1</a> &nbsp; Ye olde <span class="caps">PLI</span></h3>
451
+ </div>
452
+ </p>
444
453
 
445
454
 
446
- <p>The following projects utilize the archaic <strong>tf</strong> and <strong>acc</strong> PLI interfaces, which have been officially deprecated in <span class="caps">IEEE</span> Std 1364-2005.</p>
455
+ <p>
456
+ <hr style="display: none"/>
447
457
 
458
+ <div id="intro.related-works" class="section">
459
+ <h2 class="title">
460
+ <a href="#a-607661648">2.7</a>
448
461
 
449
- <ul>
450
- <li><a href="http://www.nelsim.com">ScriptSim</a> is a Perl, Python, and Tcl/Tk interface to <span class="caps">PLI</span>.</li>
451
- <li><a href="http://www.veripool.com/verilog-pli.html">Verilog::Pli</a> is a Perl interface to <span class="caps">PLI</span>.</li>
452
- <li><a href="http://www.time-rover.com/jpli/"><span class="caps">JPLI</span></a> is a proprietary Java interface to <span class="caps">PLI</span>.</li>
462
+ &nbsp;
463
+
464
+ Related works
465
+ </h2>
466
+
467
+ <ul>
468
+ <li><a href="http://jove.sourceforge.net">JOVE</a> is a Java interface to VPI.</li>
469
+ <li><a href="http://teal.sourceforge.net">Teal</a> is a C++ interface to VPI.</li>
470
+ <li><a href="http://embedded.eecs.berkeley.edu/Alumni/pinhong/scriptEDA/">ScriptEDA</a> is a Perl, Python, and Tcl interface to VPI.</li>
471
+ <li><a href="http://rhdl.rubyforge.org">RHDL</a> is a hardware description and verification language based on Ruby.</li>
472
+ <li><a href="http://myhdl.jandecaluwe.com">MyHDL</a> is a hardware description and verification language based on Python, which features conversion to Verilog and co-simulation.</li>
453
473
  </ul>
454
474
 
455
475
 
456
- <h1 ><a id="background" href="#a-607904308">3</a> &nbsp; Background</h1>
476
+ <p>
477
+ <hr style="display: none"/>
457
478
 
479
+ <div id="intro.related-works.pli" class="section">
480
+ <h3 class="title">
481
+ <a href="#a-607658708">2.7.1</a>
458
482
 
459
- <h2 ><a id="background.methodology" href="#a-607905318">3.1</a> &nbsp; Methodology</h2>
483
+ &nbsp;
460
484
 
485
+ Ye olde PLI
486
+ </h3>
461
487
 
462
- <p>Ruby-VPI presents an open-ended interface to <span class="caps">VPI</span>. Thus, you can use any methodology you wish when writing tests. However, being an agile language, Ruby makes it <em>very</em> easy to use agile development practies such as <a href="#glossary.TDD"><span class="caps">TDD</span></a> and <a href="#glossary.BDD"><span class="caps">BDD</span></a>.</p>
488
+ The following projects utilize the archaic <strong>tf</strong> and <strong>acc</strong> PLI interfaces, which have been officially deprecated in IEEE Std 1364-2005.
463
489
 
464
490
 
465
- <h2 ><a id="background.vocab" href="#a-607906508">3.2</a> &nbsp; Terminology</h2>
491
+ <ul>
492
+ <li><a href="http://www.nelsim.com">ScriptSim</a> is a Perl, Python, and Tcl/Tk interface to PLI.</li>
493
+ <li><a href="http://www.veripool.com/verilog-pli.html">Verilog::Pli</a> is a Perl interface to PLI.</li>
494
+ </ul>
466
495
 
496
+ </div>
497
+ </p>
467
498
 
468
- <div class="admonition">
499
+ </div>
500
+ </p>
501
+ </div>
502
+
469
503
 
470
- <div class="note" id="note1">
504
+ <hr style="display: none"/>
471
505
 
472
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
506
+ <div id="setup" class="chapter">
507
+ <h1 class="title">
508
+ Chapter <a href="#a-607728418">3</a>
473
509
 
510
+ <br/><br/>
474
511
 
475
- <p class="title">Note: Glossary has definitions</p>
512
+ <big>Setup</big>
513
+ </h1>
476
514
 
515
+
516
+ <hr style="display: none"/>
477
517
 
478
- <p>Have a look at the <a href="#glossary">glossary</a> for definitions of terms used in this manual.</p>
518
+ <div id="setup.manifest" class="section">
519
+ <h2 class="title">
520
+ <a href="#a-607690938">3.1</a>
479
521
 
522
+ &nbsp;
480
523
 
481
- </div>
524
+ Manifest
525
+ </h2>
482
526
 
483
- </div>
527
+ When you extract a release package, the following is what you would expect to find.
484
528
 
485
- <p>As a newcomer into the world of Verilog, I often heard the term <strong>test bench</strong>: &#8220;I ran the test bench, but it didn&#8217;t work!&#8221; or &#8220;Are you crazy?!! You <em>still</em> haven&#8217;t written the test bench?&#8221;, for example. I poured through my textbook for a definition of the term, but it was to no avail. Instead, it nonchalantly employed the term <em>throughout</em> its being, as if mocking my ignorance of what seems to be universal knowledge.</p>
486
529
 
530
+ <ul>
531
+ <li><tt>doc</tt> contains user documentation in various formats.</li>
532
+ <li><tt>ref</tt> contains reference API documentation in HTML format.</li>
533
+ <li><tt>ext</tt> contains source code, written in the C language, for the <a href="#organization">core of Ruby-VPI</a></li>
534
+ <li><tt>lib</tt> contains Ruby libraries provided by Ruby-VPI.</li>
535
+ <li><tt>bin</tt> contains various tools. See <a href="#usage.tools">Section 5.4</a> for more information.</li>
536
+ <li><tt>samp</tt> contains example tests. See <a href="#usage.examples">Section 5.5</a> for more information.</li>
537
+ </ul>
487
538
 
488
- <p>Defeated, I turned to my inner faculties to determine the answer. Let&#8217;s see, the term <em>test bench</em> has the word <em>test</em>&mdash;so it has something to do with testing&mdash;and it has the word <em>bench</em>&mdash;so maybe it&#8217;s referring to a table where the testing should occur. This reasoning grew increasingly familiar as my mind rummaged through towering stores of obsolescence and ultimately revealed dreaded memories of sleepless anguish: debugging electronics in the robotics laboratory.</p>
539
+ </div>
540
+
489
541
 
542
+ <hr style="display: none"/>
490
543
 
491
- <p>Aha! I exclaimed, hesitantly, rushing to dismiss the past. The term has its roots in the testing of electronic devices, where an engineer would sit at a bench in an electronics laboratory and verify that an electronic component satisfies some criteria. The bench would be furnished with tools of measurement and manipulation&mdash;such as oscilloscopes, voltmeters, soldering irons, and so on&mdash;which help the engineer to verify the electronic component or locate the sources of defects in the component.</p>
544
+ <div id="setup.reqs" class="section">
545
+ <h2 class="title">
546
+ <a href="#a-607696378">3.2</a>
492
547
 
548
+ &nbsp;
493
549
 
494
- <p>Alright, now I remember what a laboratory bench is, but how does that compare with the term test bench? Surely they cannot have the same meaning, because it doesn&#8217;t make sense to <em>run</em> a laboratory bench or to <em>write</em> one. Thus, to avoid propagating such confusion into this manual, I have attempted to clarify the terminology by <a href="#glossary">simplifying and reintroducing it in a new light</a>.</p>
550
+ Requirements
551
+ </h2>
495
552
 
553
+ <p>See <a href="#intro.reqs">Section 2.3</a> above.</p>
496
554
 
497
- <h2 ><a id="background.org" href="#a-607907578">3.3</a> &nbsp; Organization</h2>
498
555
 
556
+ <p>
557
+ <hr style="display: none"/>
499
558
 
500
- <div class="formal">
559
+ <div class="admonition">
560
+ <div class="tip" id="Add_support_for_your_Verilog_simulator">
561
+ <img src="images/tango/tip.png" alt="tip" class="icon"/>
501
562
 
502
- <div class="figure" id="fig..organization">
563
+ <p class="title"><a href="#a-607693408">Tip 1</a>. &nbsp; Add support for your Verilog simulator</p>
503
564
 
504
- <p class="title">Figure 1. Overall organization of a test</p>
565
+ Write a <a href="http://rubyforge.org/tracker/?group_id=1339">support request</a> for your simulator, while providing a sample transcript of the commands you use to run a test with your simulator, and I will add support for your simulator in the next release!
566
+ </div>
567
+ </div>
568
+ </p>
505
569
 
570
+ </div>
571
+
506
572
 
507
- <p><img src="figures/organization.png" alt="" /></p>
573
+ <hr style="display: none"/>
508
574
 
575
+ <div id="setup.recom" class="section">
576
+ <h2 class="title">
577
+ <a href="#a-607702548">3.3</a>
509
578
 
510
- </div>
579
+ &nbsp;
511
580
 
512
- </div>
581
+ Recommendations
582
+ </h2>
513
583
 
514
- <p>As <a href="#fig..organization">the figure named &ldquo;Overall organization of a test&rdquo;</a> shows, a <a href="#glossary.test">test</a> is composed of a <a href="#glossary.bench">bench</a>, a <a href="#glossary.design">design</a>, and a <a href="#glossary.specification">specification</a>.</p>
584
+ <p>The following software may make your interactions with Ruby-VPI more pleasant.</p>
515
585
 
516
586
 
517
- <p>To extend the <a href="#background.vocab">analogy of an electronics laboratory</a>, the <em>bench</em> acts as the laboratory bench which provides measurement and manipulation tools. The <em>design</em> acts as the electronic component being verified by the engineer. And the <em>specification</em> acts as the engineer who measures, manipulates, and verifies the electronic component.</p>
587
+ <p>
588
+ <hr style="display: none"/>
518
589
 
590
+ <div id="setup.recom.merger" class="section">
591
+ <h3 class="title">
592
+ <a href="#a-607699208">3.3.1</a>
519
593
 
520
- <div class="formal">
594
+ &nbsp;
521
595
 
522
- <div class="figure" id="fig..organization.detail">
596
+ Text merging tool
597
+ </h3>
523
598
 
524
- <p class="title">Figure 2. Detailed organization of a test</p>
599
+ An <em>interactive</em> text merging tool can greatly simplify the process of transferring wanted changes from one file to another. In particular, such tools are especially beneficial when using the <a href="#usage.tools.generate">automated test generator</a>. A handful of the currently available open-source text merging tools are listed below.
525
600
 
526
601
 
527
- <p><img src="figures/organization_detailed.png" alt="" /></p>
602
+ <ul>
603
+ <li><a href="http://kdiff3.sourceforge.net/"><strong>kdiff3</strong></a> is a graphical, three-way merging tool for KDE.</li>
604
+ </ul>
528
605
 
529
606
 
530
- </div>
607
+ <ul>
608
+ <li><a href="http://meld.sourceforge.net/"><strong>meld</strong></a> is a graphical, three-way merging tool for GNOME.</li>
609
+ </ul>
531
610
 
532
- </div>
533
611
 
534
- <p>Now, let us take a more detailed look at this organization, as illustrated in <a href="#fig..organization.detail">the figure named &ldquo;Detailed organization of a test&rdquo;</a>.</p>
612
+ <ul>
613
+ <li><a href="http://tkdiff.sourceforge.net/"><strong>tkdiff</strong></a> is a graphical, two-way merging tool that uses the cross-platform Tk windowing toolkit.</li>
614
+ </ul>
535
615
 
536
616
 
537
- <p>Notice that Ruby-VPI encapsulates all communication between the Ruby interpreter and <span class="caps">VPI</span>. This allows the specification, or any Ruby program in general, to access <span class="caps">VPI</span> using nothing more than the Ruby language! Thus, Ruby-VPI removes the burden of having to write C programs in order to use <span class="caps">VPI</span>.</p>
617
+ <ul>
618
+ <li><a href="http://furius.ca/xxdiff/"><strong>xxdiff</strong></a> is a graphical, three-way merging tool.</li>
619
+ </ul>
538
620
 
539
621
 
540
- <h2 ><a id="background.relay" href="#a-607908608">3.4</a> &nbsp; Ruby/Verilog interaction</h2>
622
+ <ul>
623
+ <li><a href="http://elonen.iki.fi/code/imediff/"><strong>imediff2</strong></a> is a textual, fullscreen two-way merging tool. It is very useful when you are working remotely via SSH.</li>
624
+ </ul>
541
625
 
626
+ </div>
627
+ </p>
542
628
 
543
- <p>In a typical <span class="caps">VPI</span> application written in C, the <em>Verilog simulator</em> is in charge. Verilog code temporarily transfers control to C by invoking C functions, which return control to Verilog when they finish.</p>
629
+ </div>
630
+
544
631
 
632
+ <hr style="display: none"/>
545
633
 
546
- <p>In contrast, Ruby-VPI puts the <em>specification</em> in charge. The specification temporarily transfers control to the Verilog simulator by invoking the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::advance_time</code> method, which returns control to the specification when it finishes. This process is illustrated in <a href="#fig..ruby_relay">the figure named &ldquo;Interaction between Ruby and Verilog&rdquo;</a>.</p>
634
+ <div id="setup.inst" class="section">
635
+ <h2 class="title">
636
+ <a href="#a-607711698">3.4</a>
547
637
 
638
+ &nbsp;
548
639
 
549
- <p>Ruby-VPI&#8217;s approach is the same as any software testing framework, where the <em>specification</em> drives the design under test. Whereas, the typical <span class="caps">VPI</span> &#38; C approach is literally <em>backwards</em> because the design under test drives the specification.</p>
640
+ Installation
641
+ </h2>
550
642
 
643
+ <p>Once you have satisfied the <a href="#setup.reqs">necessary requirements</a>, you can install Ruby-VPI by running the <pre>gem install -y ruby-vpi</pre> command. RubyGems will install Ruby-VPI into the system gem directory, whose path can be determined by running the <pre>gem env gemdir</pre> command. Within this directory, there is a <tt>gems/</tt> subdirectory which contains the Ruby-VPI installation, as illustrated below.</p>
551
644
 
552
- <div class="formal">
553
645
 
554
- <div class="figure" id="fig..ruby_relay">
646
+ <pre>
647
+ $ gem env gemdir
648
+ /usr/lib/ruby/gems/1.8
555
649
 
556
- <p class="title">Figure 3. Interaction between Ruby and Verilog</p>
650
+ $ ls -d /usr/lib/ruby/gems/1.8/gems/ruby-vpi*
651
+ /usr/lib/ruby/gems/1.8/gems/ruby-vpi-7.0.0/
652
+ </pre>
557
653
 
558
654
 
559
- <p><img src="figures/ruby_relay.png" alt="" /></p>
655
+ <p>
656
+ <hr style="display: none"/>
560
657
 
658
+ <div class="admonition">
659
+ <div class="note" id="Tuning_for_maximum_performance">
660
+ <img src="images/tango/note.png" alt="note" class="icon"/>
561
661
 
562
- <ol>
563
- <li>The current simulation time is <em>X</em>.</li>
564
- <li>The specification invokes the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::advance_time</code> method with parameter <em>Y</em>, which specifies the number of simulation time steps to be simulated.</li>
565
- <li>The Verilog simulator is now in control (temporarily).</li>
566
- <li>The current simulation time has <em>not</em> changed; it is still <em>X</em>.</li>
567
- <li>The Verilog simulator simulates <em>Y</em> simulation time steps.</li>
568
- <li>The current simulation time is now <em>X + Y</em>.</li>
569
- <li>The Verilog simulator returns control back to the specification.</li>
570
- </ol>
662
+ <p class="title"><a href="#a-607705108">Note 1</a>. &nbsp; Tuning for maximum performance</p>
571
663
 
664
+ You can tune your installation of Ruby-VPI for maximum performance by adding your C compiler&#8217;s optimization flag to the <code class="code"><span style="color:#036; font-weight:bold">CFLAGS</span></code> environment variable <em>before</em> you run the <pre>gem install -y ruby-vpi</pre> command. For example, if your C compiler is GCC, then you can set <code class="code"><span style="color:#036; font-weight:bold">CFLAGS</span></code> to <tt>-O9</tt> for maximum optimization.
665
+ </div>
666
+ </div>
667
+
572
668
 
573
- </div>
669
+ <hr style="display: none"/>
574
670
 
575
- </div>
671
+ <div id="setup.inst.windows" class="section">
672
+ <h3 class="title">
673
+ <a href="#a-607707638">3.4.1</a>
576
674
 
577
- <h1 ><a id="setup" href="#a-607909748">4</a> &nbsp; Setup</h1>
675
+ &nbsp;
578
676
 
677
+ Installing on Windows
678
+ </h3>
579
679
 
580
- <h2 ><a id="setup.manifest" href="#a-607910668">4.1</a> &nbsp; Manifest</h2>
680
+ <p>After Ruby-VPI is compiled, it is linked to symbols whose names begin with <tt>_vpi</tt>. In GNU/Linux and similar operating systems, these symbols are allowed to be undefined. However, one <a href="http://sourceware.org/ml/cygwin/2001-12/msg01293.html">cannot compile a shared object file with references to undefined symbols in Windows</a>.</p>
581
681
 
582
682
 
583
- <p>When you extract a release package, the following is what you would expect to find.</p>
683
+ <p>One solution to this problem is to supply the Verilog simulator&#8217;s VPI object file, which contains definitions of all VPI symbols, to the linker. The following steps illustrate this process.</p>
584
684
 
585
685
 
586
686
  <ul>
587
- <li><tt>doc</tt> contains user documentation in various formats.</li>
588
- <li><tt>ref</tt> contains reference <span class="caps">API</span> documentation in <span class="caps">HTML</span> format.</li>
589
- <li><tt>ext</tt> contains source code, written in the C language, for the <a href="#background.org">core of Ruby-VPI</a>.</li>
590
- <li><tt>lib</tt> contains Ruby libraries provided by Ruby-VPI.</li>
591
- <li><tt>bin</tt> contains various tools. See <a href="#usage.tools">the section named &ldquo;Tools&rdquo;</a> for more information.</li>
592
- <li><tt>samp</tt> contains example tests. See <a href="#usage.examples">the section named &ldquo;Sample tests&rdquo;</a> for more information.</li>
687
+ <li>Install <a href="http://www.cygwin.com">Cygwin</a>, the Linux-like environment for Windows.</li>
593
688
  </ul>
594
689
 
595
690
 
596
- <h2 ><a id="setup.reqs" href="#a-607911698">4.2</a> &nbsp; Requirements</h2>
691
+ <ul>
692
+ <li>Search for object files whose names end with <tt>.so</tt>, <tt>.o</tt>, or <tt>.dll</tt> in your Verilog simulator&#8217;s installation directory.</li>
693
+ </ul>
597
694
 
598
695
 
599
- <p>See <a href="#intro.reqs">the section named &ldquo;Requirements&rdquo;</a> above.</p>
696
+ <ul>
697
+ <li>Determine which object files, among those found in the previous step, contain symbols whose names begin with &#8220;_vpi&#8221; by running the <pre>for x in *.{o,so,dll}; do nm $x | grep -q '[Tt] _vpi' &amp;&amp; echo $x; done</pre> command in Cygwin.
698
+ <ul>
699
+ <li>If you are using Mentor Modelsim, the desired object file can be found at a path similar to <tt>C:\Modeltech\win32\libvsim.dll</tt>.</li>
700
+ <li>If you are using GPL Cver, the desired object file can be found at a path similar to <tt>C:\gplcver\objs\v_vpi.o</tt>.</li>
701
+ </ul></li>
702
+ </ul>
600
703
 
601
704
 
602
- <div class="admonition">
705
+ <ul>
706
+ <li>Assign the path of the object file (determined in the previous step) to the <code class="code"><span style="color:#036; font-weight:bold">LDFLAGS</span></code> environment variable. For example, if the object file&#8217;s path is <tt>/foo/bar/vpi.so</tt>, then you would run the <pre>export LDFLAGS=/foo/bar/vpi.so</pre> command in Cygwin.</li>
707
+ </ul>
603
708
 
604
- <div class="tip" id="tip1">
605
709
 
606
- <p style="float:left"><img src="images/tango/tip.png" title="tip" alt="tip" /></p>
710
+ <ul>
711
+ <li>You may now install Ruby-VPI by running the <pre>gem install ruby-vpi</pre> command in Cygwin.</li>
712
+ </ul>
607
713
 
714
+ </div>
715
+ </p>
608
716
 
609
- <p class="title">Tip: Add support for your Verilog simulator</p>
717
+ </div>
718
+
610
719
 
720
+ <hr style="display: none"/>
611
721
 
612
- <p>Write a <a href="http://rubyforge.org/tracker/?group_id=1339">support request</a> for your simulator, while providing a sample transcript of the commands you use to run a test with your simulator, and we will add support for your simulator in the next release!</p>
722
+ <div id="setup.maintenance" class="section">
723
+ <h2 class="title">
724
+ <a href="#a-607713978">3.5</a>
613
725
 
726
+ &nbsp;
614
727
 
615
- </div>
728
+ Maintenance
729
+ </h2>
616
730
 
617
- </div>
731
+ <ul>
732
+ <li>You can upgrade to the latest release of Ruby-VPI by running the <pre>gem update ruby-vpi</pre> command.</li>
733
+ <li>You can uninstall Ruby-VPI by running the <pre>gem uninstall ruby-vpi</pre> command.</li>
734
+ </ul>
618
735
 
619
- <h2 ><a id="setup.recom" href="#a-607912638">4.3</a> &nbsp; Recommendations</h2>
620
736
 
737
+ <p>Learn more about using and manipulating RubyGems in <a href="http://www.rubygems.org">the RubyGems user manual</a>.</p>
621
738
 
622
- <p>The following software may make your interactions with Ruby-VPI more pleasant.</p>
739
+ </div>
740
+
741
+ </div>
742
+
623
743
 
744
+ <hr style="display: none"/>
624
745
 
625
- <h3 ><a id="setup.recom.merger" href="#a-607913678">4.3.1</a> &nbsp; Text merging tool</h3>
746
+ <div id="organization" class="chapter">
747
+ <h1 class="title">
748
+ Chapter <a href="#a-607211338">4</a>
626
749
 
750
+ <br/><br/>
627
751
 
628
- An <em>interactive</em> text merging tool can greatly simplify the process of transferring wanted changes from one file to another. In particular, such tools are especially beneficial when using the <a href="#usage.tools.generate-test">automated test generator</a>. A handful of the currently available open-source text merging tools are listed below.
629
- <ul>
630
- <li><a href="http://kdiff3.sourceforge.net/"><strong>kdiff3</strong></a> is a graphical, three-way merging tool for <span class="caps">KDE</span>.</li>
631
- <li><a href="http://meld.sourceforge.net/"><strong>meld</strong></a> is a graphical, three-way merging tool for <span class="caps">GNOME</span>.</li>
632
- <li><a href="http://tkdiff.sourceforge.net/"><strong>tkdiff</strong></a> is a graphical, two-way merging tool that uses the cross-platform Tk windowing toolkit.</li>
633
- <li><a href="http://furius.ca/xxdiff/"><strong>xxdiff</strong></a> is a graphical, three-way merging tool.</li>
634
- <li><a href="http://elonen.iki.fi/code/imediff/"><strong>imediff2</strong></a> is a textual, fullscreen two-way merging tool. It is very useful when you are working remotely via <span class="caps">SSH</span>.</li>
635
- </ul>
752
+ <big>Organization</big>
753
+ </h1>
636
754
 
755
+ <p>Ruby-VPI is a bridge between <span class="caps">IEEE 1364</span>-2005 Verilog VPI and the Ruby language. It enables Ruby programs to use VPI either (1) in the same, verbose way that C programs do, or (2) in a simpler, higher level way. In addition, it serves as a vehicle for the application of agile software development practices, such as <a href="#glossary.TDD">TDD</a> and <a href="#glossary.BDD">BDD</a> to the realm of hardware development with Verilog.</p>
637
756
 
638
- <h2 ><a id="setup.installation" href="#a-607914868">4.4</a> &nbsp; Installation</h2>
639
757
 
758
+ <p>Ruby-VPI can be used with any Verilog simulator that supports VPI. In particular, it is known to operate with (1) Synopsys VCS and Mentor Modelsim, the two <a href="http://www.eetimes.com/news/design/showArticle.jhtml?articleID=47204415">most prominent Verilog simulators</a> in the Electronic Design Automation (EDA) industry; as well as (2) GPL Cver and Icarus Verilog, the two most prevalent open source Verilog simulators today.</p>
640
759
 
641
- <p>Once you have satisfied the <a href="#setup.reqs">necessary requirements</a>, you can install Ruby-VPI by running the <pre>gem install -y ruby-vpi</pre> command. RubyGems will install Ruby-VPI into the system gem directory, whose path can be determined by running the <pre>gem env gemdir</pre> command. Within this directory, there is a <tt>gems/</tt> subdirectory which contains the Ruby-VPI installation, as illustrated below.</p>
642
760
 
761
+ <p>
762
+ <hr style="display: none"/>
643
763
 
644
- <pre>
645
- $ gem env gemdir
646
- /usr/lib/ruby/gems/1.8
764
+ <div class="formal">
765
+ <div class="figure" id="fig:organization.detail">
766
+
647
767
 
648
- $ ls -d /usr/lib/ruby/gems/1.8/gems/ruby-vpi*
649
- /usr/lib/ruby/gems/1.8/gems/ruby-vpi-7.0.0/
650
- </pre>
768
+ <p class="title"><a href="#a-607731018">Figure 1</a>. &nbsp; Where does Ruby-VPI fit in?</p>
651
769
 
652
- <h3 ><a id="setup.installation.windows" href="#a-607916038">4.4.1</a> &nbsp; Installing on Windows</h3>
770
+ <img src="figures/organization_detailed.png" alt="" />
771
+ </div>
772
+ </div>
773
+
774
+ As <a href="#fig:organization.detail">Figure 1</a> shows, Ruby-VPI is composed of two complementary parts: one interacts with VPI through the C language, while the other interacts with an executable specification written in the Ruby language. The former is complied during installation to produce dynamically loadable C libraries&#8212;-each tailored to accommodate the quirks of its respective Verilog simulator. The latter is not compiled because Ruby programs are interpreted dynamically.</p>
653
775
 
654
776
 
655
- <ul>
656
- <li>Install <a href="http://www.cygwin.com">Cygwin</a>, the Linux-like environment for Windows.</li>
657
- </ul>
777
+ <p>
778
+ <hr style="display: none"/>
658
779
 
780
+ <div id="overview.relay" class="section">
781
+ <h2 class="title">
782
+ <a href="#a-607737308">4.1</a>
659
783
 
660
- <div class="admonition">
784
+ &nbsp;
661
785
 
662
- <div class="note" id="note2">
786
+ Ruby/Verilog interaction
787
+ </h2>
663
788
 
664
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
789
+ <p>In a typical VPI application written in C, the <em>Verilog simulator</em> is in charge. Verilog code temporarily transfers control to C by invoking C functions, which return control to Verilog when they finish.</p>
665
790
 
666
791
 
667
- <p class="title">Note: Undefined symbols in Windows</p>
792
+ <p>In contrast, Ruby-VPI puts the <em>specification</em> in charge. The specification temporarily transfers control to the Verilog simulator by invoking the <code class="code">advance_time</code> method, which returns control to the specification when it finishes. This process is illustrated in <a href="#fig:ruby_relay">Figure 2</a>.</p>
668
793
 
669
794
 
670
- <p>After Ruby-VPI is compiled, it is linked to symbols whose names begin with <tt>_vpi</tt>. In <span class="caps">GNU</span>/Linux and similar operating systems, these symbols are allowed to be undefined. However, one <a href="http://sourceware.org/ml/cygwin/2001-12/msg01293.html">cannot compile a shared object file with references to undefined symbols in Windows</a>.</p>
795
+ <p>Ruby-VPI&#8217;s approach is the same as any software testing framework, where the <em>specification</em> drives the design under test. Whereas, the typical VPI &#38; C approach is literally <em>backwards</em> because the design under test drives the specification.</p>
671
796
 
672
797
 
673
- <p>One solution is to supply the Verilog simulator&#8217;s <span class="caps">VPI</span> object file, which contains definitions of all <span class="caps">VPI</span> symbols, to the linker. The following steps illustrate this process.</p>
798
+ <p>
799
+ <hr style="display: none"/>
674
800
 
801
+ <div class="formal">
802
+ <div class="figure" id="fig:ruby_relay">
803
+
675
804
 
676
- </div>
805
+ <p class="title"><a href="#a-607733828">Figure 2</a>. &nbsp; Interaction between Ruby and Verilog</p>
677
806
 
678
- </div>
807
+ <img src="figures/ruby_relay.png" alt="" />
679
808
 
680
- <ul>
681
- <li>Search for object files whose names end with <tt>.so</tt>, <tt>.o</tt>, or <tt>.dll</tt> in your Verilog simulator&#8217;s installation directory.</li>
682
- </ul>
683
809
 
810
+ <ol>
811
+ <li>The current simulation time is <em>X</em>.</li>
812
+ <li>The specification invokes the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::advance_time</code> method with parameter <em>Y</em>, which specifies the number of simulation time steps to be simulated.</li>
813
+ <li>The Verilog simulator is now in control (temporarily).</li>
814
+ <li>The current simulation time has <em>not</em> changed; it is still <em>X</em>.</li>
815
+ <li>The Verilog simulator simulates <em>Y</em> simulation time steps.</li>
816
+ <li>The current simulation time is now <em>X + Y</em>.</li>
817
+ <li>The Verilog simulator returns control back to the specification.</li>
818
+ </ol>
819
+ </div>
820
+ </div>
821
+
822
+ Another means of transferring control from the specification to the Verilog simulator is the <a href="#vpi.callbacks">VPI callback</a>.</p>
684
823
 
685
- <ul>
686
- <li>Determine which object files, among those found in the previous step, contain symbols whose names begin with &#8220;_vpi&#8221; by running the <pre>for x in *.{o,so,dll}; do nm $x | grep -q '[Tt] _vpi' &amp;&amp; echo $x; done</pre> command in Cygwin.
687
- <ul>
688
- <li>If you are using Mentor Modelsim, the desired object file can be found at a path similar to <tt>C:\Modeltech\win32\libvsim.dll</tt>.</li>
689
- <li>If you are using <span class="caps">GPL</span> Cver, the desired object file can be found at a path similar to <tt>C:\gplcver\objs\v_vpi.o</tt>.</li>
690
- </ul></li>
691
- </ul>
824
+ </div>
825
+
692
826
 
827
+ <hr style="display: none"/>
693
828
 
694
- <ul>
695
- <li>Assign the path of the object file (determined in the previous step) to the <code class="code"><span style="color:#036; font-weight:bold">LDFLAGS</span></code> environment variable. For example, if the object file&#8217;s path is <tt>/foo/bar/vpi.so</tt>, then you would run the <pre>export LDFLAGS=/foo/bar/vpi.so</pre> command in Cygwin.</li>
696
- </ul>
829
+ <div id="organization.tests" class="section">
830
+ <h2 class="title">
831
+ <a href="#a-607073988">4.2</a>
697
832
 
833
+ &nbsp;
698
834
 
699
- <ul>
700
- <li>You may now install Ruby-VPI by running the <pre>gem install ruby-vpi</pre> command in Cygwin.</li>
701
- </ul>
835
+ Tests
836
+ </h2>
702
837
 
838
+ <p>In Ruby-VPI, the process of functional verification is neatly packaged into self-contained, executable tests. As <a href="#fig:organization">Figure 3</a> illustrates, a test is composed of a <strong>bench</strong>, a <strong>design</strong>, and a <strong>specification</strong>.</p>
703
839
 
704
- <h2 ><a id="setup.maintenance" href="#a-607917378">4.5</a> &nbsp; Maintenance</h2>
705
840
 
841
+ <p>
842
+ <hr style="display: none"/>
706
843
 
707
- <ul>
708
- <li>You can uninstall Ruby-VPI by running the <pre>gem uninstall ruby-vpi</pre> command.</li>
709
- <li>You can upgrade to the latest release of Ruby-VPI by running the <pre>gem update ruby-vpi</pre> command.</li>
710
- </ul>
844
+ <div class="formal">
845
+ <div class="figure" id="fig:organization">
846
+
711
847
 
848
+ <p class="title"><a href="#a-607070888">Figure 3</a>. &nbsp; Organization of a test in Ruby-VPI</p>
849
+
850
+ <img src="figures/organization.png" alt="" />
851
+ </div>
852
+ </div>
853
+
854
+ <strong>The bench</strong> is Ruby-VPI. It defines the environment in which functional verification takes place. This is analogous to a workbench in an electronics laboratory that is furnished with tools of measurement and manipulation such as oscilloscopes, voltmeters, soldering irons, and so on which enable engineers to verify electronic components and locate the source of defects within those components.</p>
712
855
 
713
- <p>Learn more about using and manipulating RubyGems in <a href="http://www.rubygems.org">the RubyGems user manual</a>.</p>
714
856
 
857
+ <p><strong>The design</strong> is an instantiated Verilog module. To extend the analogy of the electronics laboratory, it corresponds to the electronic component that is verified by an engineer.</p>
715
858
 
716
- <h1 ><a id="usage" href="#a-607918548">5</a> &nbsp; Usage</h1>
717
859
 
860
+ <p><strong>The specification</strong> is a Ruby program. In the electronics laboratory analogy, it corresponds to the engineer who inspects, manipulates, and verifies the electronic component. In terms of specification-driven functional verification, it corresponds to the executable specification.</p>
718
861
 
719
- <h2 ><a id="usage.vpi" href="#a-607919458">5.1</a> &nbsp; <span class="caps">VPI</span> in Ruby</h2>
862
+ </div>
863
+ </p>
720
864
 
721
865
 
722
- <p>The <em>entire</em> IEEE Std 1364-2005 <span class="caps">VPI</span> interface is available in Ruby, but with a few minor differences.</p>
866
+ <p>
867
+ <hr style="display: none"/>
723
868
 
869
+ <div id="VPI_in_Ruby" class="section">
870
+ <h2 class="title">
871
+ <a href="#a-607153008">4.3</a>
724
872
 
725
- <p class="title">Capitalize those names!</p>
873
+ &nbsp;
726
874
 
875
+ VPI in Ruby
876
+ </h2>
727
877
 
728
- <p>The names of all <span class="caps">VPI</span> types, structures, and constants become <em>capitalized</em> because Ruby requires that the names of constants begin with a capital letter.</p>
878
+
879
+ <hr style="display: none"/>
729
880
 
881
+ <div id="Deviations_from_the_VPI_standard" class="section">
882
+ <h3 class="title">
883
+ <a href="#a-607082938">4.3.1</a>
730
884
 
731
- <p>For example, the <code class="code">s_vpi_value</code> structure becomes the <code class="code"><span style="color:#036; font-weight:bold">S_vpi_value</span></code> class in Ruby. Likewise, the <code class="code">vpiIntVal</code> constant becomes the <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> constant in Ruby.</p>
885
+ &nbsp;
732
886
 
887
+ Deviations from the VPI standard
888
+ </h3>
733
889
 
734
- <div class="admonition">
890
+ <p>Ruby-VPI makes the entire IEEE Std 1364-2005 VPI interface available to Ruby, but with the following minor differences.</p>
735
891
 
736
- <div class="note" id="note3">
737
892
 
738
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
893
+ <p>
894
+ <hr style="display: none"/>
739
895
 
896
+ <div id="Names_are_capitalized" class="section">
897
+ <h4 class="title">
898
+ <a href="#a-607076508">4.3.1.1</a>
740
899
 
741
- <p class="title">Note: No capitalization for <span class="caps">VPI</span> functions</p>
900
+ &nbsp;
742
901
 
902
+ Names are capitalized
903
+ </h4>
743
904
 
744
- <p>Ruby&#8217;s capitalization rule does <em>not</em> apply to <span class="caps">VPI</span> functions&#8212;their names remain unchanged in Ruby.</p>
905
+ <p>The names of all VPI types, structures, and constants become <em>capitalized</em> because Ruby requires that the names of constants begin with a capital letter. However, note that Ruby&#8217;s capitalization rule does <em>not</em> apply to VPI functions.</p>
745
906
 
746
907
 
747
- </div>
908
+ <p>For example, the <code class="code">s_vpi_value</code> structure becomes the <code class="code"><span style="color:#036; font-weight:bold">S_vpi_value</span></code> class in Ruby. Likewise, the <code class="code">vpiIntVal</code> constant becomes the <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> constant in Ruby. However, the <code class="code">vpi_handle</code> function remains as <code class="code">vpi_handle</code> in Ruby.</p>
748
909
 
749
910
  </div>
911
+ </p>
912
+
913
+
914
+ <p>
915
+ <hr style="display: none"/>
916
+
917
+ <div id="a_vprintf__is__printf_" class="section">
918
+ <h4 class="title">
919
+ <a href="#a-607079008">4.3.1.2</a>
920
+
921
+ &nbsp;
750
922
 
751
- <p class="title">Use Ruby&#8217;s <code class="code">printf</code></p>
923
+ <code class="code">vprintf</code> is <code class="code">printf</code>
924
+ </h4>
752
925
 
926
+ The <code class="code">vpi_vprintf</code> and <code class="code">vpi_mcd_vprintf</code> VPI functions are aliased to <code class="code">vpi_printf</code> and <code class="code">vpi_mcd_printf</code> respectively because:
753
927
 
754
- <p>The <span class="caps">VPI</span> functions <code class="code">vpi_vprintf</code> and <code class="code">vpi_mcd_vprintf</code> are not made accessible to Ruby. However, this isn&#8217;t a big problem because you can use Ruby&#8217;s <code class="code">printf</code> method instead.</p>
755
928
 
929
+ <ul>
930
+ <li>Ruby represents <a href="http://www.rubycentral.com/book/tut_methods.html#UA">variable argument lists as arrays</a> instead of defining a special datatype, such as <code class="code">va_list</code>, for them.</li>
931
+ </ul>
756
932
 
757
- <p>The reason for this limitation is that some C compilers have trouble with pointers to the <code class="code">va_list</code> type. For these compilers, the third line of source code shown below causes a &#8220;type mismatch&#8221; error.</p>
933
+
934
+ <ul>
935
+ <li>Some C compilers have trouble with pointers to the <code class="code">va_list</code> type. For these compilers, the third line of source code shown below causes a &#8220;type mismatch&#8221; error.</li>
936
+ </ul>
758
937
 
759
938
 
760
- <pre class="code" lang="c">
939
+ <pre class="code" lang="c">
761
940
  <span style="color:#579">#include</span> <span style="color:#B44; font-weight:bold">&lt;stdarg.h&gt;</span>
762
941
  <span style="color:#339; font-weight:bold">void</span> foo(va_list ap) {
763
942
  va_list *p = &amp;ap;
764
943
  }
765
944
  </pre>
766
945
 
767
- <h3 ><a id="usage.vpi.handles" href="#a-607920448">5.1.1</a> &nbsp; Handles</h3>
946
+ </div>
947
+ </p>
768
948
 
949
+ </div>
950
+
769
951
 
770
- <p>A <em>handle</em> is a reference to an object, such as a module, register, wire, and so on, inside the Verilog simulation. In short, handles allow you to inspect and manipulate the design under test and its components.</p>
952
+ <hr style="display: none"/>
771
953
 
954
+ <div id="vpi.handles" class="section">
955
+ <h3 class="title">
956
+ <a href="#a-607114548">4.3.2</a>
772
957
 
773
- <div class="admonition">
958
+ &nbsp;
774
959
 
775
- <div class="note" id="note4">
960
+ Handles
961
+ </h3>
776
962
 
777
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
963
+ <p>A <strong>handle</strong> is a reference to an object (such as a module, register, wire, and so on) inside the Verilog simulation. Handles allows you to inspect and manipulate the design under test and its internal components. They are instances of the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::<span style="color:#036; font-weight:bold">Handle</span></code> class (see <a href="../ref/ruby/classes/Vpi/Handle.html">reference documentation</a> for details) in Ruby-VPI.</p>
778
964
 
779
965
 
780
- <p class="title">Note: <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::<span style="color:#036; font-weight:bold">Handle</span></code> heritage</p>
966
+ <p>Handles have various <strong>properties</strong>, listed in the second column of <a href="#tbl:accessors">Table 1</a>, which provide different kinds of information about the underlying Verilog objects they represent. These properties are accessed through the VPI functions listed in the last column of <a href="#tbl:accessors">Table 1</a>.</p>
781
967
 
782
968
 
783
- <p>Handles are instances of the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::<span style="color:#036; font-weight:bold">Handle</span></code> class (see <a href="../ref/ruby/classes/Vpi/Handle.html">reference documentation</a> for details) in Ruby-VPI.</p>
969
+ <p>Handles are typically obtained through the <code class="code">vpi_handle_by_name</code> and <code class="code">vpi_handle</code> functions. These functions are hierarchical in nature, as they allow you to obtain new handles that are related to existing ones. For example, to obtain a handle to a register contained within a module, one would typically write: <code class="code">your_reg = vpi_handle( <span style="color:#036; font-weight:bold">VpiReg</span>, your_handle )</code></p>
784
970
 
785
971
 
972
+ <p>
973
+ <div id="Shortcuts_for_productivity" class="paragraph">
974
+ <p class="title">Shortcuts for productivity</p>
975
+ Given a handle, Ruby-VPI allows you to access (1) its relatives and (2) its properties simply by invoking methods on the handle. If a handle&#8217;s relative happens to have the same name as one its properties, then the relative is given priority because a handle&#8217;s properties can always be accessed explicitly through the <code class="code">handle.get_value</code> and <code class="code">handle.put_value</code> methods.
786
976
  </div>
977
+ </p>
787
978
 
788
- </div>
789
979
 
790
- <p>Handles have various <em>properties</em>, which provide different kinds of information (see the &#8220;Kind of value accessed&#8221; column in <a href="#tbl..accessors">the table named &ldquo;Possible accessors and their implications&rdquo;</a>) about the underlying Verilog object represented by a handle. These properties are accessed through various functions, which are listed in the &#8220;VPI functions used to access the value&#8221; column in <a href="#tbl..accessors">the table named &ldquo;Possible accessors and their implications&rdquo;</a>.</p>
980
+ <p>
981
+ <hr style="display: none"/>
791
982
 
983
+ <div id="Accessing_a_handle_s_relatives" class="section">
984
+ <h4 class="title">
985
+ <a href="#a-607088158">4.3.2.2</a>
792
986
 
793
- <p>Handles are typically obtained through the <code class="code">vpi_handle_by_name</code> and <code class="code">vpi_handle</code> functions. These functions are hierarchical in nature, because they allow you to obtain new handles that are related to existing handles. For example, to obtain a handle to a register inside a module, you would typically write: <code class="code">some_reg = vpi_handle(<span style="color:#036; font-weight:bold">VpiReg</span>, some_handle)</code>.</p>
987
+ &nbsp;
794
988
 
989
+ Accessing a handle&#8217;s relatives
990
+ </h4>
795
991
 
796
- <p class="title">Shortcuts for productivity</p>
992
+ <p>Imagine that the design under test, say <em>foo</em>, instantiated a Verilog module named <em>bar</em>, which in turn contained a register named <em>baz</em>. To access baz from Ruby, one could employ VPI idioms by writing:</p>
797
993
 
798
994
 
799
- <p>Given a handle, Ruby-VPI allows you to access (1) its relatives and (2) its properties by simply invoking its methods.</p>
995
+ <pre class="code">
996
+ foo = vpi_handle_by_name( <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">foo</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span> )
997
+ bar = vpi_handle_by_name( <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">bar</span><span style="color:#710">&quot;</span></span>, foo )
998
+ baz = vpi_handle_by_name( <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">baz</span><span style="color:#710">&quot;</span></span>, bar )
999
+ </pre>
1000
+
1001
+
1002
+ <p>or by writing:</p>
1003
+
800
1004
 
1005
+ <code class="code">baz = vpi_handle_by_name( <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">foo.bar.bar</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span> )</code>
801
1006
 
802
- <p>If a handle&#8217;s relative happens to have the same name as one of the handle&#8217;s properties, then the relative is given preference. However, if you <em>really</em> need to access a handle&#8217;s property in such a situation, then you can use the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::<span style="color:#036; font-weight:bold">Handle</span>.get_value</code> and <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::<span style="color:#036; font-weight:bold">Handle</span>.put_value</code> methods.</p>
803
1007
 
1008
+ <p>These idioms seem excessively verbose in a higher level language such as Ruby, so Ruby-VPI allows you to access a handle&#8217;s relative by simply invoking the relative&#8217;s name as a method on the handle:</p>
1009
+
1010
+
1011
+ <code class="code">foo.bar.baz</code>
1012
+
1013
+ </div>
1014
+ </p>
804
1015
 
805
- <h4><a id="Accessing_a_handle__8217_s_relatives" href="#a-607921548">5.1.1.1</a> &nbsp; Accessing a handle&#8217;s relatives</h4>
806
1016
 
1017
+ <p>
1018
+ <hr style="display: none"/>
807
1019
 
808
- <p>To access a handle&#8217;s relative (a handle related to it), simply invoke the relative&#8217;s name as a method on the handle.</p>
1020
+ <div id="Accessing_a_handle_s_properties" class="section">
1021
+ <h4 class="title">
1022
+ <a href="#a-607091098">4.3.2.3</a>
809
1023
 
1024
+ &nbsp;
810
1025
 
811
- <p>For example, to access the <code class="code">reset</code> signal of the <code class="code">counter</code> module shown in <a href="#fig..counter.v_decl">the example named &ldquo;Declaration of a simple up-counter with synchronous reset&rdquo;</a>, you would write the following:</p>
1026
+ Accessing a handle&#8217;s properties
1027
+ </h4>
812
1028
 
1029
+ <p>Imagine that the design under test, say <em>foo</em>, contained a register named <em>bar</em>. To access the integer value of <em>bar</em> in Ruby-VPI, one could employ VPI idioms by writing:</p>
813
1030
 
814
- <pre class="code">
815
- counter_module = vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">counter</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span>)
816
1031
 
817
- reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!</span>
1032
+ <pre class="code">
1033
+ wrapper = <span style="color:#036; font-weight:bold">S_vpi_value</span>.new
1034
+ wrapper.format = <span style="color:#036; font-weight:bold">VpiIntVal</span>
1035
+ vpi_get_value( foo.bar, wrapper )
1036
+ result = wrapper.value.integer
818
1037
  </pre>
819
1038
 
820
- <p>In this code, the shortcut is that you simply wrote <code class="code">counter_module.reset</code> instead of having to write <code class="code">vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">reset</span><span style="color:#710">&quot;</span></span>, counter_module)</code>.</p>
821
1039
 
1040
+ <p>or, if <em>bar</em> is capable of storing more than 32 bits, one would convert a string representation of bar&#8217;s integer value into a limitless Ruby integer by writing:</p>
822
1041
 
823
- <h4><a id="Accessing_a_handle__8217_s_properties" href="#a-607922938">5.1.1.2</a> &nbsp; Accessing a handle&#8217;s properties</h4>
1042
+
1043
+ <pre class="code">
1044
+ wrapper = <span style="color:#036; font-weight:bold">S_vpi_value</span>.new
1045
+ wrapper.format = <span style="color:#036; font-weight:bold">VpiHexStrVal</span>
1046
+ vpi_get_value( foo.bar, wrapper )
1047
+ result = wrapper.value.str.to_i( <span style="color:#00D; font-weight:bold">16</span> )
1048
+ </pre>
824
1049
 
825
1050
 
826
- <p>To access a handle&#8217;s properties, invoke the property name, using the following format, as a method on the handle. <a href="#ex..properties">the example named &ldquo;Examples of accessing a handle's properties&rdquo;</a> shows how this naming format is used.</p>
1051
+ <p>These idioms seem excessively verbose in a higher level language such as Ruby, so Ruby-VPI allows you to access a handle&#8217;s properties by simply invoking property names, using the special naming format shown in <a href="#fig:method_naming_format">Figure 4</a>, as methods on the handle:</p>
827
1052
 
828
1053
 
829
- <div class="formal">
1054
+ <code class="code">result = foo.bar.intVal</code>
1055
+
1056
+ </div>
1057
+
830
1058
 
831
- <div class="figure" id="figure4">
1059
+ <hr style="display: none"/>
832
1060
 
833
- <p class="title">Figure 4. Method naming format for accessing a handle&#8217;s properties</p>
1061
+ <div class="formal">
1062
+ <div class="figure" id="fig:method_naming_format">
1063
+
834
1064
 
1065
+ <p class="title"><a href="#a-607093898">Figure 4</a>. &nbsp; Method naming format for accessing a handle&#8217;s properties</p>
835
1066
 
836
- <table>
1067
+ <table>
837
1068
  <tr>
838
1069
  <th>Operation </th>
839
1070
  <th>_ </th>
@@ -853,93 +1084,94 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
853
1084
 
854
1085
 
855
1086
  <ul>
856
- <li><strong>Operation</strong> suggests a method that should be invoked in the context of the Property parameter. All <a href="http://www.ruby-doc.org/core/classes/Enumerable.html">methods in the Enumerable module</a> are valid <em>operations</em>.</li>
1087
+ <li><strong>Operation</strong> suggests a method that should be invoked in the context of the <strong>Property</strong> parameter. All methods in <a href="http://www.ruby-doc.org/core/classes/Enumerable.html">Ruby&#8217;s <code class="code"><span style="color:#036; font-weight:bold">Enumerable</span></code> module</a> are valid operations.</li>
857
1088
  </ul>
858
1089
 
859
1090
 
860
1091
  <ul>
861
- <li><strong>Property</strong> suggests a <span class="caps">VPI</span> property that should be accessed. The &#8220;vpi&#8221; prefix, which is common to all <span class="caps">VPI</span> properties, can be omitted if you wish. For example, the <span class="caps">VPI</span> property &#8220;vpiFullName&#8221; is considered equivalent to &#8220;fullName&#8221; and &#8220;FullName&#8221;, but not equivalent &#8220;full_name&#8221;.</li>
1092
+ <li><strong>Property</strong> suggests a VPI property that should be accessed. The &#8220;vpi&#8221; prefix, which is common to all VPI properties, can be omitted if you wish. For example, the VPI property &#8220;vpiFullName&#8221; is considered equivalent to &#8220;fullName&#8221; and &#8220;FullName&#8221;, but not equivalent to &#8220;full_name&#8221;.</li>
862
1093
  </ul>
863
1094
 
864
1095
 
865
1096
  <ul>
866
- <li><strong>Accessor</strong> suggests a <span class="caps">VPI</span> function that should be used in order to access the <span class="caps">VPI</span> property. When this parameter is not specified, Ruby-VPI will attempt to <em>guess</em> the value of this parameter.
1097
+ <li><strong>Accessor</strong> suggests a VPI function that should be used in order to access the VPI property. When this parameter is not specified, Ruby-VPI will attempt to <em>guess</em> the value of this parameter.
867
1098
 
868
- <a href="#tbl..accessors">the table named &ldquo;Possible accessors and their implications&rdquo;</a> shows a list of valid accessors and how they affect the access to a property.</li>
1099
+ <p><a href="#tbl:accessors">Table 1</a> shows a list of valid accessors and how they influence the means by which a property is accessed.</p></li>
869
1100
  </ul>
870
1101
 
871
1102
 
872
1103
  <ul>
873
- <li><strong>Addendum</strong> suggests that the specified <span class="caps">VPI</span> property should be queried as a boolean value when it is a question mark <code class="code">?</code>. This suggestion is the same as specifying <code class="code">b</code> for the Accessor parameter.
1104
+ <li>When <strong>Addendum</strong> is an equal sign (=), it suggests that the specified VPI property should be written to.
874
1105
 
875
- <p>Also, when this parameter is an equal sign <code class="code">=</code>, it suggests that the specified <span class="caps">VPI</span> property should be written to.</p></li>
1106
+ <p>When it is a question mark (?), it suggests that the specified VPI property should be accessed as a boolean value. This suggestion is the same as specifying &#8220;b&#8221; as the <strong>Accessor</strong>.</p></li>
876
1107
  </ul>
1108
+ </div>
1109
+ </div>
1110
+
877
1111
 
1112
+ <hr style="display: none"/>
878
1113
 
879
- </div>
880
-
881
- </div>
882
-
883
- <div class="formal">
884
-
885
- <div class="table" id="tbl..accessors">
886
-
887
- <p class="title">Table 1. Possible accessors and their implications</p>
1114
+ <div class="formal">
1115
+ <div class="table" id="tbl:accessors">
1116
+
888
1117
 
1118
+ <p class="title"><a href="#a-607096328">Table 1</a>. &nbsp; Possible accessors and their implications</p>
889
1119
 
890
- <table>
1120
+ <table>
891
1121
  <tr>
892
1122
  <th>Accessor </th>
893
1123
  <th>Kind of value accessed </th>
894
- <th><span class="caps">VPI</span> functions used to access the value </th>
1124
+ <th>VPI functions used to access the value </th>
895
1125
  </tr>
896
1126
  <tr>
897
1127
  <td> d </td>
898
- <td> delay </td>
1128
+ <td> delay </td>
899
1129
  <td> <code class="code">vpi_get_delays</code>, <code class="code">vpi_put_delays</code> </td>
900
1130
  </tr>
901
1131
  <tr>
902
1132
  <td> l </td>
903
- <td> logic </td>
904
- <td> <code class="code">vpi_get_value</code>, <code class="code">vpi_put_value</code> </td>
1133
+ <td> logic </td>
1134
+ <td> <code class="code">vpi_get_value</code>, <code class="code">vpi_put_value</code> </td>
905
1135
  </tr>
906
1136
  <tr>
907
1137
  <td> i </td>
908
1138
  <td> integer </td>
909
- <td> <code class="code">vpi_get</code> </td>
1139
+ <td> <code class="code">vpi_get</code> </td>
910
1140
  </tr>
911
1141
  <tr>
912
1142
  <td> b </td>
913
1143
  <td> boolean </td>
914
- <td> <code class="code">vpi_get</code> </td>
1144
+ <td> <code class="code">vpi_get</code> </td>
915
1145
  </tr>
916
1146
  <tr>
917
1147
  <td> s </td>
918
- <td> string </td>
919
- <td> <code class="code">vpi_get_str</code> </td>
1148
+ <td> string </td>
1149
+ <td> <code class="code">vpi_get_str</code> </td>
920
1150
  </tr>
921
1151
  <tr>
922
1152
  <td> h </td>
923
- <td> handle </td>
924
- <td> <code class="code">vpi_handle</code> </td>
1153
+ <td> handle </td>
1154
+ <td> <code class="code">vpi_handle</code> </td>
1155
+ </tr>
1156
+ <tr>
1157
+ <td> a </td>
1158
+ <td> array </td>
1159
+ <td> <code class="code">vpi_iterate</code> </td>
925
1160
  </tr>
926
1161
  </table>
1162
+ </div>
1163
+ </div>
1164
+
927
1165
 
1166
+ <hr style="display: none"/>
928
1167
 
1168
+ <div class="formal">
1169
+ <div class="table" id="ex:properties">
1170
+
929
1171
 
1172
+ <p class="title"><a href="#a-607099288">Table 2</a>. &nbsp; Examples of accessing a handle&#8217;s properties</p>
930
1173
 
931
- </div>
932
-
933
- </div>
934
-
935
- <div class="formal">
936
-
937
- <div class="example" id="ex..properties">
938
-
939
- <p class="title">Example 1. Examples of accessing a handle&#8217;s properties</p>
940
-
941
-
942
- <table>
1174
+ <table>
943
1175
  <tr>
944
1176
  <th rowspan="2">Ruby expression </th>
945
1177
  <th colspan="6">Method naming format </th>
@@ -961,7 +1193,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
961
1193
  <td> &nbsp; </td>
962
1194
  <td> &nbsp; </td>
963
1195
  <td> &nbsp; </td>
964
- <td rowspan="4">These expressions access the <strong>logic value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. </td>
1196
+ <td rowspan="4">Obtain the <em>logic value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. </td>
965
1197
  </tr>
966
1198
  <tr>
967
1199
  <td> <code class="code">handle.vpiIntVal_l</code> </td>
@@ -998,7 +1230,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
998
1230
  <td> &nbsp; </td>
999
1231
  <td> &nbsp; </td>
1000
1232
  <td> = </td>
1001
- <td rowspan="4">These expressions assign the number 15 to the <strong>logic value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. </td>
1233
+ <td rowspan="4">Assign the integer 15 to the <em>logic value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. </td>
1002
1234
  </tr>
1003
1235
  <tr>
1004
1236
  <td> <code class="code">handle.vpiIntVal_l = <span style="color:#00D; font-weight:bold">15</span></code> </td>
@@ -1035,7 +1267,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1035
1267
  <td> &nbsp; </td>
1036
1268
  <td> &nbsp; </td>
1037
1269
  <td> &nbsp; </td>
1038
- <td rowspan="4">These expressions access the <strong>integer value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiType</span></code> property. </td>
1270
+ <td rowspan="4">Obtain the <em>integer value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiType</span></code> property. </td>
1039
1271
  </tr>
1040
1272
  <tr>
1041
1273
  <td> <code class="code">handle.vpiType_i</code> </td>
@@ -1072,7 +1304,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1072
1304
  <td> &nbsp; </td>
1073
1305
  <td> &nbsp; </td>
1074
1306
  <td> &nbsp; </td>
1075
- <td rowspan="6">These expressions access the <strong>boolean value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiProtected</span></code> property. </td>
1307
+ <td rowspan="6">Obtain the <em>boolean value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiProtected</span></code> property. </td>
1076
1308
  </tr>
1077
1309
  <tr>
1078
1310
  <td> <code class="code">handle.vpiProtected_b</code> </td>
@@ -1127,7 +1359,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1127
1359
  <td> &nbsp; </td>
1128
1360
  <td> &nbsp; </td>
1129
1361
  <td> &nbsp; </td>
1130
- <td rowspan="4">These expressions access the <strong>string value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiFullName</span></code> property. </td>
1362
+ <td rowspan="4">Obtain the <em>string value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiFullName</span></code> property. </td>
1131
1363
  </tr>
1132
1364
  <tr>
1133
1365
  <td> <code class="code">handle.vpiFullName_s</code> </td>
@@ -1164,7 +1396,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1164
1396
  <td> &nbsp; </td>
1165
1397
  <td> &nbsp; </td>
1166
1398
  <td> &nbsp; </td>
1167
- <td rowspan="4">These expressions access the <strong>handle value</strong> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiParent</span></code> property. </td>
1399
+ <td rowspan="4">Obtain the <em>handle value</em> of the handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiParent</span></code> property. </td>
1168
1400
  </tr>
1169
1401
  <tr>
1170
1402
  <td> <code class="code">handle.vpiParent_h</code> </td>
@@ -1201,7 +1433,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1201
1433
  <td> &nbsp; </td>
1202
1434
  <td> &nbsp; </td>
1203
1435
  <td> &nbsp; </td>
1204
- <td rowspan="2">These expressions print the full name of each <code class="code"><span style="color:#036; font-weight:bold">VpiNet</span></code> object associated with the handle. </td>
1436
+ <td rowspan="2">Use the <code class="code">each</code> operation to print the full name of each <code class="code"><span style="color:#036; font-weight:bold">VpiNet</span></code> object associated with the handle. </td>
1205
1437
  </tr>
1206
1438
  <tr>
1207
1439
  <td> <code class="code">handle.each_net {|net| puts net.fullName}</code> </td>
@@ -1220,7 +1452,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1220
1452
  <td> &nbsp; </td>
1221
1453
  <td> &nbsp; </td>
1222
1454
  <td> &nbsp; </td>
1223
- <td rowspan="2">These expressions check if all registers associated with the handle are capable of storing only one bit. </td>
1455
+ <td rowspan="2">Use the <code class="code">all?</code> operation to check whether all <code class="code"><span style="color:#036; font-weight:bold">VpiReg</span></code> objects associated with the handle are capable of storing only one bit of information. </td>
1224
1456
  </tr>
1225
1457
  <tr>
1226
1458
  <td> <code class="code">handle.all_reg? {|reg| reg.size == <span style="color:#00D; font-weight:bold">1</span>}</code> </td>
@@ -1239,7 +1471,7 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1239
1471
  <td> &nbsp; </td>
1240
1472
  <td> &nbsp; </td>
1241
1473
  <td> &nbsp; </td>
1242
- <td rowspan="2">These expressions return a list of nets whose <strong>logic value</strong> is unknown or &#8220;don&#8217;t care&#8221; (x).</td>
1474
+ <td rowspan="2">Use the <code class="code">select</code> operation to obtain a list of <code class="code"><span style="color:#036; font-weight:bold">VpiNet</span></code> objects whose <em>logic value</em> is unknown (x).</td>
1243
1475
  </tr>
1244
1476
  <tr>
1245
1477
  <td> <code class="code">handle.select_net {|net| net.x?}</code> </td>
@@ -1251,168 +1483,124 @@ reset_signal = counter_module.reset <span style="color:#888"># &lt;== shortcut!<
1251
1483
  <td> &nbsp; </td>
1252
1484
  </tr>
1253
1485
  </table>
1486
+ </div>
1487
+ </div>
1488
+ </p>
1254
1489
 
1490
+ </div>
1255
1491
 
1256
1492
 
1493
+ <hr style="display: none"/>
1257
1494
 
1258
- </div>
1495
+ <div id="vpi.callbacks" class="section">
1496
+ <h3 class="title">
1497
+ <a href="#a-607126458">4.3.3</a>
1259
1498
 
1260
- </div>
1499
+ &nbsp;
1261
1500
 
1262
- <h3 ><a id="usage.vpi.callbacks" href="#a-607924498">5.1.2</a> &nbsp; Callbacks</h3>
1501
+ Callbacks
1502
+ </h3>
1263
1503
 
1504
+ <p>A <em>callback</em> is a mechanism that makes the Verilog simuluator execute a block of code, which is known as a &#8220;callback handler&#8221;, when some prescribed event occurs in the simulation.</p>
1264
1505
 
1265
- <p>A <em>callback</em> is a mechanism that makes the Verilog simuluator execute a block of code, which is known as a &#8220;callback handler&#8221;, when some prescribed event occurs in the simulation. They are set up using the <code class="code">vpi_register_cb</code> function and torn down using the <code class="code">vpi_remove_cb</code> function.</p>
1266
1506
 
1507
+ <p>Callbacks are added using the <code class="code">vpi_register_cb</code> function and removed using the <code class="code">vpi_remove_cb</code> function. However, instead of storing the address of a C function in the <code class="code">cb_rtn</code> field of the <code class="code">s_cb_data</code> structure (as you would do in C) you pass a block of code to the <code class="code">vpi_register_cb</code> method in Ruby. This block will be executed whenever the callback occurs.</p>
1267
1508
 
1268
- <div class="formal">
1269
1509
 
1270
- <div class="example" id="ex..callback">
1510
+ <p>
1511
+ <hr style="display: none"/>
1271
1512
 
1272
- <p class="title">Example 2. Using a callback for value change notification</p>
1513
+ <div class="formal">
1514
+ <div class="example" id="ex:callback">
1515
+
1273
1516
 
1517
+ <p class="title"><a href="#a-607121788">Example 1</a>. &nbsp; Using a callback for value change notification</p>
1274
1518
 
1275
- <p>This example shows how to use a callback for notification of changes in a handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. When you no longer need this callback, you can tear it down using <code class="code">vpi_remove_cb(cb_handle)</code>.</p>
1519
+ <p>This example shows how to use a callback for notification of changes in a handle&#8217;s <code class="code"><span style="color:#036; font-weight:bold">VpiIntVal</span></code> property. When you no longer need this callback, you can tear it down using <code class="code">vpi_remove_cb(cb_handle)</code>.</p>
1276
1520
 
1277
1521
 
1278
- <p>In this example, the handle being monitored is the <code class="code"><span style="color:#036; font-weight:bold">Counter</span>.count</code> signal from <a href="#fig..counter.v_decl">the example named &ldquo;Declaration of a simple up-counter with synchronous reset&rdquo;</a>.</p>
1522
+ <p>In this example, the handle being monitored is the <code class="code"><span style="color:#036; font-weight:bold">Counter</span>.count</code> signal from <a href="#fig:counter.v_decl">Example 3</a>.</p>
1279
1523
 
1280
1524
 
1281
- <pre class="code">
1282
- cbTime = <span style="color:#036; font-weight:bold">S_vpi_time</span>.new
1283
- cbTime.type = <span style="color:#036; font-weight:bold">VpiSimTime</span>
1284
- cbTime.low = <span style="color:#00D; font-weight:bold">0</span>
1285
- cbTime.high = <span style="color:#00D; font-weight:bold">0</span>
1525
+ <pre class="code">
1526
+ cbTime = <span style="color:#036; font-weight:bold">S_vpi_time</span>.new
1527
+ cbTime.type = <span style="color:#036; font-weight:bold">VpiSimTime</span>
1528
+ cbTime.low = <span style="color:#00D; font-weight:bold">0</span>
1529
+ cbTime.high = <span style="color:#00D; font-weight:bold">0</span>
1286
1530
 
1287
- cbValue = <span style="color:#036; font-weight:bold">S_vpi_value</span>.new
1288
- cbValue.format = <span style="color:#036; font-weight:bold">VpiIntVal</span>
1531
+ cbValue = <span style="color:#036; font-weight:bold">S_vpi_value</span>.new
1532
+ cbValue.format = <span style="color:#036; font-weight:bold">VpiIntVal</span>
1289
1533
 
1290
- cbData = <span style="color:#036; font-weight:bold">S_cb_data</span>.new
1291
- cbData.reason = <span style="color:#036; font-weight:bold">CbValueChange</span>
1292
- cbData.obj = <span style="color:#036; font-weight:bold">Counter</span>.count
1293
- cbData.time = cbTime
1294
- cbData.value = cbValue
1295
- cbData.index = <span style="color:#00D; font-weight:bold">0</span>
1534
+ cbData = <span style="color:#036; font-weight:bold">S_cb_data</span>.new
1535
+ cbData.reason = <span style="color:#036; font-weight:bold">CbValueChange</span>
1536
+ cbData.obj = <span style="color:#036; font-weight:bold">Counter</span>.count
1537
+ cbData.time = cbTime
1538
+ cbData.value = cbValue
1539
+ cbData.index = <span style="color:#00D; font-weight:bold">0</span>
1296
1540
 
1297
1541
  cbHandle = vpi_register_cb(cbData) <span style="color:#080; font-weight:bold">do</span> |data|
1298
-
1299
- time = (data.time.high &lt;&lt; <span style="color:#00D; font-weight:bold">32</span>) | data.time.low
1300
- count = data.value.value.integer
1301
-
1302
- puts <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">hello from callback! time=</span><span style="background: #eee"><span style="font-weight: bold; color: #888">#{</span>time<span style="font-weight: bold; color: #888">}</span></span><span style="color:#D20"> count=</span><span style="background: #eee"><span style="font-weight: bold; color: #888">#{</span>count<span style="font-weight: bold; color: #888">}</span></span><span style="color:#710">&quot;</span></span>
1303
-
1542
+ time = (data.time.high &lt;&lt; <span style="color:#00D; font-weight:bold">32</span>) | data.time.low
1543
+ count = data.value.value.integer
1544
+ puts <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">hello from callback! time=</span><span style="background: #eee"><span style="font-weight: bold; color: #888">#{</span>time<span style="font-weight: bold; color: #888">}</span></span><span style="color:#D20"> count=</span><span style="background: #eee"><span style="font-weight: bold; color: #888">#{</span>count<span style="font-weight: bold; color: #888">}</span></span><span style="color:#710">&quot;</span></span>
1304
1545
  <span style="color:#080; font-weight:bold">end</span>
1305
1546
  </pre>
1306
1547
 
1307
- <p>Shown below is the result of appending this code to the <tt>counter_rspec_spec.rb</tt> file (provided in <a href="#usage.examples">the section named &ldquo;Sample tests&rdquo;</a> and discussed in <a href="#usage.tutorial.specification">the section named &ldquo;Specify your expectations&rdquo;</a>) and running the <a href="#usage.tutorial">counter_rspec test</a>.</p>
1308
1548
 
1549
+ <p>Append this code to the <tt>RSpec/counter_spec.rb</tt> file (provided in <a href="#usage.examples">Section 5.5</a> and discussed in <a href="#usage.tutorial.specification">Section 5.6.3</a>) and run the <a href="#usage.tutorial">counter_RSpec test</a></p>
1550
+ </div>
1551
+ </div>
1552
+ </p>
1309
1553
 
1310
- <pre>
1311
- $ rake -f counter_rspec_runner.rake cver
1312
-
1313
- (in /home/sun/src/ruby-vpi/samp/counter)
1314
- cver +loadvpi=/home/sun/src/ruby-vpi/lib/ruby-vpi/../../obj/ruby-vpi.cver.so:vlog_startup_routines_bootstrap counter.v counter_rspec_bench.v
1315
- GPLCVER_2.11a of 07/05/05 (Linux-elf).
1316
- Copyright (c) 1991-2005 Pragmatic C Software Corp.
1317
- All Rights reserved. Licensed under the GNU General Public License (GPL).
1318
- See the 'COPYING' file for details. NO WARRANTY provided.
1319
- Today is Sat Dec 30 09:24:09 2006.
1320
- Compiling source file &quot;counter.v&quot;
1321
- Compiling source file &quot;counter_rspec_bench.v&quot;
1322
- Highest level modules:
1323
- counter_rspec_bench
1324
-
1325
- A resetted counter's value
1326
- hello from callback! time=1 count=0
1327
- - should be zero
1328
- hello from callback! time=5 count=1
1329
- hello from callback! time=7 count=2
1330
- hello from callback! time=9 count=3
1331
- hello from callback! time=11 count=4
1332
- hello from callback! time=13 count=5
1333
- hello from callback! time=15 count=6
1334
- hello from callback! time=17 count=7
1335
- hello from callback! time=19 count=8
1336
- hello from callback! time=21 count=9
1337
- hello from callback! time=23 count=10
1338
- hello from callback! time=25 count=11
1339
- hello from callback! time=27 count=12
1340
- hello from callback! time=29 count=13
1341
- hello from callback! time=31 count=14
1342
- hello from callback! time=33 count=15
1343
- hello from callback! time=35 count=16
1344
- hello from callback! time=37 count=17
1345
- hello from callback! time=39 count=18
1346
- hello from callback! time=41 count=19
1347
- hello from callback! time=43 count=20
1348
- hello from callback! time=45 count=21
1349
- hello from callback! time=47 count=22
1350
- hello from callback! time=49 count=23
1351
- hello from callback! time=51 count=24
1352
- hello from callback! time=53 count=25
1353
- hello from callback! time=55 count=26
1354
- hello from callback! time=57 count=27
1355
- hello from callback! time=59 count=28
1356
- hello from callback! time=61 count=29
1357
- hello from callback! time=63 count=30
1358
- hello from callback! time=65 count=31
1359
- hello from callback! time=67 count=0
1360
- - should increment by one count upon each rising clock edge
1361
-
1362
- A counter with the maximum value
1363
- hello from callback! time=71 count=1
1364
- hello from callback! time=73 count=2
1365
- hello from callback! time=75 count=3
1366
- hello from callback! time=77 count=4
1367
- hello from callback! time=79 count=5
1368
- hello from callback! time=81 count=6
1369
- hello from callback! time=83 count=7
1370
- hello from callback! time=85 count=8
1371
- hello from callback! time=87 count=9
1372
- hello from callback! time=89 count=10
1373
- hello from callback! time=91 count=11
1374
- hello from callback! time=93 count=12
1375
- hello from callback! time=95 count=13
1376
- hello from callback! time=97 count=14
1377
- hello from callback! time=99 count=15
1378
- hello from callback! time=101 count=16
1379
- hello from callback! time=103 count=17
1380
- hello from callback! time=105 count=18
1381
- hello from callback! time=107 count=19
1382
- hello from callback! time=109 count=20
1383
- hello from callback! time=111 count=21
1384
- hello from callback! time=113 count=22
1385
- hello from callback! time=115 count=23
1386
- hello from callback! time=117 count=24
1387
- hello from callback! time=119 count=25
1388
- hello from callback! time=121 count=26
1389
- hello from callback! time=123 count=27
1390
- hello from callback! time=125 count=28
1391
- hello from callback! time=127 count=29
1392
- hello from callback! time=129 count=30
1393
- hello from callback! time=131 count=31
1394
- hello from callback! time=133 count=0
1395
- - should overflow upon increment
1396
-
1397
- Finished in 0.042328 seconds
1398
-
1399
- 3 specifications, 0 failures
1400
- </pre>
1554
+ </div>
1401
1555
 
1402
- </div>
1403
1556
 
1404
- </div>
1557
+ </div>
1558
+ </p>
1559
+ </div>
1560
+
1561
+
1562
+ <hr style="display: none"/>
1563
+
1564
+ <div id="usage" class="chapter">
1565
+ <h1 class="title">
1566
+ Chapter <a href="#a-607321458">5</a>
1567
+
1568
+ <br/><br/>
1569
+
1570
+ <big>Usage</big>
1571
+ </h1>
1572
+
1573
+
1574
+ <hr style="display: none"/>
1575
+
1576
+ <div id="usage.prototyping" class="section">
1577
+ <h2 class="title">
1578
+ <a href="#a-607223668">5.1</a>
1579
+
1580
+ &nbsp;
1405
1581
 
1406
- <h2 ><a id="usage.prototyping" href="#a-607925708">5.2</a> &nbsp; Prototyping</h2>
1582
+ Prototyping
1583
+ </h2>
1407
1584
 
1585
+ <p>Ruby-VPI enables you to rapidly prototype your designs in Ruby without having to do full-scale implementations in Verilog. This lets you explore and evaluate different design choices quickly.</p>
1408
1586
 
1409
- <p>Ruby-VPI enables you to rapidly prototype your designs in Ruby without having to do full-scale implementations in Verilog. This lets you explore and evaluate different design choices quickly.</p>
1410
1587
 
1588
+ <p>The prototyping process is completely transparent: there is absolutely no difference, in the eyes of your executable specification, between a real Verilog design or its Ruby prototype.</p>
1411
1589
 
1412
- To create a prototype,
1590
+
1591
+ <p>In addition, the prototyping process is completely standard-based: Ruby prototypes emulate the behavior of real Verilog designs using <em>nothing more</em> than the VPI itself.</p>
1592
+
1593
+
1594
+ <p>For example, compare the Verilog design shown in <a href="#fig:counter.v_impl">Example 11</a> with its Ruby prototype shown in figure <a href="#fig:counter_proto.rb">Example 8</a>. The prototype uses only VPI to (1) detect changes in its inputs and (2) manipulate its outputs accordingly. In addition, notice how well the prototype&#8217;s syntax reflects the intended behavior of the Verilog design. This similarity facilitates rapid translation of a prototype from Ruby into Verilog later in the design process.</p>
1595
+
1596
+
1597
+ <p>
1598
+ <div id="Getting_started" class="paragraph">
1599
+ <p class="title">Getting started</p>
1600
+ To create a prototype,
1413
1601
  <ol>
1414
- <li><a href="#usage.tutorial.declare-design">Determine the <strong>interface</strong></a> (Verilog module declaration) of your design.</li>
1415
- <li><a href="#usage.tutorial.generate-test">Generate a test</a> for that interface.</li>
1602
+ <li>Start with a <a href="#usage.tutorial.declare-design">Verilog module declaration</a> for your design.</li>
1603
+ <li><a href="#usage.tutorial.generate-test">Generate a test</a> using that module declaration.</li>
1416
1604
  <li><a href="#usage.tutorial.implement-proto">Implement the prototype</a> in the generated <tt>proto.rb</tt> file.</li>
1417
1605
  <li><a href="#usage.tutorial.test-proto">Verify the prototype</a> against its specification.</li>
1418
1606
  </ol>
@@ -1421,48 +1609,94 @@ To create a prototype,
1421
1609
  <p>Once you are satisfied with your prototype, you can proceed to <a href="#usage.tutorial.implement-design">implement your design in Verilog</a>. This process is often a simple translation your Ruby prototype into your Verilog. At the very least, your prototype serves as a reference while you are implementing your Verilog design.</p>
1422
1610
 
1423
1611
 
1424
- <p>Once your design has been implemented in Verilog, you can use the <em>same</em> specification, which was originally used to verify your prototype, to verify your Verilog design.</p>
1612
+ <p>Once your design has been implemented in Verilog, you can use the <em>same</em> specification, which was originally used to verify your prototype, to verify your Verilog design (see <a href="#usage.test-runner">Section 5.3</a> for details).</p>
1613
+ </div>
1614
+
1615
+
1616
+ <hr style="display: none"/>
1617
+
1618
+ <div id="How_does_prototyping_work_" class="section">
1619
+ <h3 class="title">
1620
+ <a href="#a-607218048">5.1.2</a>
1425
1621
 
1622
+ &nbsp;
1426
1623
 
1427
- <h2 ><a id="usage.debugger" href="#a-607926808">5.3</a> &nbsp; Debugging</h2>
1624
+ How does prototyping work?
1625
+ </h3>
1428
1626
 
1627
+ <p>The <code class="code">advance_time</code> method normally transfers control from the executable specification to the Verilog simulator. However, when prototyping is enabled, Ruby-VPI redefines it so that the <code class="code">feign!</code> method (which is defined in a test&#8217;s <tt>proto.rb</tt> file) is invoked on the design under test. The <code class="code">feign!</code> method artificially simulates the behavior of the real Verilog design.</p>
1429
1628
 
1430
- <p>The <a href="http://www.datanoise.com/articles/category/ruby-debug">ruby-debug project</a> serves as the interactive debugger for Ruby-VPI.</p>
1629
+
1630
+ <p>In this manner, control is kept within the Ruby interpreter when prototyping is enabled. An advantage of this approach is that it reduces the total execution time of a Ruby-VPI test by allowing Ruby&#8217;s POSIX thread to commandeer the Verilog simulator&#8217;s process. A disadvantage of this approach is that callbacks, which require the transfer of control to the Verilog simulator, must be ignored.</p>
1631
+
1632
+ </div>
1633
+ </p>
1634
+
1635
+ </div>
1636
+
1637
+
1638
+ <hr style="display: none"/>
1639
+
1640
+ <div id="usage.debugger" class="section">
1641
+ <h2 class="title">
1642
+ <a href="#a-607229298">5.2</a>
1643
+
1644
+ &nbsp;
1645
+
1646
+ Debugging
1647
+ </h2>
1648
+
1649
+ <p>The <a href="http://www.datanoise.com/articles/category/ruby-debug">ruby-debug project</a> serves as the interactive debugger for Ruby-VPI.</p>
1431
1650
 
1432
1651
 
1433
1652
  <ol>
1434
- <li>Enable the debugger by activating the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> environment variable (see <a href="#usage.test-runner">the section named &ldquo;Test runner&rdquo;</a> for details).</li>
1653
+ <li>Enable the debugger by activating the <code class="code"><span style="color:#036; font-weight:bold">DEBUGGER</span></code> environment variable (see <a href="#usage.test-runner">Section 5.3</a> for details).</li>
1435
1654
  <li>Put the <code class="code">debugger</code> command in your code&#8212;anywhere you wish to activate an interactive debugging session. These commands are automatically ignored when the debugger is disabled; so you can safely leave them in your code, if you wish.</li>
1436
1655
  </ol>
1437
1656
 
1438
1657
 
1439
- <h3 ><a id="usage.debugger.init" href="#a-607927888">5.3.1</a> &nbsp; Advanced initialization</h3>
1658
+ <p>
1659
+ <hr style="display: none"/>
1440
1660
 
1661
+ <div id="usage.debugger.init" class="section">
1662
+ <h3 class="title">
1663
+ <a href="#a-607226228">5.2.1</a>
1441
1664
 
1442
- <p>By default, Ruby-VPI enables the debugger by invoking the <code class="code"><span style="color:#036; font-weight:bold">Debugger</span>.start</code> method. If you wish to perform more advanced initialization, such as having the debugger accept remote network connections for interfacing with a remote debugging session or perhaps with an <span class="caps">IDE</span> (see <a href="http://www.datanoise.com/articles/category/ruby-debug">the ruby-debug documentation</a> for details), then:</p>
1665
+ &nbsp;
1666
+
1667
+ Advanced initialization
1668
+ </h3>
1669
+
1670
+ By default, Ruby-VPI enables the debugger by invoking the <code class="code"><span style="color:#036; font-weight:bold">Debugger</span>.start</code> method. If you wish to perform more advanced initialization, such as having the debugger accept remote network connections for interfacing with a remote debugging session or perhaps with an IDE (see <a href="http://www.datanoise.com/articles/category/ruby-debug">the ruby-debug documentation</a> for details), then:
1443
1671
 
1444
1672
 
1445
1673
  <ol>
1446
1674
  <li>Deactivate the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> environment variable.</li>
1447
- <li>Put your own code, which initializes the debugger, above the <code class="code"><span style="color:#036; font-weight:bold">RubyVpi</span>.init_bench</code> line in your generated <tt>spec.rb</tt> file.</li>
1675
+ <li>Put your own code, which initializes the debugger, at the top of your test&#8217;s <tt>spec.rb</tt> file.</li>
1448
1676
  </ol>
1449
1677
 
1678
+ </div>
1679
+ </p>
1450
1680
 
1451
- <h2 ><a id="usage.test-runner" href="#a-607929098">5.4</a> &nbsp; Test runner</h2>
1452
-
1681
+ </div>
1682
+
1453
1683
 
1454
- <p>A test runner is a file, generated by the <a href="#usage.tools.generate-test">automated test generator</a>, whose name ends with <tt>.rake</tt>. It helps you run generated tests&#8212;you can think of it as a <em>makefile</em> if you are familiar with C programming in a <span class="caps">UNIX</span> environment.</p>
1684
+ <hr style="display: none"/>
1455
1685
 
1686
+ <div id="usage.test-runner" class="section">
1687
+ <h2 class="title">
1688
+ <a href="#a-607246068">5.3</a>
1456
1689
 
1457
- <div class="formal">
1690
+ &nbsp;
1458
1691
 
1459
- <div class="example" id="example3">
1692
+ Test runner
1693
+ </h2>
1460
1694
 
1461
- <p class="title">Example 3. Seeing what a test runner can do</p>
1695
+ <p>A test runner is a file, generated by the <a href="#usage.tools.generate">automated test generator</a> whose name ends with <tt>.rake</tt>. It helps you run generated tests&#8212;you can think of it as a <em>makefile</em> if you are familiar with C programming in a UNIX environment.</p>
1462
1696
 
1463
1697
 
1464
- When you invoke a test runner without any arguments, it will show you a list of available tasks:
1465
- <pre>$ rake -f some_test_runner.rake
1698
+ <p>When you invoke a test runner without any arguments, it will show you a list of available tasks:
1699
+ <pre>$ rake -f your_test_runner.rake
1466
1700
 
1467
1701
  (in /home/sun/tmp/ruby-vpi/doc)
1468
1702
  rake clean # Remove any temporary products.
@@ -1473,132 +1707,177 @@ rake ivl # Simulate with Icarus Verilog.
1473
1707
  rake ncsim # Simulate with Cadence NC-Sim.
1474
1708
  rake vcs # Simulate with Synopsys VCS.
1475
1709
  rake vsim # Simulate with Mentor Modelsim.
1476
- </pre>
1477
-
1478
- </div>
1710
+ </pre></p>
1479
1711
 
1480
- </div>
1481
1712
 
1482
- <div class="admonition">
1713
+ <p>
1714
+ <hr style="display: none"/>
1483
1715
 
1484
- <div class="tip" id="tip2">
1716
+ <div id="usage.test-runner.env-vars" class="section">
1717
+ <h3 class="title">
1718
+ <a href="#a-607238958">5.3.1</a>
1485
1719
 
1486
- <p style="float:left"><img src="images/tango/tip.png" title="tip" alt="tip" /></p>
1720
+ &nbsp;
1487
1721
 
1722
+ Environment variables
1723
+ </h3>
1488
1724
 
1489
- <p class="title">Tip: Running multiple tests at once.</p>
1725
+ <p>Test runners support the following <em>environment</em> variables, which allow you to easily change the behavior of the test runner.</p>
1490
1726
 
1491
1727
 
1492
- <p>Create a file named <tt>Rakefile</tt> containing the following line:</p>
1728
+ <ul>
1729
+ <li><code class="code"><span style="color:#036; font-weight:bold">COVERAGE</span></code> enables code coverage analysis and generation of code coverage reports.</li>
1730
+ <li><code class="code"><span style="color:#036; font-weight:bold">DEBUGGER</span></code> enables the <a href="#usage.debugger">interactive debugger</a> in its <a href="http://www.datanoise.com/articles/2006/12/20/post-mortem-debugging">post-mortem debugging mode</a>.</li>
1731
+ <li><code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> enables the Ruby prototype for the design under test so that the prototype, rather than the real Verilog design, is verified by the specification.</li>
1732
+ </ul>
1493
1733
 
1494
1734
 
1495
- <p><code class="code">require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">ruby-vpi/runner_proxy</span><span style="color:#710">'</span></span></code></p>
1735
+ <p>To activate these variables, simply assign the number 1 to them. For example, <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=<span style="color:#00D; font-weight:bold">1</span></code> activates the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> variable.</p>
1496
1736
 
1497
1737
 
1498
- <p>Now you can invoke all test runners in the current directory simply by executing <pre>rake cver</pre> (where <em>cver</em> denotes the <a href="#setup.reqs"><span class="caps">GPL</span> Cver simulator</a>).</p>
1738
+ <p>To deactivate these variables, simply assign a different value to them or <strong>unset</strong> them in your shell. For example, both <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=<span style="color:#00D; font-weight:bold">0</span></code> and <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=</code> dectivate the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> variable.</p>
1499
1739
 
1500
1740
 
1741
+ <p>
1742
+ <div id="Variables_as_command-line_arguments" class="paragraph">
1743
+ <p class="title">Variables as command-line arguments</p>
1744
+ You can specify variable assignments as arguments to the <strong>rake</strong> command. For example, <pre>rake DEBUG=1</pre> is equivalent to
1745
+ <pre>
1746
+ DEBUG=1
1747
+ export DEBUG
1748
+ rake
1749
+ </pre> in Bourne shell or
1750
+ <pre>
1751
+ setenv DEBUG 1
1752
+ rake
1753
+ </pre> in C shell.
1501
1754
  </div>
1755
+ </p>
1502
1756
 
1503
- </div>
1504
1757
 
1505
- <h3 ><a id="usage.test-runner.env-vars" href="#a-607930258">5.4.1</a> &nbsp; Environment variables</h3>
1758
+ <p>
1759
+ <hr style="display: none"/>
1506
1760
 
1761
+ <div class="formal">
1762
+ <div class="example" id="Running_a_test_with_environment_variables">
1763
+
1507
1764
 
1508
- <p>Test runners support the following <em>environment</em> variables, which allow you to easily change the behavior of the test runner.</p>
1765
+ <p class="title"><a href="#a-607234788">Example 2</a>. &nbsp; Running a test with environment variables</p>
1509
1766
 
1767
+ <p>Below, we enable the prototype and code coverage analysis:
1768
+ <pre>rake -f your_test_runner.rake PROTOTYPE=1 COVERAGE=1</pre></p>
1510
1769
 
1511
- <ul>
1512
- <li><code class="code"><span style="color:#036; font-weight:bold">COVERAGE</span></code> enables code coverage analysis and generation of code coverage reports.</li>
1513
- <li><code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> enables the <a href="#usage.debugger">interactive debugger</a> in its <a href="http://www.datanoise.com/articles/2006/12/20/post-mortem-debugging">post-mortem debugging mode</a>.</li>
1514
- <li><code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> enables the Ruby prototype for the design under test.</li>
1515
- </ul>
1516
-
1517
-
1518
- <p>To activate these variables, simply assign a non-empty value to them. For example, <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=<span style="color:#00D; font-weight:bold">1</span></code> and <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=yes</code> and <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=foo_bar_baz</code> all activate the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> variable.</p>
1519
1770
 
1771
+ <p>Below, we <em>disable</em> the prototype and enable the code coverage analysis. These invocations are equivalent if the <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> environment variable is unset.
1772
+ <pre>rake -f your_test_runner.rake PROTOTYPE=0 COVERAGE=1</pre>
1773
+ <pre>rake -f your_test_runner.rake PROTOTYPE= COVERAGE=1</pre>
1774
+ <pre>rake -f your_test_runner.rake COVERAGE=1</pre></p>
1775
+ </div>
1776
+ </div>
1777
+ </p>
1520
1778
 
1521
- <p>To deactivate these variables, simply assign an <em>empty</em> value to them, <strong>unset</strong> them in your shell, or do not specify them as command-line arguments to rake. For example, both <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span>=</code> dectivates the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> variable.</p>
1779
+ </div>
1780
+ </p>
1522
1781
 
1782
+ </div>
1783
+
1523
1784
 
1524
- <p>In addition, you can specify variable assignments as arguments to the <strong>rake</strong> command. For example, <pre>rake DEBUG=1</pre> is equivalent to <pre>
1525
- $ DEBUG=1
1526
- $ export DEBUG
1527
- $ rake
1528
- </pre> in Bourne shell or <pre>
1529
- % setenv DEBUG 1
1530
- % rake
1531
- </pre> in C shell.</p>
1785
+ <hr style="display: none"/>
1532
1786
 
1787
+ <div id="usage.tools" class="section">
1788
+ <h2 class="title">
1789
+ <a href="#a-607265218">5.4</a>
1533
1790
 
1534
- <div class="formal">
1791
+ &nbsp;
1535
1792
 
1536
- <div class="example" id="example4">
1793
+ Tools
1794
+ </h2>
1537
1795
 
1538
- <p class="title">Example 4. Running a test with environment variables</p>
1796
+ <p>The <strong>ruby-vpi</strong> command serves as a front-end to the tools provided by Ruby-VPI. You can see its help information (reproduced below) by simply running the command without any arguments.</p>
1539
1797
 
1540
1798
 
1541
- Here we enable the prototype and code coverage analysis:
1542
- <pre>rake -f some_test_runner.rake PROTOTYPE=1 COVERAGE=1</pre>
1799
+ <pre>This is a front-end for tools provided by Ruby-VPI.
1543
1800
 
1544
- Here we <em>disable</em> the prototype and enable the code coverage analysis. Note that both of these invocations are equivalent:
1545
- <pre>rake -f some_test_runner.rake PROTOTYPE= COVERAGE=1</pre>
1546
- <pre>rake -f some_test_runner.rake COVERAGE=1</pre>
1801
+ Usage:
1547
1802
 
1548
- </div>
1803
+ ruby-vpi Show this help message
1804
+ ruby-vpi TOOL --help Show help message for TOOL
1805
+ ruby-vpi TOOL arguments... Run TOOL with some arguments
1549
1806
 
1550
- </div>
1807
+ Tools:
1808
+ convert Converts Verilog source code into Ruby.
1809
+ generate Generates Ruby-VPI tests from Verilog 2001 and Verilog 95 module declarations.
1551
1810
 
1552
- <h2 ><a id="usage.examples" href="#a-607931608">5.5</a> &nbsp; Sample tests</h2>
1811
+ Simulators:
1812
+ cver GPL Cver
1813
+ ivl Icarus Verilog
1814
+ vcs Synopsys VCS
1815
+ vsim Mentor Modelsim
1816
+ ncsim Cadence NC-Sim
1817
+ </pre>
1553
1818
 
1554
1819
 
1555
- <p>The <tt>samp</tt> directory contains several sample tests which illustrate how Ruby-VPI can be used. Each sample has an associated <tt>Rakefile</tt> which simplifies the process of running it. Therefore, simply navigate into an example directory and run the <pre>rake</pre> command to get started.</p>
1820
+ <p>
1821
+ <hr style="display: none"/>
1556
1822
 
1823
+ <div id="usage.tools.generate" class="section">
1824
+ <h3 class="title">
1825
+ <a href="#a-607255398">5.4.1</a>
1557
1826
 
1558
- <h2 ><a id="usage.tools" href="#a-607932628">5.6</a> &nbsp; Tools</h2>
1827
+ &nbsp;
1559
1828
 
1829
+ Automated test generation
1830
+ </h3>
1560
1831
 
1561
- <p>The <tt>bin</tt> directory contains various utilities which ease the process of writing tests. Each tool provides help and usage information invoked with the <tt>--help</tt> option.</p>
1832
+ <p>The <strong>generate</strong> tool generates scaffolding for Ruby-VPI tests from Verilog module declarations (written in either Verilog 2001 or Verilog 95 style).</p>
1562
1833
 
1563
1834
 
1564
- <h3 ><a id="usage.tools.generate-test" href="#a-607933658">5.6.1</a> &nbsp; Automated test generation</h3>
1835
+ A Ruby-VPI test is composed of the following files:
1836
+ <ul>
1837
+ <li><tt>runner.rake</tt> runs the test by starting a Verilog simulator and loading Ruby-VPI into it.</li>
1838
+ <li><tt>spec.rb</tt> is the executable specification for the design under test.</li>
1839
+ <li><tt>design.rb</tt> is an optional file that provides convenience methods for controlling the design under test.</li>
1840
+ <li><tt>proto.rb</tt> is an optional file that defines a Ruby prototype of the design under test.</li>
1841
+ <li><tt>Rakefile</tt> is an optional file that recursively executes all <tt>runner.rake</tt> files found immediately within or beneath the current directory. It lets you simply run <pre>rake ...</pre> instead of having to write <pre>rake -f runner.rake ...</pre> every time.</li>
1842
+ </ul>
1565
1843
 
1566
1844
 
1567
- <p>The automated test generator (<strong>generate_test.rb</strong>) generates tests from Verilog 2001 module declarations, as demonstrated <a href="#usage.tutorial.generate-test">in the tutorial</a>. A generated test is composed of the following parts:</p>
1845
+ <p>As <a href="#fig:generate-test.RSpec">Example 4</a> shows, the name of each generated file is prefixed with the name of the Verilog module for which the test was generated. This convention helps organize tests within the file system, so that they are readily distinguishable from one another.</p>
1568
1846
 
1569
1847
 
1570
- <ul>
1571
- <li>Runner
1572
- &#8211; written in <a href="#glossary.rake">Rake</a>, this file builds and runs the test.</li>
1573
- <li>Bench
1574
- &#8211; written in Verilog and Ruby, these files define the testing environment.</li>
1575
- <li>Design
1576
- &#8211; written in Ruby, this file provides an interface to the design being verified.</li>
1577
- <li>Prototype
1578
- &#8211; written in Ruby, this file defines a prototype of the design being verified.</li>
1579
- <li>Specification
1580
- &#8211; written in Ruby, this file describes the expected behavior of the design.</li>
1581
- </ul>
1848
+ <p>
1849
+ <hr style="display: none"/>
1582
1850
 
1851
+ <div class="admonition">
1852
+ <div class="caution" id="Do_not_rename_generated_files">
1853
+ <img src="images/tango/caution.png" alt="caution" class="icon"/>
1583
1854
 
1584
- <p>The reason for dividing a single test into these parts is mainly to decouple the design from the specification. This allows you to focus on writing the specification while the remainder is automatically generated by the tool. For example, when the interface of a Verilog module changes, you would simply re-run this tool and incorporate those changes (using a <a href="#setup.recom.merger">text merging tool</a>) into the test without diverting your focus from the specification.</p>
1855
+ <p class="title"><a href="#a-607248828">Caution 1</a>. &nbsp; Do not rename generated files</p>
1585
1856
 
1857
+ Ruby-VPI uses the convention described above to dynamically create a direct Ruby interface to the design under test, so <em>do not</em> rename the generated files arbitrarily.
1858
+ </div>
1859
+ </div>
1860
+
1861
+ By producing multiple files, the automated test generator physically decouples the various parts of a test. As a result, when the interface of a Verilog module changes, you can simply regenerate the test to incorporate those changes without diverting your focus from the task at hand. Furthermore, the incorporation of changes can be catalyzed by interactive text merging tools, which allow you to selectively accept or reject the merging of changes into your source code. Fully automated text merging tools may also be used for this purpose.</p>
1586
1862
 
1587
- <div class="admonition">
1588
1863
 
1589
- <div class="tip" id="tip3">
1864
+ <p>You can try this tool by running the <pre>ruby-vpi generate --help</pre> command.</p>
1590
1865
 
1591
- <p style="float:left"><img src="images/tango/tip.png" title="tip" alt="tip" /></p>
1592
1866
 
1867
+ <p>
1868
+ <hr style="display: none"/>
1593
1869
 
1594
- <p class="title">Tip: Using <strong>kdiff3</strong> with the automated test generator.</p>
1870
+ <div class="admonition">
1871
+ <div class="tip" id="Using__kdiff3__with_the_automated_test_generator.">
1872
+ <img src="images/tango/tip.png" alt="tip" class="icon"/>
1595
1873
 
1874
+ <p class="title"><a href="#a-607251318">Tip 2</a>. &nbsp; Using <strong>kdiff3</strong> with the automated test generator.</p>
1596
1875
 
1597
- <ol>
1876
+ <ol>
1598
1877
  <li>Create a file named <tt>merge2</tt> with the following content: <pre class="code">
1599
1878
  <span style="color:#888">#!/bin/sh</span>
1600
1879
  <span style="color:#888"># args: old file, new file</span>
1601
- kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">$2</span><span style="color:#710">&quot;</span></span> <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">$@</span><span style="color:#710">&quot;</span></span>
1880
+ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">$2</span><span style="color:#710">&quot;</span></span> <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">$@</span><span style="color:#710">&quot;</span></span>
1602
1881
  </pre></li>
1603
1882
  <li>Make the file executable by running the <pre>chmod +x merge2</pre> command.</li>
1604
1883
  <li>Place the file somewhere accessible by your <code class="code"><span style="color:#036; font-weight:bold">PATH</span></code> environment variable.</li>
@@ -1607,27 +1886,65 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
1607
1886
 
1608
1887
 
1609
1888
  <p>From now on, <strong>kdiff3</strong> will be invoked to help you transfer your changes between generated files. When you are finished transferring changes, simply issue the &#8220;save the file&#8221; command and quit <strong>kdiff3</strong>. Or, if you do not want to transfer any changes, simply quit <strong>kdiff3</strong> <em>without</em> saving the file.</p>
1889
+ </div>
1890
+ </div>
1891
+ </p>
1610
1892
 
1893
+ </div>
1611
1894
 
1612
- </div>
1613
1895
 
1614
- </div>
1896
+ <hr style="display: none"/>
1615
1897
 
1616
- <h3 ><a id="usage.tools.verilog-ruby-conv" href="#a-607934908">5.6.2</a> &nbsp; Verilog to Ruby conversion</h3>
1898
+ <div id="usage.tools.convert" class="section">
1899
+ <h3 class="title">
1900
+ <a href="#a-607257688">5.4.2</a>
1617
1901
 
1902
+ &nbsp;
1618
1903
 
1619
- <p>The <strong>header_to_ruby.rb</strong> tool can be used to convert Verilog header files into Ruby. You can try it by running the <pre>header_to_ruby.rb --help</pre> command.</p>
1904
+ Verilog to Ruby conversion
1905
+ </h3>
1620
1906
 
1907
+ <p>The <strong>convert</strong> tool can be used to convert Verilog header files into Ruby. You can try it by running the <pre>ruby-vpi convert --help</pre> command.</p>
1621
1908
 
1622
- <p>By converting Verilog header files into Ruby, your <a href="#glossary.test">test</a> can utilize the same <code class="code"><span style="background-color:#f0fff0"><span style="color:#161">`</span><span style="color:#2B2">define</span></span></code> constants that are used in the Verilog <a href="#glossary.design">design</a>.</p>
1623
1909
 
1910
+ <p>By converting Verilog header files into Ruby, your test can utilize the same <code class="code"><span style="background-color:#f0fff0"><span style="color:#161">`</span><span style="color:#2B2">define</span></span></code> constants that are used in the Verilog design.</p>
1624
1911
 
1625
- <h2 ><a id="usage.tutorial" href="#a-607936328">5.7</a> &nbsp; Tutorial</h2>
1912
+ </div>
1913
+ </p>
1626
1914
 
1915
+ </div>
1916
+
1627
1917
 
1628
- <ol>
1918
+ <hr style="display: none"/>
1919
+
1920
+ <div id="usage.examples" class="section">
1921
+ <h2 class="title">
1922
+ <a href="#a-607267438">5.5</a>
1923
+
1924
+ &nbsp;
1925
+
1926
+ Sample tests
1927
+ </h2>
1928
+
1929
+ The <tt>samp</tt> directory contains several sample tests which illustrate how Ruby-VPI can be used. Each sample has an associated <tt>Rakefile</tt> which simplifies the process of running it. Therefore, simply navigate into an example directory and run the <pre>rake</pre> command to get started.
1930
+
1931
+ </div>
1932
+
1933
+
1934
+ <hr style="display: none"/>
1935
+
1936
+ <div id="usage.tutorial" class="section">
1937
+ <h2 class="title">
1938
+ <a href="#a-607188458">5.6</a>
1939
+
1940
+ &nbsp;
1941
+
1942
+ Tutorial
1943
+ </h2>
1944
+
1945
+ <ol>
1629
1946
  <li><a href="#usage.tutorial.declare-design">Declare a design</a> using Verilog 2001 syntax.</li>
1630
- <li><a href="#usage.tutorial.generate-test">Generate a test</a> for the design using the <a href="#usage.tools.generate-test">automated test generator</a> tool.</li>
1947
+ <li><a href="#usage.tutorial.generate-test">Generate a test</a> for the design using the <a href="#usage.tools.generate">automated test generator</a> tool.</li>
1631
1948
  <li><a href="#usage.tutorial.specification">Identify your expectations</a> for the design and implement them in the specification.</li>
1632
1949
  <li>(Optional) <a href="#usage.tutorial.implement-proto">Implement the prototype</a> of the design in Ruby.</li>
1633
1950
  <li>(Optional) <a href="#usage.tutorial.test-proto">Verify the prototype</a> against the specification.</li>
@@ -1636,10 +1953,19 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
1636
1953
  </ol>
1637
1954
 
1638
1955
 
1639
- <h3 ><a id="usage.tutorial.declare-design" href="#a-607937408">5.7.1</a> &nbsp; Start with a design</h3>
1956
+ <p>
1957
+ <hr style="display: none"/>
1640
1958
 
1959
+ <div id="usage.tutorial.declare-design" class="section">
1960
+ <h3 class="title">
1961
+ <a href="#a-607274848">5.6.1</a>
1641
1962
 
1642
- <p>First, we need a <a href="#glossary.design">design</a> to verify. In this tutorial, <a href="#fig..counter.v_decl">the example named &ldquo;Declaration of a simple up-counter with synchronous reset&rdquo;</a> will serve as our design. Its interface is composed of the following parts:</p>
1963
+ &nbsp;
1964
+
1965
+ Start with a Verilog design
1966
+ </h3>
1967
+
1968
+ <p>First, we need a Verilog design to test. In this tutorial, <a href="#fig:counter.v_decl">Example 3</a> will serve as our design under test. Its interface is composed of the following parts:</p>
1643
1969
 
1644
1970
 
1645
1971
  <ul>
@@ -1650,127 +1976,128 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
1650
1976
  </ul>
1651
1977
 
1652
1978
 
1653
- <div class="formal">
1979
+ <p>
1980
+ <hr style="display: none"/>
1654
1981
 
1655
- <div class="example" id="fig..counter.v_decl">
1982
+ <div class="formal">
1983
+ <div class="example" id="fig:counter.v_decl">
1984
+
1656
1985
 
1657
- <p class="title">Example 5. Declaration of a simple up-counter with synchronous reset</p>
1986
+ <p class="title"><a href="#a-607271338">Example 3</a>. &nbsp; Declaration of a simple up-counter with synchronous reset</p>
1658
1987
 
1659
-
1660
- <pre class="code" lang="verilog">
1988
+ <pre class="code" lang="verilog">
1661
1989
  module counter #(parameter Size = 5) (
1662
- input clock,
1663
- input reset,
1664
- output reg [Size - 1 : 0] count
1990
+ input clock,
1991
+ input reset,
1992
+ output reg [Size-1 : 0] count
1665
1993
  );
1666
1994
  endmodule
1667
1995
  </pre>
1996
+ </div>
1997
+ </div>
1998
+
1999
+ Before we continue, save the source code shown in <a href="#fig:counter.v_decl">Example 3</a> into a file named <tt>counter.v</tt>.</p>
1668
2000
 
1669
- </div>
1670
-
1671
- </div>
1672
-
1673
- <div class="admonition">
1674
-
1675
- <div class="important" id="important1">
1676
-
1677
- <p style="float:left"><img src="images/tango/important.png" title="important" alt="important" /></p>
1678
-
1679
-
1680
- <p class="title">Important: Before we continue&#8230;</p>
1681
-
1682
-
1683
- <p>Save the source code shown in <a href="#fig..counter.v_decl">the example named &ldquo;Declaration of a simple up-counter with synchronous reset&rdquo;</a> into a file named <tt>counter.v</tt>.</p>
2001
+ </div>
2002
+ </p>
1684
2003
 
1685
2004
 
1686
- </div>
2005
+ <p>
2006
+ <hr style="display: none"/>
1687
2007
 
1688
- </div>
2008
+ <div id="usage.tutorial.generate-test" class="section">
2009
+ <h3 class="title">
2010
+ <a href="#a-607081228">5.6.2</a>
1689
2011
 
1690
- <h3 ><a id="usage.tutorial.generate-test" href="#a-607938748">5.7.2</a> &nbsp; Generate a test</h3>
2012
+ &nbsp;
1691
2013
 
2014
+ Generate a test
2015
+ </h3>
1692
2016
 
1693
- <p>Now that we have a <a href="#glossary.design">design</a> to verify, let us generate a <a href="#glossary.test">test</a> for it using the <a href="#usage.tools.generate-test">automated test generator</a>. This tool allows us to implement our specification in either rSpec, xUnit, or our very own format.</p>
2017
+ <p>Now that we have a Verilog design to test, we shall use the <a href="#usage.tools.generate">generate</a> tool to generate some scaffolding for our test. This tool allows us to implement our specification using RSpec, xUnit, or any other format.</p>
1694
2018
 
1695
2019
 
1696
2020
  Each format represents a different software development methodology:
1697
2021
  <ul>
1698
- <li>rSpec represents <a href="#glossary.BDD"><span class="caps">BDD</span></a></li>
1699
- <li>xUnit represents <a href="#glossary.TDD"><span class="caps">TDD</span></a></li>
2022
+ <li>RSpec represents <a href="#glossary.BDD">BDD</a></li>
2023
+ <li>xUnit represents <a href="#glossary.TDD">TDD</a></li>
1700
2024
  <li>our own format can represent another methodology</li>
1701
2025
  </ul>
1702
2026
 
1703
2027
 
1704
- <div class="admonition">
1705
-
1706
- <div class="note" id="note5">
1707
-
1708
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
1709
-
1710
-
1711
- <p class="title">Note:</p>
1712
-
1713
-
1714
- <p>Both rSpec and xUnit formats are presented in this tutorial.</p>
1715
-
1716
-
1717
- </div>
1718
-
1719
- </div>
2028
+ <p>In this tutorial, you will see how both RSpec and xUnit formats are used. So let us make separate directories for both formats to avoid generated tests from overwriting each other:
2029
+ <pre>
2030
+ $ mkdir RSpec xUnit
2031
+ $ cp counter.v RSpec
2032
+ $ cp counter.v xUnit
2033
+ </pre></p>
1720
2034
 
1721
- <p>Once we have decided how we want to implement our specification, we can proceed to generate a test for our design. This process is illustrated by <a href="#fig..generate-test.rspec">the example named &ldquo;Generating a test with specification in rSpec format&rdquo;</a> and <a href="#fig..generate-test.unit-test">the example named &ldquo;Generating a test with specification in xUnit format&rdquo;</a>.</p>
1722
2035
 
2036
+ <p>Once we have decided how we want to implement our specification, we can proceed to generate a test for our design. This process is illustrated by <a href="#fig:generate-test.RSpec">Example 4</a> and <a href="#fig:generate-test.xUnit">Example 5</a>.</p>
1723
2037
 
1724
- <div class="formal">
1725
2038
 
1726
- <div class="example" id="fig..generate-test.rspec">
2039
+ <p>
2040
+ <hr style="display: none"/>
1727
2041
 
1728
- <p class="title">Example 6. Generating a test with specification in rSpec format</p>
2042
+ <div class="formal">
2043
+ <div class="example" id="fig:generate-test.RSpec">
2044
+
1729
2045
 
2046
+ <p class="title"><a href="#a-607278188">Example 4</a>. &nbsp; Generating a test with specification in RSpec format</p>
1730
2047
 
1731
- <pre>
1732
- $ generate_test.rb counter.v --rspec --name rspec
2048
+ <pre>
2049
+ $ ruby-vpi generate counter.v --RSpec
1733
2050
 
1734
2051
  module counter
1735
- create counter_rspec_runner.rake
1736
- create counter_rspec_bench.v
1737
- create counter_rspec_bench.rb
1738
- create counter_rspec_design.rb
1739
- create counter_rspec_proto.rb
1740
- create counter_rspec_spec.rb
2052
+ create counter_runner.rake
2053
+ create counter_design.rb
2054
+ create counter_proto.rb
2055
+ create counter_spec.rb
2056
+ create Rakefile
1741
2057
  </pre>
2058
+ </div>
2059
+ </div>
2060
+
1742
2061
 
1743
- </div>
1744
-
1745
- </div>
1746
-
1747
- <div class="formal">
1748
-
1749
- <div class="example" id="fig..generate-test.unit-test">
2062
+ <hr style="display: none"/>
1750
2063
 
1751
- <p class="title">Example 7. Generating a test with specification in xUnit format</p>
2064
+ <div class="formal">
2065
+ <div class="example" id="fig:generate-test.xUnit">
2066
+
1752
2067
 
2068
+ <p class="title"><a href="#a-607073088">Example 5</a>. &nbsp; Generating a test with specification in xUnit format</p>
1753
2069
 
1754
- <pre>
1755
- $ generate_test.rb counter.v --xunit --name xunit
2070
+ <pre>
2071
+ $ ruby-vpi generate counter.v --xUnit
1756
2072
 
1757
2073
  module counter
1758
- create counter_xunit_runner.rake
1759
- create counter_xunit_bench.v
1760
- create counter_xunit_bench.rb
1761
- create counter_xunit_design.rb
1762
- create counter_xunit_proto.rb
1763
- create counter_xunit_spec.rb
2074
+ create counter_runner.rake
2075
+ create counter_design.rb
2076
+ create counter_proto.rb
2077
+ create counter_spec.rb
2078
+ create Rakefile
1764
2079
  </pre>
2080
+ </div>
2081
+ </div>
2082
+ </p>
1765
2083
 
1766
- </div>
2084
+ </div>
2085
+ </p>
1767
2086
 
1768
- </div>
1769
2087
 
1770
- <h3 ><a id="usage.tutorial.specification" href="#a-607940058">5.7.3</a> &nbsp; Specify your expectations</h3>
2088
+ <p>
2089
+ <hr style="display: none"/>
2090
+
2091
+ <div id="usage.tutorial.specification" class="section">
2092
+ <h3 class="title">
2093
+ <a href="#a-607098358">5.6.3</a>
2094
+
2095
+ &nbsp;
1771
2096
 
2097
+ Specify your expectations
2098
+ </h3>
1772
2099
 
1773
- <p>So far, the test generation tool has created a basic foundation for our <a href="#glossary.test">test</a>. Now we must build upon this foundation by identifying our <a href="#glossary.expectation">expectation</a> of the <a href="#glossary.design">design</a>. That is, how do we expect the design to <em>behave</em> under certain conditions?</p>
2100
+ <p>So far, the test generation tool has created a basic foundation for our test Now we must build upon this foundation by identifying our <a href="#glossary.expectation">expectation</a> of the design under test. That is, how do we expect the design to <em>behave</em> under certain conditions?</p>
1774
2101
 
1775
2102
 
1776
2103
  Here are some reasonable expectations for our simple counter:
@@ -1781,72 +2108,74 @@ Here are some reasonable expectations for our simple counter:
1781
2108
  </ul>
1782
2109
 
1783
2110
 
1784
- <p>Now that we have identified a set of expectations for our design, we are ready to implement them in our specification. This process is illustrated by <a href="#fig..counter_rspec_spec.rb">the example named &ldquo;Specification implemented in rSpec format&rdquo;</a> and <a href="#fig..counter_xunit_spec.rb">the example named &ldquo;Specification implemented in xUnit format&rdquo;</a>.</p>
2111
+ <p>Now that we have identified a set of expectations for our design, we are ready to implement them in our specification. This process is illustrated by <a href="#fig:RSpec_counter_spec.rb">Example 6</a> and <a href="#fig:xUnit_counter_spec.rb">Example 7</a>.</p>
1785
2112
 
1786
2113
 
1787
- <div class="formal">
1788
2114
 
1789
- <div class="example" id="fig..counter_rspec_spec.rb">
2115
+ <hr style="display: none"/>
1790
2116
 
1791
- <p class="title">Example 8. Specification implemented in rSpec format</p>
2117
+ <div class="formal">
2118
+ <div class="example" id="fig:RSpec_counter_spec.rb">
2119
+
1792
2120
 
2121
+ <p class="title"><a href="#a-607085368">Example 6</a>. &nbsp; Specification implemented in RSpec format</p>
1793
2122
 
1794
- <pre class="code"><span style="color:#888"># This file is a behavioral specification for the design under test.</span>
2123
+ <pre class="code">require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">spec</span><span style="color:#710">'</span></span>
1795
2124
 
1796
2125
  <span style="color:#888"># lowest upper bound of counter's value</span>
1797
- <span style="color:#036; font-weight:bold">LIMIT</span> = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#036; font-weight:bold">Counter</span>.<span style="color:#036; font-weight:bold">Size</span>.intVal
2126
+ <span style="color:#036; font-weight:bold">LIMIT</span> = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#036; font-weight:bold">Counter</span>::<span style="color:#036; font-weight:bold">Size</span>
1798
2127
 
1799
2128
  <span style="color:#888"># maximum allowed value for a counter</span>
1800
2129
  <span style="color:#036; font-weight:bold">MAX</span> = <span style="color:#036; font-weight:bold">LIMIT</span> - <span style="color:#00D; font-weight:bold">1</span>
1801
2130
 
1802
- context <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">A resetted counter's value</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
2131
+ describe <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">A resetted counter's value</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
1803
2132
  setup <span style="color:#080; font-weight:bold">do</span>
1804
2133
  <span style="color:#036; font-weight:bold">Counter</span>.reset!
1805
2134
  <span style="color:#080; font-weight:bold">end</span>
1806
2135
 
1807
- specify <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should be zero</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
2136
+ it <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should be zero</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
1808
2137
  <span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == <span style="color:#00D; font-weight:bold">0</span>
1809
2138
  <span style="color:#080; font-weight:bold">end</span>
1810
2139
 
1811
- specify <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should increment by one count upon each rising clock edge</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
2140
+ it <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should increment upon each rising clock edge</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
1812
2141
  <span style="color:#036; font-weight:bold">LIMIT</span>.times <span style="color:#080; font-weight:bold">do</span> |i|
1813
2142
  <span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == i
1814
- simulate <span style="color:#888"># increment the counter</span>
2143
+ <span style="color:#036; font-weight:bold">Counter</span>.cycle! <span style="color:#888"># increment the counter</span>
1815
2144
  <span style="color:#080; font-weight:bold">end</span>
1816
2145
  <span style="color:#080; font-weight:bold">end</span>
1817
2146
  <span style="color:#080; font-weight:bold">end</span>
1818
2147
 
1819
- context <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">A counter with the maximum value</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
2148
+ describe <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">A counter with the maximum value</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
1820
2149
  setup <span style="color:#080; font-weight:bold">do</span>
1821
2150
  <span style="color:#036; font-weight:bold">Counter</span>.reset!
1822
2151
 
1823
2152
  <span style="color:#888"># increment the counter to maximum value</span>
1824
- <span style="color:#036; font-weight:bold">MAX</span>.times {simulate}
2153
+ <span style="color:#036; font-weight:bold">MAX</span>.times { <span style="color:#036; font-weight:bold">Counter</span>.cycle! }
1825
2154
  <span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == <span style="color:#036; font-weight:bold">MAX</span>
1826
2155
  <span style="color:#080; font-weight:bold">end</span>
1827
2156
 
1828
- specify <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should overflow upon increment</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
1829
- simulate <span style="color:#888"># increment the counter</span>
2157
+ it <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">should overflow upon increment</span><span style="color:#710">&quot;</span></span> <span style="color:#080; font-weight:bold">do</span>
2158
+ <span style="color:#036; font-weight:bold">Counter</span>.cycle! <span style="color:#888"># increment the counter</span>
1830
2159
  <span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == <span style="color:#00D; font-weight:bold">0</span>
1831
2160
  <span style="color:#080; font-weight:bold">end</span>
1832
2161
  <span style="color:#080; font-weight:bold">end</span>
1833
2162
  </pre>
2163
+ </div>
2164
+ </div>
2165
+
1834
2166
 
1835
- </div>
1836
-
1837
- </div>
1838
-
1839
- <div class="formal">
1840
-
1841
- <div class="example" id="fig..counter_xunit_spec.rb">
2167
+ <hr style="display: none"/>
1842
2168
 
1843
- <p class="title">Example 9. Specification implemented in xUnit format</p>
2169
+ <div class="formal">
2170
+ <div class="example" id="fig:xUnit_counter_spec.rb">
2171
+
1844
2172
 
2173
+ <p class="title"><a href="#a-607089898">Example 7</a>. &nbsp; Specification implemented in xUnit format</p>
1845
2174
 
1846
- <pre class="code"><span style="color:#888"># This file is a behavioral specification for the design under test.</span>
2175
+ <pre class="code">require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">test/unit</span><span style="color:#710">'</span></span>
1847
2176
 
1848
2177
  <span style="color:#888"># lowest upper bound of counter's value</span>
1849
- <span style="color:#036; font-weight:bold">LIMIT</span> = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#036; font-weight:bold">Counter</span>.<span style="color:#036; font-weight:bold">Size</span>.intVal
2178
+ <span style="color:#036; font-weight:bold">LIMIT</span> = <span style="color:#00D; font-weight:bold">2</span> ** <span style="color:#036; font-weight:bold">Counter</span>::<span style="color:#036; font-weight:bold">Size</span>
1850
2179
 
1851
2180
  <span style="color:#888"># maximum allowed value for a counter</span>
1852
2181
  <span style="color:#036; font-weight:bold">MAX</span> = <span style="color:#036; font-weight:bold">LIMIT</span> - <span style="color:#00D; font-weight:bold">1</span>
@@ -1857,13 +2186,13 @@ context <span style="background-color:#fff0f0"><span style="color:#710">&quot;</
1857
2186
  <span style="color:#080; font-weight:bold">end</span>
1858
2187
 
1859
2188
  <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">test_zero</span>
1860
- assert_equal <span style="color:#00D; font-weight:bold">0</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
2189
+ assert_equal( <span style="color:#00D; font-weight:bold">0</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal )
1861
2190
  <span style="color:#080; font-weight:bold">end</span>
1862
2191
 
1863
2192
  <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">test_increment</span>
1864
2193
  <span style="color:#036; font-weight:bold">LIMIT</span>.times <span style="color:#080; font-weight:bold">do</span> |i|
1865
- assert_equal i, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
1866
- simulate <span style="color:#888"># increment the counter</span>
2194
+ assert_equal( i, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal )
2195
+ <span style="color:#036; font-weight:bold">Counter</span>.cycle! <span style="color:#888"># increment the counter</span>
1867
2196
  <span style="color:#080; font-weight:bold">end</span>
1868
2197
  <span style="color:#080; font-weight:bold">end</span>
1869
2198
  <span style="color:#080; font-weight:bold">end</span>
@@ -1873,70 +2202,73 @@ context <span style="background-color:#fff0f0"><span style="color:#710">&quot;</
1873
2202
  <span style="color:#036; font-weight:bold">Counter</span>.reset!
1874
2203
 
1875
2204
  <span style="color:#888"># increment the counter to maximum value</span>
1876
- <span style="color:#036; font-weight:bold">MAX</span>.times {simulate}
1877
- assert_equal <span style="color:#036; font-weight:bold">MAX</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
2205
+ <span style="color:#036; font-weight:bold">MAX</span>.times { <span style="color:#036; font-weight:bold">Counter</span>.cycle! }
2206
+ assert_equal( <span style="color:#036; font-weight:bold">MAX</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal )
1878
2207
  <span style="color:#080; font-weight:bold">end</span>
1879
2208
 
1880
2209
  <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">test_overflow</span>
1881
- simulate <span style="color:#888"># increment the counter</span>
1882
- assert_equal <span style="color:#00D; font-weight:bold">0</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
2210
+ <span style="color:#036; font-weight:bold">Counter</span>.cycle! <span style="color:#888"># increment the counter</span>
2211
+ assert_equal( <span style="color:#00D; font-weight:bold">0</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal )
1883
2212
  <span style="color:#080; font-weight:bold">end</span>
1884
2213
  <span style="color:#080; font-weight:bold">end</span>
1885
2214
  </pre>
1886
-
1887
- </div>
1888
-
1889
- </div>
1890
-
1891
- <div class="admonition">
1892
-
1893
- <div class="important" id="important2">
1894
-
1895
- <p style="float:left"><img src="images/tango/important.png" title="important" alt="important" /></p>
1896
-
1897
-
1898
- <p class="title">Important: Before we continue&#8230;</p>
1899
-
1900
-
2215
+ </div>
2216
+ </div>
2217
+
2218
+ Before we continue,
1901
2219
  <ol>
1902
- <li>Replace the contents of the file named <tt>counter_rspec_spec.rb</tt> with the source code shown in <a href="#fig..counter_rspec_spec.rb">the example named &ldquo;Specification implemented in rSpec format&rdquo;</a>.</li>
1903
- <li>Replace the contents of the file named <tt>counter_xunit_spec.rb</tt> with the source code shown in <a href="#fig..counter_xunit_spec.rb">the example named &ldquo;Specification implemented in xUnit format&rdquo;</a>.</li>
1904
- <li>Replace the contents of the files named <tt>counter_rspec_design.rb</tt> and <tt>counter_xunit_design.rb</tt> with the following code. <pre class="code"><span style="color:#888"># This is a Ruby interface to the design under test.</span>
1905
-
1906
- <span style="color:#888"># This method resets the design under test.</span>
1907
- <span style="color:#080; font-weight:bold">def</span> <span style="color:#036; font-weight:bold">Counter</span>.reset!
1908
- reset.intVal = <span style="color:#00D; font-weight:bold">1</span>
1909
- simulate
1910
- reset.intVal = <span style="color:#00D; font-weight:bold">0</span>
2220
+ <li>Replace the contents of the file named <tt>RSpec/counter_spec.rb</tt> with the source code shown in <a href="#fig:RSpec_counter_spec.rb">Example 6</a>.</li>
2221
+ <li>Replace the contents of the file named <tt>xUnit/counter_spec.rb</tt> with the source code shown in <a href="#fig:xUnit_counter_spec.rb">Example 7</a>.</li>
2222
+ <li>Replace the contents of the files named <tt>RSpec/counter_design.rb</tt> and <tt>xUnit/counter_design.rb</tt> with the following code. <pre class="code">
2223
+ <span style="color:#888"># Simulates the design under test for one clock cycle.</span>
2224
+ <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">cycle!</span>
2225
+ clock.high!
2226
+ advance_time
2227
+ clock.low!
2228
+ advance_time
2229
+ <span style="color:#080; font-weight:bold">end</span>
2230
+
2231
+ <span style="color:#888"># Brings the design under test into a blank state.</span>
2232
+ <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">reset!</span>
2233
+ reset.high!
2234
+ cycle!
2235
+ reset.low!
1911
2236
  <span style="color:#080; font-weight:bold">end</span>
1912
2237
  </pre></li>
1913
2238
  </ol>
1914
2239
 
2240
+ </div>
2241
+ </p>
1915
2242
 
1916
- </div>
1917
-
1918
- </div>
1919
2243
 
1920
- <h3 ><a id="usage.tutorial.implement-proto" href="#a-607941368">5.7.4</a> &nbsp; Implement the prototype</h3>
2244
+ <p>
2245
+ <hr style="display: none"/>
1921
2246
 
2247
+ <div id="usage.tutorial.implement-proto" class="section">
2248
+ <h3 class="title">
2249
+ <a href="#a-607106078">5.6.4</a>
1922
2250
 
1923
- <p>Now that we have a <a href="#glossary.specification">specification</a> against which to verify our <a href="#glossary.design">design</a>, let us build a prototype of our design. By doing so, we exercise our specification, experience potential problems that may arise when we later implement our design in Verilog, and gain confidence in our work. The result of this proceess is illustrated by <a href="#fig..counter_proto.rb">the example named &ldquo;Ruby prototype of our Verilog design&rdquo;</a>.</p>
2251
+ &nbsp;
1924
2252
 
2253
+ Implement the prototype
2254
+ </h3>
1925
2255
 
1926
- <div class="formal">
2256
+ <p>Now that we have a specification against which to verify our design let us build a prototype of our design. By doing so, we exercise our specification, experience potential problems that may arise when we later implement our design in Verilog, and gain confidence in our work. The result of this proceess is illustrated by <a href="#fig:counter_proto.rb">Example 8</a>.</p>
1927
2257
 
1928
- <div class="example" id="fig..counter_proto.rb">
1929
2258
 
1930
- <p class="title">Example 10. Ruby prototype of our Verilog design</p>
2259
+ <p>
2260
+ <hr style="display: none"/>
1931
2261
 
2262
+ <div class="formal">
2263
+ <div class="example" id="fig:counter_proto.rb">
2264
+
1932
2265
 
1933
- <pre class="code"><span style="color:#888"># This is a prototype of the design under test.</span>
2266
+ <p class="title"><a href="#a-607102138">Example 8</a>. &nbsp; Ruby prototype of our Verilog design</p>
1934
2267
 
1935
- <span style="color:#888"># When prototyping is enabled, Vpi::advance_time invokes this</span>
1936
- <span style="color:#888"># method instead of transferring control to the Verilog simulator.</span>
1937
- <span style="color:#080; font-weight:bold">def</span> <span style="color:#036; font-weight:bold">Counter</span>.simulate!
2268
+ <pre class="code"><span style="color:#888"># Ruby prototype of the design under test's Verilog implementation.</span>
2269
+ <span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">feign!</span>
1938
2270
  <span style="color:#080; font-weight:bold">if</span> clock.posedge?
1939
- <span style="color:#080; font-weight:bold">if</span> reset.intVal == <span style="color:#00D; font-weight:bold">1</span>
2271
+ <span style="color:#080; font-weight:bold">if</span> reset.high?
1940
2272
  count.intVal = <span style="color:#00D; font-weight:bold">0</span>
1941
2273
  <span style="color:#080; font-weight:bold">else</span>
1942
2274
  count.intVal += <span style="color:#00D; font-weight:bold">1</span>
@@ -1944,131 +2276,135 @@ context <span style="background-color:#fff0f0"><span style="color:#710">&quot;</
1944
2276
  <span style="color:#080; font-weight:bold">end</span>
1945
2277
  <span style="color:#080; font-weight:bold">end</span>
1946
2278
  </pre>
2279
+ </div>
2280
+ </div>
2281
+
2282
+ Before we continue, replace the contents of the files named <tt>RSpec/counter_proto.rb</tt> and <tt>xUnit/counter_proto.rb</tt> with the source code shown in <a href="#fig:counter_proto.rb">Example 8</a>.</p>
1947
2283
 
1948
- </div>
1949
-
1950
- </div>
1951
-
1952
- <div class="admonition">
1953
-
1954
- <div class="important" id="important3">
1955
-
1956
- <p style="float:left"><img src="images/tango/important.png" title="important" alt="important" /></p>
1957
-
1958
-
1959
- <p class="title">Important: Before we continue&#8230;</p>
1960
-
1961
-
1962
- <p>Replace the contents of the files named <tt>counter_rspec_proto.rb</tt> and <tt>counter_xunit_proto.rb</tt> with the source code shown in <a href="#fig..counter_proto.rb">the example named &ldquo;Ruby prototype of our Verilog design&rdquo;</a></p>
1963
-
1964
-
1965
- </div>
1966
-
1967
- </div>
2284
+ </div>
2285
+ </p>
1968
2286
 
1969
- <h3 ><a id="usage.tutorial.test-proto" href="#a-607942708">5.7.5</a> &nbsp; Verify the prototype</h3>
1970
2287
 
2288
+ <p>
2289
+ <hr style="display: none"/>
1971
2290
 
1972
- <p>Now that we have implemented our prototype, we are ready to verify it against our <a href="#glossary.specification">specification</a> by running the <a href="#glossary.test">test</a>. This process is illustrated by <a href="#fig..test-proto.rspec">the example named &ldquo;Running a test with specification in rSpec format&rdquo;</a> and <a href="#fig..test-proto.unit-test">the example named &ldquo;Running a test with specification in xUnit format&rdquo;</a>.</p>
2291
+ <div id="usage.tutorial.test-proto" class="section">
2292
+ <h3 class="title">
2293
+ <a href="#a-607132558">5.6.5</a>
1973
2294
 
2295
+ &nbsp;
1974
2296
 
1975
- <p>In these examples, the <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> environment variable is assigned a non-empty value while running the test so that, instead of our design, our prototype is verified against our specification. You can also assign a value to <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> before running the test, by using your shell&#8217;s <strong>export</strong> or <strong>setenv</strong> command. Finally, the <a href="#setup.reqs"><span class="caps">GPL</span> Cver simulator</a>, denoted by <em>cver</em>, is used to run the simulation.</p>
2297
+ Verify the prototype
2298
+ </h3>
1976
2299
 
2300
+ <p>Now that we have implemented our prototype, we are ready to verify it against our specification by running the test This process is illustrated by <a href="#fig:test-proto.RSpec">Example 9</a> and <a href="#fig:test-proto.unit-test">Example 10</a>.</p>
1977
2301
 
1978
- <div class="formal">
1979
2302
 
1980
- <div class="example" id="fig..test-proto.rspec">
2303
+ <p>In these examples, the <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> environment variable is assigned the value 1 while running the test so that, instead of our design, our prototype is verified against our specification (see <a href="#usage.test-runner.env-vars">Section 5.3.1</a> for details). Also, the <a href="#setup.reqs">GPL Cver simulator</a> denoted by <em>cver</em>, is used to run the simulation.</p>
1981
2304
 
1982
- <p class="title">Example 11. Running a test with specification in rSpec format</p>
1983
2305
 
2306
+ <p>
2307
+ <hr style="display: none"/>
1984
2308
 
1985
- <pre>
1986
- $ rake -f counter_rspec_runner.rake cver PROTOTYPE=1
2309
+ <div class="formal">
2310
+ <div class="example" id="fig:test-proto.RSpec">
2311
+
1987
2312
 
1988
- Ruby-VPI: prototype has been enabled for test &quot;counter_rspec&quot;
2313
+ <p class="title"><a href="#a-607119008">Example 9</a>. &nbsp; Running a test with specification in RSpec format</p>
1989
2314
 
1990
- A resetted counter's value
1991
- - should be zero
1992
- - should increment by one count upon each rising clock edge
2315
+ <pre>
2316
+ $ cd RSpec
2317
+ $ rake cver PROTOTYPE=1
1993
2318
 
1994
- A counter with the maximum value
1995
- - should overflow upon increment
2319
+ Ruby-VPI: prototype is enabled
2320
+ ...
1996
2321
 
1997
- Finished in 0.018199 seconds
2322
+ Finished in 0.05106 seconds
1998
2323
 
1999
- 3 specifications, 0 failures
2324
+ 3 examples, 0 failures
2325
+ cd -
2000
2326
  </pre>
2327
+ </div>
2328
+ </div>
2329
+
2001
2330
 
2002
- </div>
2003
-
2004
- </div>
2005
-
2006
- <div class="formal">
2007
-
2008
- <div class="example" id="fig..test-proto.unit-test">
2009
-
2010
- <p class="title">Example 12. Running a test with specification in xUnit format</p>
2331
+ <hr style="display: none"/>
2011
2332
 
2333
+ <div class="formal">
2334
+ <div class="example" id="fig:test-proto.unit-test">
2335
+
2012
2336
 
2013
- <pre>
2014
- $ rake -f counter_xunit_runner.rake cver PROTOTYPE=1
2337
+ <p class="title"><a href="#a-607123158">Example 10</a>. &nbsp; Running a test with specification in xUnit format</p>
2015
2338
 
2016
- Ruby-VPI: prototype has been enabled for test &quot;counter_xunit&quot;
2339
+ <pre>
2340
+ $ cd xUnit
2341
+ $ rake cver PROTOTYPE=1
2017
2342
 
2018
- Loaded suite counter_xunit_bench
2343
+ Ruby-VPI: prototype is enabled
2344
+ Loaded suite counter
2019
2345
  Started
2020
2346
  ...
2021
- Finished in 0.040668 seconds.
2347
+ Finished in 0.043859 seconds.
2022
2348
 
2023
2349
  3 tests, 35 assertions, 0 failures, 0 errors
2024
2350
  </pre>
2351
+ </div>
2352
+ </div>
2353
+
2025
2354
 
2026
- </div>
2027
-
2028
- </div>
2029
-
2030
- <div class="admonition">
2031
-
2032
- <div class="tip" id="tip4">
2355
+ <hr style="display: none"/>
2033
2356
 
2034
- <p style="float:left"><img src="images/tango/tip.png" title="tip" alt="tip" /></p>
2357
+ <div class="admonition">
2358
+ <div class="tip" id="What_can_the_test_runner_do_">
2359
+ <img src="images/tango/tip.png" alt="tip" class="icon"/>
2035
2360
 
2361
+ <p class="title"><a href="#a-607126068">Tip 3</a>. &nbsp; What can the test runner do?</p>
2036
2362
 
2037
- <p class="title">Tip: What can the test runner do?</p>
2363
+ If you invoke the test runner (1) without any arguments or (2) with the <tt>--tasks</tt> option, it will show you a list of tasks that it can perform for you.
2364
+ </div>
2365
+ </div>
2366
+ </p>
2038
2367
 
2368
+ </div>
2369
+ </p>
2039
2370
 
2040
- <p>If you invoke the test runner (1) without any arguments or (2) with the <tt>--tasks</tt> option, it will show you a list of tasks that it can perform for you.</p>
2041
2371
 
2372
+ <p>
2373
+ <hr style="display: none"/>
2042
2374
 
2043
- </div>
2044
-
2045
- </div>
2375
+ <div id="usage.tutorial.implement-design" class="section">
2376
+ <h3 class="title">
2377
+ <a href="#a-607138718">5.6.6</a>
2046
2378
 
2047
- <h3 ><a id="usage.tutorial.implement-design" href="#a-607943958">5.7.6</a> &nbsp; Implement the design</h3>
2379
+ &nbsp;
2048
2380
 
2381
+ Implement the design
2382
+ </h3>
2049
2383
 
2050
- <p>Now that we have implemented and verified our prototype, we are ready to implement our <a href="#glossary.design">design</a>. This is often quite simple because we translate <em>existing</em> code from Ruby (our prototype) into Verilog (our design). The result of this process is illustrated by <a href="#fig..counter.v_impl">the example named &ldquo;Implementation of a simple up-counter with synchronous reset&rdquo;</a>.</p>
2384
+ <p>Now that we have implemented and verified our prototype, we are ready to implement our design This is often quite simple because we translate <em>existing</em> code from Ruby (our prototype) into Verilog (our design). The result of this process is illustrated by <a href="#fig:counter.v_impl">Example 11</a>.</p>
2051
2385
 
2052
2386
 
2053
- <div class="formal">
2387
+ <p>
2388
+ <hr style="display: none"/>
2054
2389
 
2055
- <div class="example" id="fig..counter.v_impl">
2390
+ <div class="formal">
2391
+ <div class="example" id="fig:counter.v_impl">
2392
+
2056
2393
 
2057
- <p class="title">Example 13. Implementation of a simple up-counter with synchronous reset</p>
2394
+ <p class="title"><a href="#a-607135238">Example 11</a>. &nbsp; Implementation of a simple up-counter with synchronous reset</p>
2058
2395
 
2059
-
2060
- <pre class="code" lang="verilog">/**
2396
+ <pre class="code" lang="verilog">/**
2061
2397
  A simple up-counter with synchronous reset.
2062
2398
 
2063
- @param Size Number of bits used to represent the counter's value.
2064
- @param clock Increments the counter's value upon each positive edge.
2065
- @param reset Zeroes the counter's value when asserted.
2066
- @param count The counter's value.
2399
+ @param Size Number of bits used to represent the counter's value.
2400
+ @param clock Increments the counter's value upon each positive edge.
2401
+ @param reset Zeroes the counter's value when asserted.
2402
+ @param count The counter's value.
2067
2403
  */
2068
2404
  module counter #(parameter Size = 5) (
2069
- input clock,
2070
- input reset,
2071
- output reg [Size - 1 : 0] count
2405
+ input clock,
2406
+ input reset,
2407
+ output reg [Size-1 : 0] count
2072
2408
  );
2073
2409
  always @(posedge clock) begin
2074
2410
  if (reset)
@@ -2078,105 +2414,136 @@ module counter #(parameter Size = 5) (
2078
2414
  end
2079
2415
  endmodule
2080
2416
  </pre>
2417
+ </div>
2418
+ </div>
2419
+
2420
+ Before we continue, replace the contents of the files named <tt>RSpec/counter.v</tt> and <tt>xUnit/counter.v</tt> with the source code shown in <a href="#fig:counter.v_impl">Example 11</a></p>
2081
2421
 
2082
- </div>
2083
-
2084
- </div>
2085
-
2086
- <div class="admonition">
2087
-
2088
- <div class="important" id="important4">
2089
-
2090
- <p style="float:left"><img src="images/tango/important.png" title="important" alt="important" /></p>
2422
+ </div>
2423
+ </p>
2091
2424
 
2092
2425
 
2093
- <p class="title">Important: Before we continue&#8230;</p>
2426
+ <p>
2427
+ <hr style="display: none"/>
2094
2428
 
2429
+ <div id="usage.tutorial.test-design" class="section">
2430
+ <h3 class="title">
2431
+ <a href="#a-607149178">5.6.7</a>
2095
2432
 
2096
- <p>Replace the contents of the file named <tt>counter.v</tt> with the source code shown in <a href="#fig..counter.v_impl">the example named &ldquo;Implementation of a simple up-counter with synchronous reset&rdquo;</a></p>
2433
+ &nbsp;
2097
2434
 
2435
+ Verify the design
2436
+ </h3>
2098
2437
 
2099
- </div>
2438
+ <p>Now that we have implemented our design we are ready to verify it against our specification by running the test <a href="#fig:test-design.RSpec">Example 12</a> and <a href="#fig:test-design.unit-test">Example 13</a> illustrate this process.</p>
2100
2439
 
2101
- </div>
2102
2440
 
2103
- <h3 ><a id="usage.tutorial.test-design" href="#a-607945338">5.7.7</a> &nbsp; Verify the design</h3>
2441
+ <p>In these examples, the <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> environment variable is <em>not</em> specified while running the test, so that our design, instead of our prototype, is verified against our specification. You can also achieve this effect by assigning an empty value to <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code>, or by using your shell&#8217;s <strong>unset</strong> command. Finally, the <a href="#setup.reqs">GPL Cver simulator</a> denoted by <em>cver</em>, is used to run the simulation.</p>
2104
2442
 
2105
2443
 
2106
- <p>Now that we have implemented our <a href="#glossary.design">design</a>, we are ready to verify it against our <a href="#glossary.specification">specification</a> by running the <a href="#glossary.test">test</a>. <a href="#fig..test-design.rspec">the example named &ldquo;Running a test with specification in rSpec format&rdquo;</a> and <a href="#fig..test-design.unit-test">the example named &ldquo;Running a test with specification in xUnit format&rdquo;</a> illustrate this process.</p>
2444
+ <p>
2445
+ <hr style="display: none"/>
2107
2446
 
2447
+ <div class="formal">
2448
+ <div class="example" id="fig:test-design.RSpec">
2449
+
2108
2450
 
2109
- <p>In these examples, the <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> environment variable is <em>not</em> specified while running the test, so that our design, instead of our prototype, is verified against our specification. You can also achieve this effect by assigning an empty value to <code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code>, or by using your shell&#8217;s <strong>unset</strong> command. Finally, the <a href="#setup.reqs"><span class="caps">GPL</span> Cver simulator</a>, denoted by <em>cver</em>, is used to run the simulation.</p>
2451
+ <p class="title"><a href="#a-607141778">Example 12</a>. &nbsp; Running a test with specification in RSpec format</p>
2110
2452
 
2453
+ <pre>
2454
+ $ cd RSpec
2455
+ $ rake cver
2111
2456
 
2112
- <div class="formal">
2457
+ ...
2113
2458
 
2114
- <div class="example" id="fig..test-design.rspec">
2459
+ Finished in 0.041198 seconds
2115
2460
 
2116
- <p class="title">Example 14. Running a test with specification in rSpec format</p>
2461
+ 3 examples, 0 failures
2462
+ </pre>
2463
+ </div>
2464
+ </div>
2465
+
2117
2466
 
2467
+ <hr style="display: none"/>
2118
2468
 
2119
- <pre>
2120
- $ rake -f counter_rspec_runner.rake cver
2469
+ <div class="formal">
2470
+ <div class="example" id="fig:test-design.unit-test">
2471
+
2121
2472
 
2122
- A resetted counter's value
2123
- - should be zero
2124
- - should increment by one count upon each rising clock edge
2473
+ <p class="title"><a href="#a-607144398">Example 13</a>. &nbsp; Running a test with specification in xUnit format</p>
2125
2474
 
2126
- A counter with the maximum value
2127
- - should overflow upon increment
2475
+ <pre>
2476
+ $ cd xUnit
2477
+ $ rake cver
2128
2478
 
2129
- Finished in 0.005628 seconds
2479
+ Loaded suite counter
2480
+ Started
2481
+ ...
2482
+ Finished in 0.040262 seconds.
2130
2483
 
2131
- 3 specifications, 0 failures
2484
+ 3 tests, 35 assertions, 0 failures, 0 errors
2132
2485
  </pre>
2486
+ </div>
2487
+ </div>
2488
+ </p>
2133
2489
 
2134
- </div>
2490
+ </div>
2491
+ </p>
2135
2492
 
2136
- </div>
2493
+ </div>
2494
+
2495
+ </div>
2496
+
2137
2497
 
2138
- <div class="formal">
2498
+ <hr style="display: none"/>
2139
2499
 
2140
- <div class="example" id="fig..test-design.unit-test">
2500
+ <div id="hacking" class="chapter">
2501
+ <h1 class="title">
2502
+ Chapter <a href="#a-607333248">6</a>
2141
2503
 
2142
- <p class="title">Example 15. Running a test with specification in xUnit format</p>
2504
+ <br/><br/>
2143
2505
 
2506
+ <big>Hacking</big>
2507
+ </h1>
2144
2508
 
2145
- <pre>
2146
- $ rake -f counter_xunit_runner.rake cver
2509
+ <p>
2510
+ <hr style="display: none"/>
2147
2511
 
2148
- Loaded suite counter_xunit_bench
2149
- Started
2150
- ...
2151
- Finished in 0.006766 seconds.
2512
+ <div id="hacking.scm" class="section">
2513
+ <h2 class="title">
2514
+ <a href="#a-607323788">6.1</a>
2152
2515
 
2153
- 3 tests, 35 assertions, 0 failures, 0 errors
2154
- </pre>
2516
+ &nbsp;
2155
2517
 
2156
- </div>
2518
+ Getting the source code
2519
+ </h2>
2157
2520
 
2158
- </div>
2521
+ Check out the source code using <a href="http://darcs.net">Darcs</a> from the project repository:
2159
2522
 
2160
- <h1 ><a id="hacking" href="#a-607946678">6</a> &nbsp; Hacking</h1>
2161
-
2162
-
2163
- <h2 ><a id="hacking.scm" href="#a-607947628">6.1</a> &nbsp; Getting the source code</h2>
2164
2523
 
2524
+ <pre>darcs get http://ruby-vpi.rubyforge.org/src/ruby-vpi</pre>
2165
2525
 
2166
- <p>Check out the source code using <a href="http://darcs.net">Darcs</a> from the project repository:</p>
2526
+ </div>
2527
+ </p>
2167
2528
 
2168
2529
 
2169
- <pre>darcs get http://ruby-vpi.rubyforge.org/src/ruby-vpi</pre>
2530
+ <p>
2531
+ <hr style="display: none"/>
2170
2532
 
2533
+ <div id="hacking.release-packages" class="section">
2534
+ <h2 class="title">
2535
+ <a href="#a-607326418">6.2</a>
2171
2536
 
2172
- <h2 ><a id="hacking.release-packages" href="#a-607948608">6.2</a> &nbsp; Building release packages</h2>
2537
+ &nbsp;
2173
2538
 
2539
+ Building release packages
2540
+ </h2>
2174
2541
 
2175
- <p>In addition to the <a href="#setup.reqs">normal requirements</a>, you need the following software to build release packages:</p>
2542
+ <p>In addition to the <a href="#setup.reqs">normal requirements</a> you need the following software to build release packages:</p>
2176
2543
 
2177
2544
 
2178
2545
  <ul>
2179
- <li><a href="http://www.swig.org/"><span class="caps">SWIG</span></a></li>
2546
+ <li><a href="http://www.swig.org/">SWIG</a></li>
2180
2547
  <li><a href="http://rubyforge.org/projects/redcloth/">RedCloth</a></li>
2181
2548
  <li><a href="http://rubyforge.org/projects/coderay/">CodeRay</a></li>
2182
2549
  </ul>
@@ -2184,261 +2551,404 @@ Finished in 0.006766 seconds.
2184
2551
 
2185
2552
  <p>Once you have satisfied these requirements, you can run <pre>rake release</pre> to build the release packages. Also, see the output of <pre>rake -T</pre> for more build options.</p>
2186
2553
 
2554
+ </div>
2555
+ </p>
2187
2556
 
2188
- <h1 ><a id="problems" href="#a-607949918">7</a> &nbsp; Known problems</h1>
2189
-
2190
-
2191
- <p>This chapter presents known problems and possible solutions. In addition, previously solved problems have been retained for historical reference.</p>
2192
-
2193
-
2194
- <h2 ><a id="problems.ruby" href="#a-607950878">7.1</a> &nbsp; Ruby</h2>
2195
-
2196
-
2197
- <h3 ><a id="problems.ruby.SystemStackError" href="#a-607951958">7.1.1</a> &nbsp; SystemStackError</h3>
2198
-
2199
-
2200
- <div class="admonition">
2201
-
2202
- <div class="note" id="note6">
2203
-
2204
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
2205
-
2206
-
2207
- <p class="title">Note: Fixed in 2.0.0.</p>
2208
-
2209
-
2210
- <p>This problem was fixed in release 2.0.0 (2006-04-17).</p>
2211
-
2212
-
2213
- </div>
2214
-
2215
- </div>
2216
-
2217
- <p>If a &#8220;stack level too deep (SystemStackError)&#8221; error occurs during the simulation, then increase the system-resource limit for stack-size by running the <pre>ulimit -s unlimited</pre> command before starting the simulation.</p>
2218
-
2219
-
2220
- <h3 ><a id="problems.ruby.xUnit" href="#a-607953298">7.1.2</a> &nbsp; test/unit</h3>
2221
2557
 
2558
+ <p>
2559
+ <hr style="display: none"/>
2222
2560
 
2223
- <div class="admonition">
2561
+ <div id="hacking.manual" class="section">
2562
+ <h2 class="title">
2563
+ <a href="#a-607328648">6.3</a>
2224
2564
 
2225
- <div class="note" id="note7">
2565
+ &nbsp;
2226
2566
 
2227
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
2567
+ Editing this manual
2568
+ </h2>
2228
2569
 
2570
+ The &#8220;doc&#8221; files inside the <tt>doc/</tt> directory are really <em>plain text</em> files that contain the source code of this manual. You can edit these files and run the <pre>rake</pre> command to automatically generate the HTML documentation you are currently viewing.
2229
2571
 
2230
- <p class="title">Note: Fixed in 2.0.0.</p>
2572
+ </div>
2573
+ </p>
2574
+ </div>
2575
+
2231
2576
 
2577
+ <hr style="display: none"/>
2232
2578
 
2233
- <p>This problem was fixed in release 2.0.0 (2006-04-17).</p>
2579
+ <div id="problems" class="chapter">
2580
+ <h1 class="title">
2581
+ Chapter <a href="#a-607380138">7</a>
2234
2582
 
2583
+ <br/><br/>
2235
2584
 
2236
- </div>
2585
+ <big>Known problems</big>
2586
+ </h1>
2237
2587
 
2238
- </div>
2588
+ <p>This chapter presents known problems and possible solutions.</p>
2239
2589
 
2240
- <p>If your specification employs Ruby&#8217;s unit testing framework, then you will encounter an error saying &#8220;[BUG] cross-thread violation on rb_gc()&#8221;.</p>
2241
2590
 
2591
+ <p>
2592
+ <hr style="display: none"/>
2242
2593
 
2243
- <h2 ><a id="problem.ivl" href="#a-607954508">7.2</a> &nbsp; Icarus Verilog</h2>
2594
+ <div id="problem.ivl" class="section">
2595
+ <h2 class="title">
2596
+ <a href="#a-607358828">7.1</a>
2244
2597
 
2598
+ &nbsp;
2245
2599
 
2246
- <h3 ><a id="problems.ivl.vpi_handle_by_name" href="#a-607955538">7.2.1</a> &nbsp; Vpi::vpi_handle_by_name</h3>
2600
+ Icarus Verilog
2601
+ </h2>
2247
2602
 
2603
+
2604
+ <hr style="display: none"/>
2248
2605
 
2249
- <h4 ><a id="problems.ivl.vpi_handle_by_name.absolute-paths" href="#a-607956978">7.2.1.1</a> &nbsp; Give full paths to Verilog objects</h4>
2606
+ <div id="problems.ivl.vpi_handle_by_name.absolute-paths" class="section">
2607
+ <h3 class="title">
2608
+ <a href="#a-607339198">7.1.1</a>
2250
2609
 
2610
+ &nbsp;
2251
2611
 
2252
- <p>In version 0.8 and snapshot 20061009 of Icarus Verilog, the <code class="code">vpi_handle_by_name</code> function requires an <em>absolute</em> path (including the name of the bench which instantiates the design) to a Verilog object. In addition, <code class="code">vpi_handle_by_name</code> always returns <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> when its second parameter is specified.</p>
2612
+ Give full paths to Verilog objects
2613
+ </h3>
2253
2614
 
2615
+ <p>In version 0.8 and snapshot 20061009 of Icarus Verilog, the <code class="code">vpi_handle_by_name</code> function requires an <em>absolute</em> path (including the name of the bench which instantiates the design) to a Verilog object. In addition, <code class="code">vpi_handle_by_name</code> always returns <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> when its second parameter is specified.</p>
2254
2616
 
2255
- <p>For example, consider <a href="#ex..TestFoo">the example named &ldquo;Part of a bench which instantiates a Verilog design&rdquo;</a>. Here, one must write <code class="code">vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">TestFoo.my_foo.clk</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span>)</code> instead of <code class="code">vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">my_foo.clk</span><span style="color:#710">&quot;</span></span>, <span style="color:#036; font-weight:bold">TestFoo</span>)</code> in order to access the <code class="code">clk</code> input of the <code class="code">my_foo</code> module instance.</p>
2256
2617
 
2618
+ <p>For example, consider <a href="#ex:TestFoo">Example 14</a>. Here, one must write <code class="code">vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">TestFoo.my_foo.clk</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span>)</code> instead of <code class="code">vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">my_foo.clk</span><span style="color:#710">&quot;</span></span>, <span style="color:#036; font-weight:bold">TestFoo</span>)</code> in order to access the <code class="code">clk</code> input of the <code class="code">my_foo</code> module instance.</p>
2257
2619
 
2258
- <div class="formal">
2259
2620
 
2260
- <div class="example" id="ex..TestFoo">
2621
+ <p>
2622
+ <hr style="display: none"/>
2261
2623
 
2262
- <p class="title">Example 16. Part of a bench which instantiates a Verilog design</p>
2624
+ <div class="formal">
2625
+ <div class="example" id="ex:TestFoo">
2626
+
2263
2627
 
2628
+ <p class="title"><a href="#a-607336038">Example 14</a>. &nbsp; Part of a bench which instantiates a Verilog design</p>
2264
2629
 
2265
- <pre class="code" lang="verilog">
2630
+ <pre class="code" lang="verilog">
2266
2631
  module TestFoo;
2267
2632
  reg clk_reg;
2268
2633
  Foo my_foo(.clk(clk_reg));
2269
2634
  endmodule
2270
2635
  </pre>
2636
+ </div>
2637
+ </div>
2638
+ </p>
2271
2639
 
2272
2640
  </div>
2641
+
2273
2642
 
2274
- </div>
2643
+ <hr style="display: none"/>
2275
2644
 
2276
- <h4 ><a id="problems.ivl.vpi_handle_by_name.connect-registers" href="#a-607958638">7.2.1.2</a> &nbsp; Registers must be connected</h4>
2645
+ <div id="problems.ivl.vpi_handle_by_name.connect-registers" class="section">
2646
+ <h3 class="title">
2647
+ <a href="#a-607348888">7.1.2</a>
2277
2648
 
2649
+ &nbsp;
2278
2650
 
2279
- <p>In version 0.8 of Icarus Verilog, if you want to access a register in a design, then it must be connected to something (either assigned to a wire or passed as a parameter to a module instantiation). Otherwise, you will get a <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> value as the result of <code class="code">vpi_handle_by_name</code> method.</p>
2651
+ Registers must be connected
2652
+ </h3>
2280
2653
 
2654
+ <p>In version 0.8 of Icarus Verilog, if you want to access a register in a design, then it must be connected to something (either assigned to a wire or passed as a parameter to a module instantiation). Otherwise, you will get a <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> value as the result of <code class="code">vpi_handle_by_name</code> method.</p>
2281
2655
 
2282
- <p>For example, suppose you wanted to access the <code class="code">clk_reg</code> register, from the bench shown in <a href="#ex..TestFoo_bad">the example named &ldquo;Bad design with unconnected registers&rdquo;</a> If you execute the statement <code class="code">clk_reg = vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">TestFoo.clk_reg</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span>)</code> in a specification, then you will discover that the <code class="code">vpi_handle_by_name</code> method returns <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> instead of a handle to the <code class="code">clk_reg</code> register.</p>
2283
2656
 
2657
+ <p>For example, suppose you wanted to access the <code class="code">clk_reg</code> register, from the bench shown in <a href="#ex:TestFoo_bad">Example 15</a> If you execute the statement <code class="code">clk_reg = vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">TestFoo.clk_reg</span><span style="color:#710">&quot;</span></span>, <span style="color:#038; font-weight:bold">nil</span>)</code> in a specification, then you will discover that the <code class="code">vpi_handle_by_name</code> method returns <code class="code"><span style="color:#038; font-weight:bold">nil</span></code> instead of a handle to the <code class="code">clk_reg</code> register.</p>
2284
2658
 
2285
- <p>The solution is to change the design such that it appears like the one shown in <a href="#ex..TestFoo_fix">the example named &ldquo;Fixed design with wired registers&rdquo;</a> where the register is connected to a wire, or <a href="#ex..TestFoo">the example named &ldquo;Part of a bench which instantiates a Verilog design&rdquo;</a> where the register is connected to a module instantiation.</p>
2286
2659
 
2660
+ <p>The solution is to change the design such that it appears like the one shown in <a href="#ex:TestFoo_fix">Example 16</a> where the register is connected to a wire, or <a href="#ex:TestFoo">Example 14</a> where the register is connected to a module instantiation.</p>
2287
2661
 
2288
- <div class="formal">
2289
2662
 
2290
- <div class="example" id="ex..TestFoo_bad">
2663
+ <p>
2664
+ <hr style="display: none"/>
2291
2665
 
2292
- <p class="title">Example 17. Bad design with unconnected registers</p>
2666
+ <div class="formal">
2667
+ <div class="example" id="ex:TestFoo_bad">
2668
+
2293
2669
 
2670
+ <p class="title"><a href="#a-607342098">Example 15</a>. &nbsp; Bad design with unconnected registers</p>
2294
2671
 
2295
- <pre class="code" lang="verilog">
2672
+ Here the <code class="code">clk_reg</code> register is not connected to anything.
2673
+
2674
+
2675
+ <pre class="code" lang="verilog">
2296
2676
  module TestFoo;
2297
2677
  reg clk_reg;
2298
2678
  endmodule
2299
2679
  </pre>
2680
+ </div>
2681
+ </div>
2682
+
2300
2683
 
2301
- <p>Here the <code class="code">clk_reg</code> register is not connected to anything.</p>
2302
-
2303
-
2304
- </div>
2305
-
2306
- </div>
2684
+ <hr style="display: none"/>
2307
2685
 
2308
- <div class="formal">
2686
+ <div class="formal">
2687
+ <div class="example" id="ex:TestFoo_fix">
2688
+
2309
2689
 
2310
- <div class="example" id="ex..TestFoo_fix">
2690
+ <p class="title"><a href="#a-607344538">Example 16</a>. &nbsp; Fixed design with wired registers</p>
2311
2691
 
2312
- <p class="title">Example 18. Fixed design with wired registers</p>
2692
+ Here the <code class="code">clk_reg</code> register is connected to the <code class="code">clk_wire</code> wire.
2313
2693
 
2314
2694
 
2315
- <pre class="code" lang="verilog">
2695
+ <pre class="code" lang="verilog">
2316
2696
  module TestFoo;
2317
2697
  reg clk_reg;
2318
2698
  wire clk_wire;
2319
2699
  assign clk_wire = clk_reg;
2320
2700
  endmodule
2321
2701
  </pre>
2702
+ </div>
2703
+ </div>
2704
+ </p>
2322
2705
 
2323
- <p>Here the <code class="code">clk_reg</code> register is connected to the <code class="code">clk_wire</code> wire.</p>
2324
-
2325
-
2326
- </div>
2327
-
2328
- </div>
2706
+ </div>
2329
2707
 
2330
- <h3 ><a id="problems.ivl.vpi_reset" href="#a-607960458">7.2.2</a> &nbsp; Vpi::reset</h3>
2331
2708
 
2709
+ </div>
2710
+
2332
2711
 
2333
- <p>In version 0.8 of Icarus Verilog, the <code class="code">vpi_control(vpiReset)</code> VPI function causes an assertion to fail inside the simulator. As a result, the simulation terminates and a core dump is produced.</p>
2712
+ <hr style="display: none"/>
2334
2713
 
2714
+ <div id="problems.ivl.vpi_reset" class="section">
2715
+ <h2 class="title">
2716
+ <a href="#a-607361048">7.2</a>
2335
2717
 
2336
- <h2 ><a id="problems.vsim" href="#a-607961718">7.3</a> &nbsp; Mentor Modelsim</h2>
2718
+ &nbsp;
2337
2719
 
2720
+ Vpi::reset
2721
+ </h2>
2338
2722
 
2339
- <h3 ><a id="problems.vsim.ruby_run" href="#a-607962798">7.3.1</a> &nbsp; ruby_run();</h3>
2723
+ In version 0.8 of Icarus Verilog, the <code class="code">vpi_control(vpiReset)</code> VPI function causes an assertion to fail inside the simulator. As a result, the simulation terminates and a core dump is produced.
2340
2724
 
2725
+ </div>
2726
+ </p>
2727
+ </div>
2728
+
2341
2729
 
2342
- <div class="admonition">
2730
+ <hr style="display: none"/>
2343
2731
 
2344
- <div class="note" id="note8">
2732
+ <div id="glossary" class="chapter">
2733
+ <h1 class="title">
2734
+ Chapter <a href="#a-607138038">8</a>
2345
2735
 
2346
- <p style="float:left"><img src="images/tango/note.png" title="note" alt="note" /></p>
2736
+ <br/><br/>
2347
2737
 
2738
+ <big>Glossary</big>
2739
+ </h1>
2348
2740
 
2349
- <p class="title">Note: Fixed in 2.0.0.</p>
2741
+
2742
+ <hr style="display: none"/>
2350
2743
 
2744
+ <div id="glossary.test" class="section">
2745
+ <h2 class="title">
2746
+ <a href="#a-607382968">8.1</a>
2351
2747
 
2352
- <p>This problem was fixed in release 2.0.0 (2006-04-17).</p>
2748
+ &nbsp;
2353
2749
 
2750
+ Test
2751
+ </h2>
2354
2752
 
2355
- </div>
2753
+ Something that checks if a <a href="#glossary.design">design</a> satisfies a <a href="#glossary.specification">specification</a>
2356
2754
 
2357
- </div>
2755
+ </div>
2756
+
2358
2757
 
2359
- <p>Version 6.1b of Mentor Modelsim doesn&#8217;t play nicely with either an embedded Ruby interpreter or <span class="caps">POSIX</span> threads in a <span class="caps">PLI</span> application. When Ruby-VPI invokes the ruby_run function (which starts the Ruby interpreter), the simulator terminates immediately with an exit status of 0.</p>
2758
+ <hr style="display: none"/>
2360
2759
 
2760
+ <div id="glossary.design" class="section">
2761
+ <h2 class="title">
2762
+ <a href="#a-607385468">8.2</a>
2361
2763
 
2362
- <h1 ><a id="glossary" href="#a-607964068">8</a> &nbsp; Glossary</h1>
2764
+ &nbsp;
2363
2765
 
2766
+ Design
2767
+ </h2>
2364
2768
 
2365
- <h2 ><a id="glossary.bench" href="#a-607965038">8.1</a> &nbsp; Bench</h2>
2769
+ A Verilog module that is verified against a <a href="#glossary.specification">specification</a> in order to ensure correctness or soundness of its being. In other words, it is the thing being checked: does it work or not?
2366
2770
 
2771
+ </div>
2772
+
2367
2773
 
2368
- <p>An environment in which a <a href="#glossary.design">design</a> is verified against a <a href="#glossary.specification">specification</a>. Often, it is used to emulate conditions in which the design will be eventually deployed.</p>
2774
+ <hr style="display: none"/>
2369
2775
 
2776
+ <div id="glossary.specification" class="section">
2777
+ <h2 class="title">
2778
+ <a href="#a-607076108">8.3</a>
2370
2779
 
2371
- <h2 ><a id="glossary.BDD" href="#a-607966068">8.2</a> &nbsp; Behavior driven development (BDD)</h2>
2780
+ &nbsp;
2372
2781
 
2782
+ Specification
2783
+ </h2>
2373
2784
 
2374
- <p>An <a href="http://agilemanifesto.org/">agile software development methodology</a> which emphasizes thinking in terms of behavior when designing, implementing, and verifying software.</p>
2785
+ A set of <a href="#glossary.expectation">expectations</a> which define the desired behavior of a <a href="#glossary.design">design</a> when it is subjected to certain stimulus.
2375
2786
 
2787
+ </div>
2788
+
2376
2789
 
2377
- <p>See the <a href="http://behaviour-driven.org/">official wiki</a> for more information.</p>
2790
+ <hr style="display: none"/>
2378
2791
 
2792
+ <div id="glossary.expectation" class="section">
2793
+ <h2 class="title">
2794
+ <a href="#a-607080598">8.4</a>
2379
2795
 
2380
- <h2 ><a id="glossary.design" href="#a-607967048">8.3</a> &nbsp; Design</h2>
2796
+ &nbsp;
2381
2797
 
2798
+ Expectation
2799
+ </h2>
2382
2800
 
2383
- <p>A Verilog module that is verified against a <a href="#glossary.specification">specification</a> in order to ensure correctness or soundness of its being. In other words, it is the thing being checked: does it work or not?</p>
2801
+ The desired response to some stimulus.
2384
2802
 
2803
+ </div>
2804
+
2385
2805
 
2386
- <h2 ><a id="glossary.expectation" href="#a-607968108">8.4</a> &nbsp; Expectation</h2>
2806
+ <hr style="display: none"/>
2387
2807
 
2808
+ <div id="glossary.handle" class="section">
2809
+ <h2 class="title">
2810
+ <a href="#a-607087288">8.5</a>
2388
2811
 
2389
- <p>The desired response to some stimulus.</p>
2812
+ &nbsp;
2390
2813
 
2814
+ Handle
2815
+ </h2>
2391
2816
 
2392
- <h2 ><a id="glossary.handle" href="#a-607969248">8.5</a> &nbsp; Handle</h2>
2817
+ A reference to an object inside the Verilog simulation. See <a href="#vpi.handles">Section 4.3.2</a> for usage instructions.
2393
2818
 
2819
+ </div>
2820
+
2394
2821
 
2395
- <p>A reference to an object inside the Verilog simulation that was obtained through the <code class="code">vpi_handle_by_name</code> function.</p>
2822
+ <hr style="display: none"/>
2396
2823
 
2824
+ <div id="glossary.rake" class="section">
2825
+ <h2 class="title">
2826
+ <a href="#a-607093708">8.6</a>
2397
2827
 
2398
- <h2 ><a id="glossary.rake" href="#a-607970298">8.6</a> &nbsp; Rake</h2>
2828
+ &nbsp;
2399
2829
 
2830
+ Rake
2831
+ </h2>
2400
2832
 
2401
- <blockquote>
2833
+ <blockquote>
2402
2834
  <p>Rake is a build tool, written in Ruby, using Ruby as a build language. Rake is similar to <strong>make</strong> in scope and purpose.</p>
2403
2835
  </blockquote>
2404
2836
 
2405
2837
 
2406
2838
  <p style="text-align:right;">&#8212;<a href="http://docs.rubyrake.org">Rake documentation</a></p>
2407
2839
 
2840
+ </div>
2841
+
2408
2842
 
2409
- <h2 ><a id="glossary.rspec" href="#a-607971318">8.7</a> &nbsp; rSpec</h2>
2843
+ <hr style="display: none"/>
2410
2844
 
2845
+ <div id="glossary.RSpec" class="section">
2846
+ <h2 class="title">
2847
+ <a href="#a-607099278">8.7</a>
2411
2848
 
2412
- <p>The <a href="#glossary.BDD"><span class="caps">BDD</span></a> framework for Ruby.</p>
2849
+ &nbsp;
2413
2850
 
2851
+ RSpec
2852
+ </h2>
2414
2853
 
2415
- <p>See the <a href="http://rspec.rubyforge.org">rSpec website</a> and <a href="http://rspec.rubyforge.org/tutorials/index.html">tutorial</a> for more information.</p>
2854
+ <p>The <a href="#glossary.BDD">BDD</a> framework for Ruby.</p>
2416
2855
 
2417
2856
 
2418
- <h2 ><a id="glossary.specification" href="#a-607972348">8.8</a> &nbsp; Specification</h2>
2857
+ <p>See the <a href="http://rspec.rubyforge.org">RSpec website</a> and <a href="http://rspec.rubyforge.org/tutorials/index.html">tutorial</a> for more information.</p>
2419
2858
 
2859
+ </div>
2860
+
2420
2861
 
2421
- <p>A set of <a href="#glossary.expectations">expectations</a> which define the desired behavior of a <a href="#glossary.design">design</a> when it is subjected to certain stimulus.</p>
2862
+ <hr style="display: none"/>
2422
2863
 
2864
+ <div id="glossary.TDD" class="section">
2865
+ <h2 class="title">
2866
+ <a href="#a-607104428">8.8</a>
2423
2867
 
2424
- <h2 ><a id="glossary.TDD" href="#a-607973538">8.9</a> &nbsp; Test driven development (TDD)</h2>
2868
+ &nbsp;
2425
2869
 
2870
+ Test driven development
2871
+ </h2>
2426
2872
 
2427
- <p>An <a href="http://agilemanifesto.org/">agile software development methodology</a> which emphasizes (1) testing functionality before implementing it and (2) refactoring.</p>
2873
+ <p>An <a href="http://agilemanifesto.org/">agile software development methodology</a> which emphasizes (1) testing functionality before implementing it and (2) refactoring.</p>
2428
2874
 
2429
2875
 
2430
2876
  <p>See <a href="http://www.agiledata.org/essays/tdd.html">this introductory article</a> for more information.</p>
2431
2877
 
2878
+ </div>
2879
+
2880
+
2881
+ <hr style="display: none"/>
2432
2882
 
2433
- <h2 ><a id="glossary.test" href="#a-607974518">9.0</a> &nbsp; Test</h2>
2883
+ <div id="glossary.BDD" class="section">
2884
+ <h2 class="title">
2885
+ <a href="#a-607113088">8.9</a>
2434
2886
 
2887
+ &nbsp;
2435
2888
 
2436
- <p>Something that checks if a <a href="#glossary.design">design</a> satisfies a <a href="#glossary.specification">specification</a>.</p>
2889
+ Behavior driven development
2890
+ </h2>
2437
2891
 
2892
+ <p>An <a href="http://agilemanifesto.org/">agile software development methodology</a> which emphasizes thinking in terms of behavior when designing, implementing, and verifying software.</p>
2438
2893
 
2439
- <h2 ><a id="glossary.test_bench" href="#a-607975528">9.1</a> &nbsp; Test bench</h2>
2440
2894
 
2895
+ <p>See the <a href="http://behaviour-driven.org/">official wiki</a> for more information.</p>
2896
+
2897
+ </div>
2898
+
2899
+ </div>
2900
+ </div>
2441
2901
 
2442
- <p>An allusion to <a href="#background.vocab">a bench in an electronics laboratory</a>, or so it seems.</p>
2443
- </body>
2902
+ <hr style="display: none"/>
2903
+ <div id="toc">
2904
+ <h1 id="toc:contents">Contents</h1>
2905
+ <ul><li><span class="hide">1 </span><a id="a-607611558" href="#Ruby-VPI_17.0.0_user_manual">Ruby-VPI 17.0.0 user manual</a><ul><li><span class="hide">1.1 </span><a id="a-607604718" href="#About_this_manual">About this manual</a></li><li><span class="hide">1.2 </span><a id="a-607607248" href="#Legal_notice">Legal notice</a></li></ul></li><li><span class="hide">2 </span><a id="a-607687748" href="#intro">Welcome</a><ul><li><span class="hide">2.1 </span><a id="a-607624238" href="#resources">Resources</a><ul><li><span class="hide">2.1.1 </span><a id="a-607614278" href="#Records">Records</a></li><li><span class="hide">2.1.2 </span><a id="a-607616618" href="#Documentation">Documentation</a></li><li><span class="hide">2.1.3 </span><a id="a-607619258" href="#Facilities">Facilities</a></li></ul></li><li><span class="hide">2.2 </span><a id="a-607636548" href="#intro.features">Features</a><ul><li><span class="hide">2.2.1 </span><a id="a-607626878" href="#Portable">Portable</a></li><li><span class="hide">2.2.2 </span><a id="a-607629278" href="#Agile">Agile</a></li><li><span class="hide">2.2.3 </span><a id="a-607631678" href="#Powerful">Powerful</a></li></ul></li><li><span class="hide">2.3 </span><a id="a-607648378" href="#intro.reqs">Requirements</a><ul><li><span class="hide">2.3.1 </span><a id="a-607639108" href="#Verilog_simulator">Verilog simulator</a></li><li><span class="hide">2.3.2 </span><a id="a-607641448" href="#Compilers">Compilers</a></li><li><span class="hide">2.3.3 </span><a id="a-607643748" href="#Libraries">Libraries</a></li></ul></li><li><span class="hide">2.4 </span><a id="a-607650938" href="#intro.applications">Applications</a></li><li><span class="hide">2.5 </span><a id="a-607653538" href="#intro.appetizers">Appetizers</a></li><li><span class="hide">2.6 </span><a id="a-607656258" href="#intro.license">License</a></li><li><span class="hide">2.7 </span><a id="a-607661648" href="#intro.related-works">Related works</a><ul><li><span class="hide">2.7.1 </span><a id="a-607658708" href="#intro.related-works.pli">Ye olde PLI</a></li></ul></li></ul></li><li><span class="hide">3 </span><a id="a-607728418" href="#setup">Setup</a><ul><li><span class="hide">3.1 </span><a id="a-607690938" href="#setup.manifest">Manifest</a></li><li><span class="hide">3.2 </span><a id="a-607696378" href="#setup.reqs">Requirements</a></li><li><span class="hide">3.3 </span><a id="a-607702548" href="#setup.recom">Recommendations</a><ul><li><span class="hide">3.3.1 </span><a id="a-607699208" href="#setup.recom.merger">Text merging tool</a></li></ul></li><li><span class="hide">3.4 </span><a id="a-607711698" href="#setup.inst">Installation</a><ul><li><span class="hide">3.4.1 </span><a id="a-607707638" href="#setup.inst.windows">Installing on Windows</a></li></ul></li><li><span class="hide">3.5 </span><a id="a-607713978" href="#setup.maintenance">Maintenance</a></li></ul></li><li><span class="hide">4 </span><a id="a-607211338" href="#organization">Organization</a><ul><li><span class="hide">4.1 </span><a id="a-607737308" href="#overview.relay">Ruby/Verilog interaction</a></li><li><span class="hide">4.2 </span><a id="a-607073988" href="#organization.tests">Tests</a></li><li><span class="hide">4.3 </span><a id="a-607153008" href="#VPI_in_Ruby">VPI in Ruby</a><ul><li><span class="hide">4.3.1 </span><a id="a-607082938" href="#Deviations_from_the_VPI_standard">Deviations from the VPI standard</a><ul><li><span class="hide">4.3.1.1 </span><a id="a-607076508" href="#Names_are_capitalized">Names are capitalized</a></li><li><span class="hide">4.3.1.2 </span><a id="a-607079008" href="#a_vprintf__is__printf_"><code class="code">vprintf</code> is <code class="code">printf</code></a></li></ul></li><li><span class="hide">4.3.2 </span><a id="a-607114548" href="#vpi.handles">Handles</a><ul><li><span class="hide">4.3.2.1 </span><a id="a-607085598" href="#Shortcuts_for_productivity">Shortcuts for productivity</a></li><li><span class="hide">4.3.2.2 </span><a id="a-607088158" href="#Accessing_a_handle_s_relatives">Accessing a handle&#8217;s relatives</a></li><li><span class="hide">4.3.2.3 </span><a id="a-607091098" href="#Accessing_a_handle_s_properties">Accessing a handle&#8217;s properties</a></li></ul></li><li><span class="hide">4.3.3 </span><a id="a-607126458" href="#vpi.callbacks">Callbacks</a></li></ul></li></ul></li><li><span class="hide">5 </span><a id="a-607321458" href="#usage">Usage</a><ul><li><span class="hide">5.1 </span><a id="a-607223668" href="#usage.prototyping">Prototyping</a><ul><li><span class="hide">5.1.1 </span><a id="a-607215768" href="#Getting_started">Getting started</a></li><li><span class="hide">5.1.2 </span><a id="a-607218048" href="#How_does_prototyping_work_">How does prototyping work?</a></li></ul></li><li><span class="hide">5.2 </span><a id="a-607229298" href="#usage.debugger">Debugging</a><ul><li><span class="hide">5.2.1 </span><a id="a-607226228" href="#usage.debugger.init">Advanced initialization</a></li></ul></li><li><span class="hide">5.3 </span><a id="a-607246068" href="#usage.test-runner">Test runner</a><ul><li><span class="hide">5.3.1 </span><a id="a-607238958" href="#usage.test-runner.env-vars">Environment variables</a><ul><li><span class="hide">5.3.1.1 </span><a id="a-607232388" href="#Variables_as_command-line_arguments">Variables as command-line arguments</a></li></ul></li></ul></li><li><span class="hide">5.4 </span><a id="a-607265218" href="#usage.tools">Tools</a><ul><li><span class="hide">5.4.1 </span><a id="a-607255398" href="#usage.tools.generate">Automated test generation</a></li><li><span class="hide">5.4.2 </span><a id="a-607257688" href="#usage.tools.convert">Verilog to Ruby conversion</a></li></ul></li><li><span class="hide">5.5 </span><a id="a-607267438" href="#usage.examples">Sample tests</a></li><li><span class="hide">5.6 </span><a id="a-607188458" href="#usage.tutorial">Tutorial</a><ul><li><span class="hide">5.6.1 </span><a id="a-607274848" href="#usage.tutorial.declare-design">Start with a Verilog design</a></li><li><span class="hide">5.6.2 </span><a id="a-607081228" href="#usage.tutorial.generate-test">Generate a test</a></li><li><span class="hide">5.6.3 </span><a id="a-607098358" href="#usage.tutorial.specification">Specify your expectations</a></li><li><span class="hide">5.6.4 </span><a id="a-607106078" href="#usage.tutorial.implement-proto">Implement the prototype</a></li><li><span class="hide">5.6.5 </span><a id="a-607132558" href="#usage.tutorial.test-proto">Verify the prototype</a></li><li><span class="hide">5.6.6 </span><a id="a-607138718" href="#usage.tutorial.implement-design">Implement the design</a></li><li><span class="hide">5.6.7 </span><a id="a-607149178" href="#usage.tutorial.test-design">Verify the design</a></li></ul></li></ul></li><li><span class="hide">6 </span><a id="a-607333248" href="#hacking">Hacking</a><ul><li><span class="hide">6.1 </span><a id="a-607323788" href="#hacking.scm">Getting the source code</a></li><li><span class="hide">6.2 </span><a id="a-607326418" href="#hacking.release-packages">Building release packages</a></li><li><span class="hide">6.3 </span><a id="a-607328648" href="#hacking.manual">Editing this manual</a></li></ul></li><li><span class="hide">7 </span><a id="a-607380138" href="#problems">Known problems</a><ul><li><span class="hide">7.1 </span><a id="a-607358828" href="#problem.ivl">Icarus Verilog</a><ul><li><span class="hide">7.1.1 </span><a id="a-607339198" href="#problems.ivl.vpi_handle_by_name.absolute-paths">Give full paths to Verilog objects</a></li><li><span class="hide">7.1.2 </span><a id="a-607348888" href="#problems.ivl.vpi_handle_by_name.connect-registers">Registers must be connected</a></li></ul></li><li><span class="hide">7.2 </span><a id="a-607361048" href="#problems.ivl.vpi_reset">Vpi::reset</a></li></ul></li><li><span class="hide">8 </span><a id="a-607138038" href="#glossary">Glossary</a><ul><li><span class="hide">8.1 </span><a id="a-607382968" href="#glossary.test">Test</a></li><li><span class="hide">8.2 </span><a id="a-607385468" href="#glossary.design">Design</a></li><li><span class="hide">8.3 </span><a id="a-607076108" href="#glossary.specification">Specification</a></li><li><span class="hide">8.4 </span><a id="a-607080598" href="#glossary.expectation">Expectation</a></li><li><span class="hide">8.5 </span><a id="a-607087288" href="#glossary.handle">Handle</a></li><li><span class="hide">8.6 </span><a id="a-607093708" href="#glossary.rake">Rake</a></li><li><span class="hide">8.7 </span><a id="a-607099278" href="#glossary.RSpec">RSpec</a></li><li><span class="hide">8.8 </span><a id="a-607104428" href="#glossary.TDD">Test driven development</a></li><li><span class="hide">8.9 </span><a id="a-607113088" href="#glossary.BDD">Behavior driven development</a></li></ul></li></ul>
2906
+
2907
+ <h1 id="toc:tip">Tips</h1>
2908
+ <ol>
2909
+ <li><a href="#Add_support_for_your_Verilog_simulator" id="a-607693408">Add support for your Verilog simulator</a></li>
2910
+ <li><a href="#Using__kdiff3__with_the_automated_test_generator." id="a-607251318">Using <strong>kdiff3</strong> with the automated test generator.</a></li>
2911
+ <li><a href="#What_can_the_test_runner_do_" id="a-607126068">What can the test runner do?</a></li>
2912
+ </ol>
2913
+ <h1 id="toc:note">Notes</h1>
2914
+ <ol>
2915
+ <li><a href="#Tuning_for_maximum_performance" id="a-607705108">Tuning for maximum performance</a></li>
2916
+ </ol>
2917
+ <h1 id="toc:caution">Cautions</h1>
2918
+ <ol>
2919
+ <li><a href="#Do_not_rename_generated_files" id="a-607248828">Do not rename generated files</a></li>
2920
+ </ol>
2921
+ <h1 id="toc:figure">Figures</h1>
2922
+ <ol>
2923
+ <li><a href="#fig:organization.detail" id="a-607731018">Where does Ruby-VPI fit in?</a></li>
2924
+ <li><a href="#fig:ruby_relay" id="a-607733828">Interaction between Ruby and Verilog</a></li>
2925
+ <li><a href="#fig:organization" id="a-607070888">Organization of a test in Ruby-VPI</a></li>
2926
+ <li><a href="#fig:method_naming_format" id="a-607093898">Method naming format for accessing a handle&#8217;s properties</a></li>
2927
+ </ol>
2928
+ <h1 id="toc:table">Tables</h1>
2929
+ <ol>
2930
+ <li><a href="#tbl:accessors" id="a-607096328">Possible accessors and their implications</a></li>
2931
+ <li><a href="#ex:properties" id="a-607099288">Examples of accessing a handle&#8217;s properties</a></li>
2932
+ </ol>
2933
+ <h1 id="toc:example">Examples</h1>
2934
+ <ol>
2935
+ <li><a href="#ex:callback" id="a-607121788">Using a callback for value change notification</a></li>
2936
+ <li><a href="#Running_a_test_with_environment_variables" id="a-607234788">Running a test with environment variables</a></li>
2937
+ <li><a href="#fig:counter.v_decl" id="a-607271338">Declaration of a simple up-counter with synchronous reset</a></li>
2938
+ <li><a href="#fig:generate-test.RSpec" id="a-607278188">Generating a test with specification in RSpec format</a></li>
2939
+ <li><a href="#fig:generate-test.xUnit" id="a-607073088">Generating a test with specification in xUnit format</a></li>
2940
+ <li><a href="#fig:RSpec_counter_spec.rb" id="a-607085368">Specification implemented in RSpec format</a></li>
2941
+ <li><a href="#fig:xUnit_counter_spec.rb" id="a-607089898">Specification implemented in xUnit format</a></li>
2942
+ <li><a href="#fig:counter_proto.rb" id="a-607102138">Ruby prototype of our Verilog design</a></li>
2943
+ <li><a href="#fig:test-proto.RSpec" id="a-607119008">Running a test with specification in RSpec format</a></li>
2944
+ <li><a href="#fig:test-proto.unit-test" id="a-607123158">Running a test with specification in xUnit format</a></li>
2945
+ <li><a href="#fig:counter.v_impl" id="a-607135238">Implementation of a simple up-counter with synchronous reset</a></li>
2946
+ <li><a href="#fig:test-design.RSpec" id="a-607141778">Running a test with specification in RSpec format</a></li>
2947
+ <li><a href="#fig:test-design.unit-test" id="a-607144398">Running a test with specification in xUnit format</a></li>
2948
+ <li><a href="#ex:TestFoo" id="a-607336038">Part of a bench which instantiates a Verilog design</a></li>
2949
+ <li><a href="#ex:TestFoo_bad" id="a-607342098">Bad design with unconnected registers</a></li>
2950
+ <li><a href="#ex:TestFoo_fix" id="a-607344538">Fixed design with wired registers</a></li>
2951
+ </ol>
2952
+ </div>
2953
+ </body>
2444
2954
  </html>