ruby-vpi 13.0.0 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -1
- data/bin/generate_test_tpl/bench.rb +84 -1
- data/bin/generate_test_tpl/bench.v +8 -17
- data/bin/generate_test_tpl/proto.rb +1 -1
- data/doc/common.css +14 -41
- data/doc/common.tpl +1 -1
- data/doc/figures/figures.dia +274 -753
- data/doc/figures/organization_detailed.png +0 -0
- data/doc/figures/ruby_relay.png +0 -0
- data/doc/history.html +363 -276
- data/doc/history.yml +40 -0
- data/doc/intro.inc +37 -15
- data/doc/lib/doc_proxy.rb +24 -4
- data/doc/manual.doc +345 -196
- data/doc/manual.html +741 -497
- data/doc/memo.doc +15 -15
- data/doc/memo.html +28 -27
- data/doc/readme.doc +2 -2
- data/doc/readme.html +51 -15
- data/doc/rss.erb +1 -1
- data/doc/rss.xml +1624 -31
- data/ext/Rakefile +1 -6
- data/ext/main.c +8 -3
- data/ext/main.h +5 -0
- data/ext/relay.c +12 -12
- data/ext/relay.h +1 -6
- data/ext/swig_vpi.i +2 -2
- data/ext/swig_wrap.cin +37 -20
- data/ext/verilog.h +2 -2
- data/ext/vlog.c +10 -3
- data/ext/vlog.h +4 -4
- data/lib/ruby-vpi/vpi.rb +114 -0
- data/lib/ruby-vpi.rb +21 -59
- data/ref/c/annotated.html +1 -1
- data/ref/c/common_8h.html +1 -1
- data/ref/c/files.html +1 -1
- data/ref/c/functions.html +1 -1
- data/ref/c/functions_vars.html +1 -1
- data/ref/c/globals.html +1 -1
- data/ref/c/globals_0x63.html +1 -1
- data/ref/c/globals_0x65.html +1 -1
- data/ref/c/globals_0x66.html +1 -1
- data/ref/c/globals_0x6d.html +3 -2
- data/ref/c/globals_0x70.html +1 -1
- data/ref/c/globals_0x72.html +4 -5
- data/ref/c/globals_0x73.html +1 -1
- data/ref/c/globals_0x74.html +1 -1
- data/ref/c/globals_0x76.html +4 -2
- data/ref/c/globals_0x78.html +1 -1
- data/ref/c/globals_defs.html +1 -1
- data/ref/c/globals_defs_0x65.html +1 -1
- data/ref/c/globals_defs_0x70.html +1 -1
- data/ref/c/globals_defs_0x76.html +1 -1
- data/ref/c/globals_defs_0x78.html +1 -1
- data/ref/c/globals_enum.html +1 -1
- data/ref/c/globals_eval.html +1 -1
- data/ref/c/globals_func.html +8 -7
- data/ref/c/globals_type.html +1 -1
- data/ref/c/globals_vars.html +3 -2
- data/ref/c/index.html +1 -1
- data/ref/c/main_8c.html +26 -1
- data/ref/c/main_8h.html +26 -1
- data/ref/c/relay_8c.html +11 -35
- data/ref/c/relay_8h.html +3 -27
- data/ref/c/structt__cb__data.html +1 -1
- data/ref/c/structt__vpi__delay.html +1 -1
- data/ref/c/structt__vpi__error__info.html +1 -1
- data/ref/c/structt__vpi__strengthval.html +1 -1
- data/ref/c/structt__vpi__systf__data.html +1 -1
- data/ref/c/structt__vpi__time.html +1 -1
- data/ref/c/structt__vpi__value.html +1 -1
- data/ref/c/structt__vpi__vecval.html +1 -1
- data/ref/c/structt__vpi__vlog__info.html +1 -1
- data/ref/c/verilog_8h.html +5 -5
- data/ref/c/vlog_8c.html +44 -6
- data/ref/c/vlog_8h.html +7 -8
- data/ref/c/vpi__user_8h.html +1 -1
- data/ref/ruby/classes/RDoc.html +5 -5
- data/ref/ruby/classes/RDoc.src/{M000041.html → M000045.html} +0 -0
- data/ref/ruby/classes/RubyVpi.html +10 -28
- data/ref/ruby/classes/RubyVpi.src/M000029.html +101 -124
- data/ref/ruby/classes/Vpi/Handle.html +56 -56
- data/ref/ruby/classes/Vpi/Handle.src/M000034.html +5 -9
- data/ref/ruby/classes/Vpi/Handle.src/M000035.html +5 -31
- data/ref/ruby/classes/Vpi/Handle.src/M000036.html +5 -74
- data/ref/ruby/classes/Vpi/Handle.src/M000037.html +5 -17
- data/ref/ruby/classes/Vpi/Handle.src/M000038.html +9 -11
- data/ref/ruby/classes/Vpi/Handle.src/M000039.html +44 -0
- data/ref/ruby/classes/Vpi/Handle.src/M000040.html +74 -55
- data/ref/ruby/classes/Vpi/Handle.src/M000041.html +30 -0
- data/ref/ruby/classes/Vpi/Handle.src/M000042.html +24 -0
- data/ref/ruby/classes/Vpi/Handle.src/M000044.html +68 -0
- data/ref/ruby/classes/Vpi.html +149 -0
- data/ref/ruby/classes/Vpi.src/M000030.html +28 -0
- data/ref/ruby/classes/Vpi.src/M000031.html +18 -0
- data/ref/ruby/classes/Vpi.src/M000032.html +39 -0
- data/ref/ruby/classes/Vpi.src/M000033.html +22 -0
- data/ref/ruby/created.rid +1 -1
- data/ref/ruby/files/lib/ruby-vpi/vpi_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi_rb.html +2 -2
- data/ref/ruby/fr_method_index.html +18 -14
- data/samp/counter/counter_rspec_bench.rb +81 -1
- data/samp/counter/counter_rspec_bench.v +5 -12
- data/samp/counter/counter_rspec_design.rb +1 -2
- data/samp/counter/counter_rspec_proto.rb +1 -1
- data/samp/counter/counter_rspec_spec.rb +3 -3
- data/samp/counter/counter_xunit_bench.rb +81 -1
- data/samp/counter/counter_xunit_bench.v +5 -12
- data/samp/counter/counter_xunit_design.rb +1 -2
- data/samp/counter/counter_xunit_proto.rb +1 -1
- data/samp/counter/counter_xunit_spec.rb +3 -3
- data/samp/pipelined_alu/hw5_unit_test_bench.rb +81 -1
- data/samp/pipelined_alu/hw5_unit_test_bench.v +11 -18
- data/samp/pipelined_alu/hw5_unit_test_design.rb +1 -1
- data/samp/pipelined_alu/hw5_unit_test_proto.rb +1 -1
- data/samp/pipelined_alu/hw5_unit_test_spec.rb +1 -1
- metadata +12 -9
- data/doc/figures/ruby_init.png +0 -0
- data/ext/swig_vpi.h +0 -924
- data/ref/ruby/classes/Vpi/Handle.src/M000030.html +0 -18
- data/ref/ruby/classes/Vpi/Handle.src/M000031.html +0 -18
- data/ref/ruby/classes/Vpi/Handle.src/M000032.html +0 -18
- data/ref/ruby/classes/Vpi/Handle.src/M000033.html +0 -18
data/doc/manual.html
CHANGED
@@ -12,141 +12,143 @@
|
|
12
12
|
|
13
13
|
<h1>Contents</h1>
|
14
14
|
<ul>
|
15
|
-
<li
|
15
|
+
<li>1 <a href="#anchor4">Ruby-VPI user manual</a>
|
16
16
|
<ul>
|
17
|
-
<li
|
17
|
+
<li>1.1 <a href="#terms">Terms</a></li>
|
18
18
|
</ul>
|
19
19
|
</li>
|
20
|
-
<li
|
20
|
+
<li>2 <a href="#intro">Introduction</a>
|
21
21
|
<ul>
|
22
|
-
<li
|
22
|
+
<li>2.1 <a href="#intro.features">Features</a>
|
23
23
|
<ul>
|
24
|
-
<li
|
25
|
-
<li
|
24
|
+
<li>2.1.1 <a href="#anchor5">Portable</a></li>
|
25
|
+
<li>2.1.2 <a href="#anchor6">Agile</a></li>
|
26
|
+
<li>2.1.3 <a href="#anchor7">Powerful</a></li>
|
27
|
+
<li>2.1.4 <a href="#anchor8">Free</a></li>
|
26
28
|
</ul>
|
27
29
|
</li>
|
28
|
-
<li
|
29
|
-
<li
|
30
|
+
<li>2.2 <a href="#intro.applications">Applications</a></li>
|
31
|
+
<li>2.3 <a href="#intro.appetizers">Appetizers</a></li>
|
32
|
+
<li>2.4 <a href="#intro.license">License</a></li>
|
33
|
+
<li>2.5 <a href="#intro.related-works">Related works</a>
|
30
34
|
<ul>
|
31
|
-
<li
|
35
|
+
<li>2.5.1 <a href="#intro.related-works.pli">Ye olde <span class="caps">PLI</span></a></li>
|
32
36
|
</ul>
|
33
37
|
</li>
|
34
38
|
</ul>
|
35
39
|
</li>
|
36
|
-
<li
|
40
|
+
<li>3 <a href="#background">Background</a>
|
37
41
|
<ul>
|
38
|
-
<li
|
39
|
-
<li
|
40
|
-
<li
|
41
|
-
|
42
|
-
<li><a href="#background.org.vpi">Interface to <span class="caps">VPI</span></a>
|
43
|
-
<ul>
|
44
|
-
<li><a href="#background.org.vpi.util"><span class="caps">VPI</span> utility layer</a></li>
|
42
|
+
<li>3.1 <a href="#background.methodology">Methodology</a></li>
|
43
|
+
<li>3.2 <a href="#background.vocab">Terminology</a></li>
|
44
|
+
<li>3.3 <a href="#background.org">Organization</a></li>
|
45
|
+
<li>3.4 <a href="#background.relay">Ruby/Verilog interaction</a></li>
|
45
46
|
</ul>
|
46
47
|
</li>
|
48
|
+
<li>4 <a href="#setup">Setup</a>
|
49
|
+
<ul>
|
50
|
+
<li>4.1 <a href="#setup.manifest">Manifest</a></li>
|
51
|
+
<li>4.2 <a href="#setup.reqs">Requirements</a></li>
|
52
|
+
<li>4.3 <a href="#setup.recom">Recommendations</a>
|
53
|
+
<ul>
|
54
|
+
<li>4.3.1 <a href="#setup.recom.merger">Text merging tool</a></li>
|
47
55
|
</ul>
|
48
56
|
</li>
|
49
|
-
<li
|
57
|
+
<li>4.4 <a href="#setup.installation">Installation</a>
|
50
58
|
<ul>
|
51
|
-
<li
|
52
|
-
<li><a href="#background.running-tests.exec">Execution</a></li>
|
59
|
+
<li>4.4.1 <a href="#setup.installation.windows">Installing on Windows</a></li>
|
53
60
|
</ul>
|
54
61
|
</li>
|
62
|
+
<li>4.5 <a href="#setup.maintenance">Maintenance</a></li>
|
55
63
|
</ul>
|
56
64
|
</li>
|
57
|
-
<li
|
65
|
+
<li>5 <a href="#usage">Usage</a>
|
58
66
|
<ul>
|
59
|
-
<li
|
60
|
-
<li><a href="#setup.reqs">Requirements</a></li>
|
61
|
-
<li><a href="#setup.recom">Recommendations</a>
|
67
|
+
<li>5.1 <a href="#usage.vpi"><span class="caps">VPI</span> in Ruby</a>
|
62
68
|
<ul>
|
63
|
-
<li
|
64
|
-
</ul>
|
65
|
-
</li>
|
66
|
-
<li><a href="#setup.installation">Installation</a>
|
69
|
+
<li>5.1.1 <a href="#usage.vpi.handles">Handles</a>
|
67
70
|
<ul>
|
68
|
-
<li
|
71
|
+
<li>5.1.1.1 <a href="#anchor9">Accessing a handle’s relatives</a></li>
|
72
|
+
<li>5.1.1.2 <a href="#anchor10">Accessing a handle’s properties</a></li>
|
69
73
|
</ul>
|
70
74
|
</li>
|
71
|
-
<li
|
75
|
+
<li>5.1.2 <a href="#usage.vpi.callbacks">Callbacks</a></li>
|
72
76
|
</ul>
|
73
77
|
</li>
|
74
|
-
<li
|
75
|
-
<ul>
|
76
|
-
<li><a href="#usage.tools">Tools</a>
|
78
|
+
<li>5.2 <a href="#usage.debugger">Debugging</a>
|
77
79
|
<ul>
|
78
|
-
<li
|
79
|
-
<li><a href="#usage.tools.verilog-ruby-conv">Verilog to Ruby conversion</a></li>
|
80
|
+
<li>5.2.1 <a href="#usage.debugger.init">Advanced initialization</a></li>
|
80
81
|
</ul>
|
81
82
|
</li>
|
82
|
-
<li
|
83
|
-
<ul>
|
84
|
-
<li
|
85
|
-
<li><a href="#usage.tutorial.generate-test">Generate a test</a></li>
|
86
|
-
<li><a href="#usage.tutorial.specification">Specify your expectations</a></li>
|
87
|
-
<li><a href="#usage.tutorial.implement-proto">Implement the prototype</a></li>
|
88
|
-
<li><a href="#usage.tutorial.test-proto">Verify the prototype</a></li>
|
89
|
-
<li><a href="#usage.tutorial.implement-design">Implement the design</a></li>
|
90
|
-
<li><a href="#usage.tutorial.test-design">Verify the design</a></li>
|
83
|
+
<li>5.3 <a href="#usage.test-runner">Test runner</a>
|
84
|
+
<ul>
|
85
|
+
<li>5.3.1 <a href="#usage.test-runner.env-vars">Environment variables</a></li>
|
91
86
|
</ul>
|
92
87
|
</li>
|
93
|
-
<li
|
88
|
+
<li>5.4 <a href="#usage.examples">Sample tests</a></li>
|
89
|
+
<li>5.5 <a href="#usage.tools">Tools</a>
|
94
90
|
<ul>
|
95
|
-
<li
|
91
|
+
<li>5.5.1 <a href="#usage.tools.generate-test">Automated test generation</a></li>
|
92
|
+
<li>5.5.2 <a href="#usage.tools.verilog-ruby-conv">Verilog to Ruby conversion</a></li>
|
96
93
|
</ul>
|
97
94
|
</li>
|
98
|
-
<li
|
99
|
-
<ul>
|
100
|
-
<li
|
95
|
+
<li>5.6 <a href="#usage.tutorial">Tutorial</a>
|
96
|
+
<ul>
|
97
|
+
<li>5.6.1 <a href="#usage.tutorial.declare-design">Start with a design</a></li>
|
98
|
+
<li>5.6.2 <a href="#usage.tutorial.generate-test">Generate a test</a></li>
|
99
|
+
<li>5.6.3 <a href="#usage.tutorial.specification">Specify your expectations</a></li>
|
100
|
+
<li>5.6.4 <a href="#usage.tutorial.implement-proto">Implement the prototype</a></li>
|
101
|
+
<li>5.6.5 <a href="#usage.tutorial.test-proto">Verify the prototype</a></li>
|
102
|
+
<li>5.6.6 <a href="#usage.tutorial.implement-design">Implement the design</a></li>
|
103
|
+
<li>5.6.7 <a href="#usage.tutorial.test-design">Verify the design</a></li>
|
101
104
|
</ul>
|
102
105
|
</li>
|
103
|
-
<li><a href="#usage.examples">Sample tests</a></li>
|
104
106
|
</ul>
|
105
107
|
</li>
|
106
|
-
<li
|
108
|
+
<li>6 <a href="#hacking">Hacking</a>
|
107
109
|
<ul>
|
108
|
-
<li
|
110
|
+
<li>6.1 <a href="#hacking.release-packages">Building release packages</a></li>
|
109
111
|
</ul>
|
110
112
|
</li>
|
111
|
-
<li
|
113
|
+
<li>7 <a href="#problems">Known problems</a>
|
112
114
|
<ul>
|
113
|
-
<li
|
115
|
+
<li>7.1 <a href="#problems.ruby">Ruby</a>
|
114
116
|
<ul>
|
115
|
-
<li
|
116
|
-
<li
|
117
|
+
<li>7.1.1 <a href="#problems.ruby.SystemStackError">SystemStackError</a></li>
|
118
|
+
<li>7.1.2 <a href="#problems.ruby.xUnit">test/unit</a></li>
|
117
119
|
</ul>
|
118
120
|
</li>
|
119
|
-
<li
|
121
|
+
<li>7.2 <a href="#problem.ivl">Icarus Verilog</a>
|
120
122
|
<ul>
|
121
|
-
<li
|
123
|
+
<li>7.2.1 <a href="#problems.ivl.vpi_handle_by_name">Vpi::vpi_handle_by_name</a>
|
122
124
|
<ul>
|
123
|
-
<li
|
124
|
-
<li
|
125
|
+
<li>7.2.1.1 <a href="#problems.ivl.vpi_handle_by_name.absolute-paths">Give full paths to Verilog objects</a></li>
|
126
|
+
<li>7.2.1.2 <a href="#problems.ivl.vpi_handle_by_name.connect-registers">Registers must be connected</a></li>
|
125
127
|
</ul>
|
126
128
|
</li>
|
127
|
-
<li
|
129
|
+
<li>7.2.2 <a href="#problems.ivl.vpi_reset">Vpi::reset</a></li>
|
128
130
|
</ul>
|
129
131
|
</li>
|
130
|
-
<li
|
132
|
+
<li>7.3 <a href="#problems.vsim">Mentor Modelsim</a>
|
131
133
|
<ul>
|
132
|
-
<li
|
134
|
+
<li>7.3.1 <a href="#problems.vsim.ruby_run">ruby_run();</a></li>
|
133
135
|
</ul>
|
134
136
|
</li>
|
135
137
|
</ul>
|
136
138
|
</li>
|
137
|
-
<li
|
138
|
-
<ul>
|
139
|
-
<li
|
140
|
-
<li
|
141
|
-
<li
|
142
|
-
<li
|
143
|
-
<li
|
144
|
-
<li
|
145
|
-
<li
|
146
|
-
<li
|
147
|
-
<li
|
148
|
-
<li
|
149
|
-
<li
|
139
|
+
<li>8 <a href="#glossary">Glossary</a>
|
140
|
+
<ul>
|
141
|
+
<li>8.1 <a href="#glossary.bench">Bench</a></li>
|
142
|
+
<li>8.2 <a href="#glossary.BDD" title="BDD">Behavior driven development</a></li>
|
143
|
+
<li>8.3 <a href="#glossary.design">Design</a></li>
|
144
|
+
<li>8.4 <a href="#glossary.expectation">Expectation</a></li>
|
145
|
+
<li>8.5 <a href="#glossary.handle">Handle</a></li>
|
146
|
+
<li>8.6 <a href="#glossary.rake">Rake</a></li>
|
147
|
+
<li>8.7 <a href="#glossary.rspec">rSpec</a></li>
|
148
|
+
<li>8.8 <a href="#glossary.specification">Specification</a></li>
|
149
|
+
<li>8.9 <a href="#glossary.TDD" title="TDD">Test driven development</a></li>
|
150
|
+
<li>9.0 <a href="#glossary.test">Test</a></li>
|
151
|
+
<li>9.1 <a href="#glossary.test_bench">Test bench</a></li>
|
150
152
|
</ul></li>
|
151
153
|
</ul>
|
152
154
|
|
@@ -155,9 +157,9 @@
|
|
155
157
|
<h2>Tips</h2>
|
156
158
|
<ol>
|
157
159
|
<li><a href="#tip1">Add support for your Verilog simulator</a></li>
|
158
|
-
<li><a href="#tip2">
|
159
|
-
<li><a href="#tip3">
|
160
|
-
<li><a href="#tip4">
|
160
|
+
<li><a href="#tip2">Running multiple tests at once.</a></li>
|
161
|
+
<li><a href="#tip3">Using <strong>kdiff3</strong> with the automated test generator.</a></li>
|
162
|
+
<li><a href="#tip4">What can the test runner do?</a></li>
|
161
163
|
</ol>
|
162
164
|
<h2>Notes</h2>
|
163
165
|
<ol>
|
@@ -165,9 +167,10 @@
|
|
165
167
|
<li><a href="#note2">Undefined symbols in Windows</a></li>
|
166
168
|
<li><a href="#note3">note3</a></li>
|
167
169
|
<li><a href="#note4">note4</a></li>
|
168
|
-
<li><a href="#note5">
|
170
|
+
<li><a href="#note5">note5</a></li>
|
169
171
|
<li><a href="#note6">Fixed in 2.0.0.</a></li>
|
170
172
|
<li><a href="#note7">Fixed in 2.0.0.</a></li>
|
173
|
+
<li><a href="#note8">Fixed in 2.0.0.</a></li>
|
171
174
|
</ol>
|
172
175
|
<h2>Importants</h2>
|
173
176
|
<ol>
|
@@ -182,17 +185,20 @@
|
|
182
185
|
<ol>
|
183
186
|
<li><a href="#fig..organization">Overall organization of a test</a></li>
|
184
187
|
<li><a href="#fig..organization.detail">Detailed organization of a test</a></li>
|
185
|
-
<li><a href="#
|
186
|
-
<li><a href="#
|
187
|
-
<li><a href="#
|
188
|
+
<li><a href="#fig..ruby_relay">Interaction between Ruby and Verilog</a></li>
|
189
|
+
<li><a href="#figure4">Method naming format for accessing a handle’s properties</a></li>
|
190
|
+
<li><a href="#figure5">Output from <xref#ex..callback></a></li>
|
188
191
|
</ol>
|
189
192
|
<h2>Tables</h2>
|
190
193
|
<ol>
|
191
|
-
<li><a href="#
|
194
|
+
<li><a href="#tbl..accessors">Possible accessors and their implications</a></li>
|
192
195
|
</ol>
|
193
196
|
<h2>Examples</h2>
|
194
197
|
<ol>
|
195
|
-
<li><a href="#
|
198
|
+
<li><a href="#ex..properties">Examples of accessing a handle’s properties</a></li>
|
199
|
+
<li><a href="#ex..callback">Using a callback for value change notification</a></li>
|
200
|
+
<li><a href="#example3">Seeing what a test runner can do</a></li>
|
201
|
+
<li><a href="#example4">Running a test with environment variables</a></li>
|
196
202
|
<li><a href="#fig..counter.v_decl">Declaration of a simple up-counter with synchronous reset</a></li>
|
197
203
|
<li><a href="#fig..generate-test.rspec">Generating a test with specification in rSpec format</a></li>
|
198
204
|
<li><a href="#fig..generate-test.unit-test">Generating a test with specification in xUnit format</a></li>
|
@@ -204,44 +210,48 @@
|
|
204
210
|
<li><a href="#fig..counter.v_impl">Implementation of a simple up-counter with synchronous reset</a></li>
|
205
211
|
<li><a href="#fig..test-design.rspec">Running a test with specification in rSpec format</a></li>
|
206
212
|
<li><a href="#fig..test-design.unit-test">Running a test with specification in xUnit format</a></li>
|
207
|
-
<li><a href="#example13">Seeing what a test runner can do</a></li>
|
208
|
-
<li><a href="#example14">Running a test with environment variables</a></li>
|
209
213
|
<li><a href="#ex..TestFoo">Part of a bench which instantiates a Verilog design</a></li>
|
210
214
|
<li><a href="#ex..TestFoo_bad">Bad design with unconnected registers</a></li>
|
211
215
|
<li><a href="#ex..TestFoo_fix">Fixed design with wired registers</a></li>
|
212
216
|
</ol>
|
213
217
|
</div>
|
214
|
-
<
|
218
|
+
<h1 id="anchor4">1 Ruby-VPI user manual</h1>
|
215
219
|
|
216
|
-
<h1 id="anchor5">Ruby-VPI user manual</h1>
|
217
220
|
|
221
|
+
<p>This manual was last updated on Sat Dec 30 19:26:28 <span class="caps">PST 2006</span>.</p>
|
218
222
|
|
219
|
-
<p>Suraj N. Kurapati</p>
|
220
223
|
|
224
|
+
<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>
|
221
225
|
|
222
|
-
<p>Wed Dec 27 22:29:49 <span class="caps">PST 2006</span></p>
|
223
226
|
|
227
|
+
<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>
|
224
228
|
|
225
|
-
</div>
|
226
229
|
|
227
|
-
<
|
230
|
+
<p><em>Happy reading!</em></p>
|
231
|
+
|
232
|
+
|
233
|
+
<h2 id="terms">1.1 Terms</h2>
|
234
|
+
|
235
|
+
|
236
|
+
<p>Copyright© 2006 Suraj N. Kurapati.</p>
|
228
237
|
|
229
238
|
|
230
239
|
<p>Permission is granted to copy, distribute and/or modify this document under the terms of the <a href="http://www.gnu.org/copyleft/fdl.html"><span class="caps">GNU</span> Free Documentation License</a>, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the the file named <a href="./LICENSE"><span class="caps">LICENSE</span></a>.</p>
|
231
240
|
|
232
241
|
|
233
|
-
<p>
|
242
|
+
<p>The admonition and navigation graphics used in this manual are Copyright© 2005, 2006 <a href="http://tango.freedesktop.org">Tango Desktop Project</a> and are licensed under <a href="./images/LICENSE">these terms</a>.</p>
|
234
243
|
|
235
244
|
|
236
|
-
<h1 id="intro">Introduction</h1>
|
245
|
+
<h1 id="intro">2 Introduction</h1>
|
237
246
|
|
238
247
|
|
239
|
-
<
|
240
|
-
<p>Ruby-VPI is a <a href="http://www.ruby-lang.org">Ruby</a> interface to <a href="http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=33945">Verilog <span class="caps">VPI</span></a>. It lets you create complex Verilog test benches easily and wholly in Ruby.</p>
|
241
|
-
</blockquote>
|
248
|
+
<p>Ruby-VPI is a <a href="http://www.ruby-lang.org">Ruby</a> interface to <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>. It lets you create complex Verilog test benches easily and wholly in Ruby.</p>
|
242
249
|
|
243
250
|
|
244
|
-
<h2 id="intro.features">Features</h2>
|
251
|
+
<h2 id="intro.features">2.1 Features</h2>
|
252
|
+
|
253
|
+
|
254
|
+
<h3 id="anchor5">2.1.1 Portable</h3>
|
245
255
|
|
246
256
|
|
247
257
|
<ul>
|
@@ -252,11 +262,14 @@
|
|
252
262
|
<ul>
|
253
263
|
<li>Works with all <a href="manual.html#setup.reqs">major Verilog simulators</a> available today.
|
254
264
|
<ul>
|
255
|
-
<li>
|
265
|
+
<li>Compiled <em>just once</em> during <a href="manual.html#setup.installation">installation</a> and used forever!</li>
|
256
266
|
</ul></li>
|
257
267
|
</ul>
|
258
268
|
|
259
269
|
|
270
|
+
<h3 id="anchor6">2.1.2 Agile</h3>
|
271
|
+
|
272
|
+
|
260
273
|
<ul>
|
261
274
|
<li>Enables <a href="http://agilemanifesto.org/">agile practices</a> such as
|
262
275
|
<ul>
|
@@ -270,14 +283,18 @@
|
|
270
283
|
<ul>
|
271
284
|
<li>Eliminates unneccesary work:
|
272
285
|
<ul>
|
273
|
-
<li><a href="manual.html#usage.tutorial.specification">Specifications</a> are
|
286
|
+
<li><a href="manual.html#usage.tutorial.specification">Specifications</a> are readable, portable, and <em>executable</em>.</li>
|
274
287
|
<li>The <a href="manual.html#usage.tools.generate-test">automated test generator</a> helps you accomodate design changes with <em>minimal</em> effort.</li>
|
288
|
+
<li>There is absolutely <em>no compiling</em>!</li>
|
275
289
|
</ul></li>
|
276
290
|
</ul>
|
277
291
|
|
278
292
|
|
293
|
+
<h3 id="anchor7">2.1.3 Powerful</h3>
|
294
|
+
|
295
|
+
|
279
296
|
<ul>
|
280
|
-
<li>
|
297
|
+
<li>Inherits the <a href="http://www.ruby-lang.org/en/about/">power and elegance</a> of Ruby:
|
281
298
|
<ul>
|
282
299
|
<li>Unlimited length integers</li>
|
283
300
|
<li>Regular expressions</li>
|
@@ -288,29 +305,55 @@
|
|
288
305
|
</ul>
|
289
306
|
|
290
307
|
|
308
|
+
<ul>
|
309
|
+
<li>Uses <a href="http://rubyforge.org/projects/ruby-debug/">ruby-debug</a> for <a href="manual.html#usage.debugger">interactive debugging</a>.</li>
|
310
|
+
<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>
|
311
|
+
</ul>
|
312
|
+
|
313
|
+
|
314
|
+
<h3 id="anchor8">2.1.4 Free</h3>
|
315
|
+
|
316
|
+
|
291
317
|
<ul>
|
292
318
|
<li>Gives you the <em>freedom</em> to study, modify, and distribute this software, in accordance with the <a href="http://www.gnu.org/copyleft/gpl.html"><span class="caps">GNU</span> General Public License</a>.</li>
|
293
319
|
</ul>
|
294
320
|
|
295
321
|
|
296
|
-
<
|
322
|
+
<h2 id="intro.applications">2.2 Applications</h2>
|
297
323
|
|
298
324
|
|
299
|
-
<p>Here is a modest sampling of tasks
|
325
|
+
<p>Here is a modest sampling of tasks that Ruby-VPI can be used to perform.</p>
|
326
|
+
|
327
|
+
|
328
|
+
<ul>
|
329
|
+
<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>:
|
330
|
+
<ul>
|
331
|
+
<li>C language bus-functional models</li>
|
332
|
+
<li>Reading test vector files</li>
|
333
|
+
<li>Delay calculation</li>
|
334
|
+
<li>Custom output displays</li>
|
335
|
+
<li>Co-simulation</li>
|
336
|
+
<li>Design debug utilities</li>
|
337
|
+
<li>Simulation analysis</li>
|
338
|
+
</ul></li>
|
339
|
+
</ul>
|
300
340
|
|
301
341
|
|
342
|
+
<ul>
|
343
|
+
<li>Adapted from <a href="http://embedded.eecs.berkeley.edu/Alumni/pinhong/scriptEDA/">Pin Hong’s</a> observations:
|
302
344
|
<ul>
|
303
345
|
<li>Writing hardware models in Ruby</li>
|
304
|
-
<li>Dumping
|
305
|
-
<li>Dumping
|
346
|
+
<li>Dumping or processing netlist data from Verilog database</li>
|
347
|
+
<li>Dumping or processing simulation data</li>
|
306
348
|
<li>Feeding dynamic simulation stimuli</li>
|
307
349
|
<li>Back-annotating delay information</li>
|
308
350
|
<li>Interactive logic simulation</li>
|
309
351
|
<li>Building a distributed simulation</li>
|
352
|
+
</ul></li>
|
310
353
|
</ul>
|
311
354
|
|
312
355
|
|
313
|
-
<
|
356
|
+
<h2 id="intro.appetizers">2.3 Appetizers</h2>
|
314
357
|
|
315
358
|
|
316
359
|
<p>Here is a modest sampling of code to whet your appetite.</p>
|
@@ -352,17 +395,17 @@
|
|
352
395
|
|
353
396
|
|
354
397
|
<blockquote>
|
355
|
-
<p><code class="code"><span style="color:#00D; font-weight:bold">15</span>.times {
|
398
|
+
<p><code class="code"><span style="color:#00D; font-weight:bold">15</span>.times { simulate }</code></p>
|
356
399
|
</blockquote>
|
357
400
|
|
358
401
|
|
359
|
-
<h2 id="intro.license">License</h2>
|
402
|
+
<h2 id="intro.license">2.4 License</h2>
|
360
403
|
|
361
404
|
|
362
405
|
<p>Ruby-VPI is <a href="http://en.wikipedia.org/wiki/Free_software">free software</a> ; you can redistribute it and/or modify it under the terms of the <a href="http://www.gnu.org/copyleft/gpl.html"><span class="caps">GNU</span> General Public License</a> as published by the <a href="http://www.fsf.org">Free Software Foundation</a> ; either version 2 of the License, or (at your option) any later version.</p>
|
363
406
|
|
364
407
|
|
365
|
-
<h2 id="intro.related-works">Related works</h2>
|
408
|
+
<h2 id="intro.related-works">2.5 Related works</h2>
|
366
409
|
|
367
410
|
|
368
411
|
<ul>
|
@@ -374,7 +417,7 @@
|
|
374
417
|
</ul>
|
375
418
|
|
376
419
|
|
377
|
-
<h3 id="intro.related-works.pli">Ye olde <span class="caps">PLI</span></h3>
|
420
|
+
<h3 id="intro.related-works.pli">2.5.1 Ye olde <span class="caps">PLI</span></h3>
|
378
421
|
|
379
422
|
|
380
423
|
<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>
|
@@ -387,19 +430,16 @@
|
|
387
430
|
</ul>
|
388
431
|
|
389
432
|
|
390
|
-
<h1 id="background">Background</h1>
|
391
|
-
|
433
|
+
<h1 id="background">3 Background</h1>
|
392
434
|
|
393
|
-
<p>Ruby-VPI is a <a href="#glossary.bench">bench</a> which lets you <a href="#glossary.test">test</a> Verilog modules using the Ruby language.</p>
|
394
435
|
|
395
|
-
|
396
|
-
<h2 id="background.methodology">Methodology</h2>
|
436
|
+
<h2 id="background.methodology">3.1 Methodology</h2>
|
397
437
|
|
398
438
|
|
399
439
|
<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>
|
400
440
|
|
401
441
|
|
402
|
-
<h2 id="background.vocab">Terminology</h2>
|
442
|
+
<h2 id="background.vocab">3.2 Terminology</h2>
|
403
443
|
|
404
444
|
|
405
445
|
<div class="admonition">
|
@@ -418,7 +458,9 @@
|
|
418
458
|
</div>
|
419
459
|
|
420
460
|
</div>
|
421
|
-
|
461
|
+
|
462
|
+
<p>As a newcomer into the world of Verilog, I often heard the term <strong>test bench</strong>: “I ran the test bench, but it didn’t work!” or “Are you crazy?!! You <em>still</em> haven’t written the test bench?”, 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>
|
463
|
+
|
422
464
|
|
423
465
|
<p>Defeated, I turned to my inner faculties to determine the answer. Let’s see, the term <em>test bench</em> has the word <em>test</em>—so it has something to do with testing—and it has the word <em>bench</em>—so maybe it’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>
|
424
466
|
|
@@ -429,7 +471,7 @@ As a newcomer into the world of Verilog, I often heard the term <strong>test ben
|
|
429
471
|
<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’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>
|
430
472
|
|
431
473
|
|
432
|
-
<h2 id="background.org">Organization</h2>
|
474
|
+
<h2 id="background.org">3.3 Organization</h2>
|
433
475
|
|
434
476
|
|
435
477
|
<div class="formal">
|
@@ -445,12 +487,11 @@ As a newcomer into the world of Verilog, I often heard the term <strong>test ben
|
|
445
487
|
</div>
|
446
488
|
|
447
489
|
</div>
|
448
|
-
As <a href="#fig..organization">the figure named “Overall organization of a test”</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>.
|
449
490
|
|
450
|
-
<p>
|
491
|
+
<p>As <a href="#fig..organization">the figure named “Overall organization of a test”</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>
|
451
492
|
|
452
493
|
|
453
|
-
<
|
494
|
+
<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>
|
454
495
|
|
455
496
|
|
456
497
|
<div class="formal">
|
@@ -466,52 +507,331 @@ As <a href="#fig..organization">the figure named “Overall organization of
|
|
466
507
|
</div>
|
467
508
|
|
468
509
|
</div>
|
469
|
-
In <a href="#fig..organization.detail">the figure named “Detailed organization of a test”</a>, Ruby-VPI acts as the <em>bench</em>, a Verilog simulator encapsulates the <em>design</em>, and a Ruby interpreter encapsulates the <em>specification</em>.
|
470
510
|
|
471
|
-
<p>
|
511
|
+
<p>Now, let us take a more detailed look at this organization, as illustrated in <a href="#fig..organization.detail">the figure named “Detailed organization of a test”</a>.</p>
|
512
|
+
|
513
|
+
|
514
|
+
<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>
|
515
|
+
|
516
|
+
|
517
|
+
<h2 id="background.relay">3.4 Ruby/Verilog interaction</h2>
|
518
|
+
|
519
|
+
|
520
|
+
<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>
|
521
|
+
|
522
|
+
|
523
|
+
<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 “Interaction between Ruby and Verilog”</a>.</p>
|
524
|
+
|
525
|
+
|
526
|
+
<p>Ruby-VPI’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> & C approach is literally <em>backwards</em> because the design under test drives the specification.</p>
|
527
|
+
|
528
|
+
|
529
|
+
<div class="formal">
|
530
|
+
|
531
|
+
<div class="figure" id="fig..ruby_relay">
|
532
|
+
|
533
|
+
<p class="title">Figure 3. Interaction between Ruby and Verilog</p>
|
534
|
+
|
535
|
+
|
536
|
+
<p><img src="figures/ruby_relay.png" alt="" /></p>
|
537
|
+
|
538
|
+
|
539
|
+
<ol>
|
540
|
+
<li>The current simulation time is <em>X</em>.</li>
|
541
|
+
<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>
|
542
|
+
<li>The Verilog simulator is now in control (temporarily).</li>
|
543
|
+
<li>The current simulation time has <em>not</em> changed; it is still <em>X</em>.</li>
|
544
|
+
<li>The Verilog simulator simulates <em>Y</em> simulation time steps.</li>
|
545
|
+
<li>The current simulation time is now <em>X + Y</em>.</li>
|
546
|
+
<li>The Verilog simulator returns control back to the specification.</li>
|
547
|
+
</ol>
|
548
|
+
|
549
|
+
|
550
|
+
</div>
|
551
|
+
|
552
|
+
</div>
|
553
|
+
|
554
|
+
<h1 id="setup">4 Setup</h1>
|
472
555
|
|
473
556
|
|
474
|
-
<
|
557
|
+
<h2 id="setup.manifest">4.1 Manifest</h2>
|
558
|
+
|
559
|
+
|
560
|
+
<p>When you extract a release package, the following is what you would expect to find.</p>
|
475
561
|
|
476
562
|
|
477
563
|
<ul>
|
478
|
-
<li
|
564
|
+
<li><tt>doc</tt> contains user documentation in various formats.</li>
|
565
|
+
<li><tt>ref</tt> contains reference <span class="caps">API</span> documentation in <span class="caps">HTML</span> format.</li>
|
566
|
+
<li><tt>ext</tt> contains source code, written in the C language, for the <a href="#background.org">core of Ruby-VPI</a>.</li>
|
567
|
+
<li><tt>lib</tt> contains Ruby libraries provided by Ruby-VPI.</li>
|
568
|
+
<li><tt>bin</tt> contains various tools. See <a href="#usage.tools">the section named “Tools”</a> for more information.</li>
|
569
|
+
<li><tt>samp</tt> contains example tests. See <a href="#usage.examples">the section named “Sample tests”</a> for more information.</li>
|
479
570
|
</ul>
|
480
571
|
|
481
572
|
|
573
|
+
<h2 id="setup.reqs">4.2 Requirements</h2>
|
574
|
+
|
575
|
+
|
576
|
+
<p>The following software is necessary in order to use Ruby-VPI.</p>
|
577
|
+
|
578
|
+
|
579
|
+
<ul>
|
580
|
+
<li>Verilog simulator
|
581
|
+
– 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>.
|
482
582
|
<ul>
|
483
|
-
<li
|
583
|
+
<li><a href="http://www.pragmatic-c.com/gpl-cver/"><span class="caps">GPL</span> Cver</a>
|
584
|
+
– version 2.11a or newer is acceptable.</li>
|
585
|
+
<li><a href="http://www.icarus.com/eda/Verilog/">Icarus Verilog</a>
|
586
|
+
– version 0.8 is <em>mostly</em> acceptable—you <strong>will not</strong> be able to <a href="#background.org.vpi.util">access child handles through method calls</a>. The reason for this limitation is explained in <a href="#problems.ivl.vpi_handle_by_name.absolute-paths">the section named “Give full paths to Verilog objects”</a>.</li>
|
587
|
+
<li><a href="http://www.synopsys.com/products/simulation/simulation.html">Synopsys <span class="caps">VCS</span></a>
|
588
|
+
– any version that supports the <tt>-load</tt> option is acceptable.</li>
|
589
|
+
<li><a href="http://www.model.com">Mentor Modelsim</a>
|
590
|
+
– any version that supports the <tt>-pli</tt> option is acceptable.</li>
|
591
|
+
</ul></li>
|
484
592
|
</ul>
|
485
593
|
|
486
594
|
|
487
|
-
|
488
|
-
|
489
|
-
|
595
|
+
<div class="admonition">
|
596
|
+
|
597
|
+
<div class="tip" id="tip1">
|
598
|
+
|
599
|
+
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
600
|
+
|
601
|
+
|
602
|
+
<p class="title">Tip: Add support for your Verilog simulator</p>
|
603
|
+
|
604
|
+
|
605
|
+
<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>
|
606
|
+
|
607
|
+
|
608
|
+
</div>
|
609
|
+
|
610
|
+
</div>
|
611
|
+
|
612
|
+
<ul>
|
613
|
+
<li><strong>make</strong>
|
614
|
+
– any distribution should be acceptable.</li>
|
615
|
+
</ul>
|
616
|
+
|
617
|
+
|
618
|
+
<ul>
|
619
|
+
<li>C compiler
|
620
|
+
– 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>
|
621
|
+
</ul>
|
622
|
+
|
623
|
+
|
624
|
+
<ul>
|
625
|
+
<li><a href="http://en.wikipedia.org/wiki/Pthreads" title="pthreads"><span class="caps">POSIX</span> threads</a>
|
626
|
+
– header and linkable object files, and operating system support for this library are necessary.</li>
|
627
|
+
</ul>
|
628
|
+
|
629
|
+
|
630
|
+
<ul>
|
631
|
+
<li><a href="http://www.ruby-lang.org">Ruby</a>
|
632
|
+
– 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>
|
633
|
+
</ul>
|
634
|
+
|
635
|
+
|
636
|
+
<ul>
|
637
|
+
<li><a href="http://rubyforge.org/frs/?group_id=126">RubyGems</a>
|
638
|
+
– 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>
|
639
|
+
</ul>
|
640
|
+
|
641
|
+
|
642
|
+
<h2 id="setup.recom">4.3 Recommendations</h2>
|
643
|
+
|
490
644
|
|
645
|
+
<p>The following software may make your interactions with Ruby-VPI more pleasant.</p>
|
646
|
+
|
647
|
+
|
648
|
+
<h3 id="setup.recom.merger">4.3.1 Text merging tool</h3>
|
649
|
+
|
650
|
+
|
651
|
+
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.
|
652
|
+
<ul>
|
653
|
+
<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>
|
654
|
+
<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>
|
655
|
+
<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>
|
656
|
+
<li><a href="http://furius.ca/xxdiff/"><strong>xxdiff</strong></a> is a graphical, three-way merging tool.</li>
|
657
|
+
<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>
|
658
|
+
</ul>
|
491
659
|
|
492
|
-
|
493
|
-
<
|
494
|
-
|
495
|
-
|
660
|
+
|
661
|
+
<h2 id="setup.installation">4.4 Installation</h2>
|
662
|
+
|
663
|
+
|
664
|
+
<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>
|
665
|
+
|
666
|
+
|
667
|
+
<pre>
|
668
|
+
$ gem env gemdir
|
669
|
+
/usr/lib/ruby/gems/1.8
|
670
|
+
|
671
|
+
$ ls -d /usr/lib/ruby/gems/1.8/gems/ruby-vpi*
|
672
|
+
/usr/lib/ruby/gems/1.8/gems/ruby-vpi-7.0.0/
|
496
673
|
</pre>
|
497
674
|
|
498
|
-
<
|
675
|
+
<h3 id="setup.installation.windows">4.4.1 Installing on Windows</h3>
|
499
676
|
|
500
677
|
|
501
|
-
<
|
678
|
+
<ul>
|
679
|
+
<li>Install <a href="http://www.cygwin.com">Cygwin</a>, the Linux-like environment for Windows.</li>
|
680
|
+
</ul>
|
681
|
+
|
682
|
+
|
683
|
+
<div class="admonition">
|
684
|
+
|
685
|
+
<div class="note" id="note2">
|
686
|
+
|
687
|
+
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
688
|
+
|
689
|
+
|
690
|
+
<p class="title">Note: Undefined symbols in Windows</p>
|
691
|
+
|
692
|
+
|
693
|
+
<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>
|
694
|
+
|
695
|
+
|
696
|
+
<p>One solution is to supply the Verilog simulator’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>
|
502
697
|
|
503
698
|
|
504
|
-
|
699
|
+
</div>
|
505
700
|
|
701
|
+
</div>
|
506
702
|
|
507
|
-
<
|
703
|
+
<ul>
|
704
|
+
<li>Search for object files whose names end with <tt>.so</tt>, <tt>.o</tt>, or <tt>.dll</tt> in your Verilog simulator’s installation directory.</li>
|
705
|
+
</ul>
|
706
|
+
|
707
|
+
|
708
|
+
<ul>
|
709
|
+
<li>Determine which object files, among those found in the previous step, contain symbols whose names begin with “_vpi” by running the <pre>for x in *.{o,so,dll}; do nm $x | grep -q '[Tt] _vpi' && echo $x; done</pre> command in Cygwin.
|
710
|
+
<ul>
|
711
|
+
<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>
|
712
|
+
<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>
|
713
|
+
</ul></li>
|
714
|
+
</ul>
|
715
|
+
|
716
|
+
|
717
|
+
<ul>
|
718
|
+
<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’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>
|
719
|
+
</ul>
|
720
|
+
|
721
|
+
|
722
|
+
<ul>
|
723
|
+
<li>You may now install Ruby-VPI by running the <pre>gem install ruby-vpi</pre> command in Cygwin.</li>
|
724
|
+
</ul>
|
725
|
+
|
726
|
+
|
727
|
+
<h2 id="setup.maintenance">4.5 Maintenance</h2>
|
728
|
+
|
729
|
+
|
730
|
+
<ul>
|
731
|
+
<li>You can uninstall Ruby-VPI by running the <pre>gem uninstall ruby-vpi</pre> command.</li>
|
732
|
+
<li>You can upgrade to the latest release of Ruby-VPI by running the <pre>gem update ruby-vpi</pre> command.</li>
|
733
|
+
</ul>
|
734
|
+
|
735
|
+
|
736
|
+
<div class="admonition">
|
737
|
+
|
738
|
+
<div class="note" id="note3">
|
739
|
+
|
740
|
+
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
741
|
+
|
742
|
+
|
743
|
+
<p class="title">Note:</p>
|
744
|
+
|
745
|
+
|
746
|
+
<p>Learn more about using and manipulating RubyGems in <a href="http://www.rubygems.org">the RubyGems user manual</a>.</p>
|
747
|
+
|
748
|
+
|
749
|
+
</div>
|
750
|
+
|
751
|
+
</div>
|
752
|
+
|
753
|
+
<h1 id="usage">5 Usage</h1>
|
754
|
+
|
755
|
+
|
756
|
+
<h2 id="usage.vpi">5.1 <span class="caps">VPI</span> in Ruby</h2>
|
757
|
+
|
758
|
+
|
759
|
+
<p>The <em>entire</em> IEEE Std 1364-2005 <span class="caps">VPI</span> interface is available in Ruby, but with one minor difference: 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>
|
760
|
+
|
761
|
+
|
762
|
+
<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>
|
763
|
+
|
764
|
+
|
765
|
+
<p>Note that this capitalization rule does <strong>not</strong> apply to <span class="caps">VPI</span> functions; their names remain <em>unchanged</em> in Ruby.</p>
|
766
|
+
|
767
|
+
|
768
|
+
<h3 id="usage.vpi.handles">5.1.1 Handles</h3>
|
769
|
+
|
770
|
+
|
771
|
+
<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>
|
772
|
+
|
773
|
+
|
774
|
+
<div class="admonition">
|
775
|
+
|
776
|
+
<div class="note" id="note4">
|
777
|
+
|
778
|
+
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
779
|
+
|
780
|
+
|
781
|
+
<p class="title">Note:</p>
|
782
|
+
|
783
|
+
|
784
|
+
<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>
|
785
|
+
|
786
|
+
|
787
|
+
</div>
|
788
|
+
|
789
|
+
</div>
|
790
|
+
|
791
|
+
<p>Handles have various <em>properties</em>, which provide different kinds of information (see the “Kind of value accessed” column in <a href="#tbl..accessors">the table named “Possible accessors and their implications”</a>) about the underlying Verilog object represented by a handle. These properties are accessed through various functions, which are listed in the “VPI functions used to access the value” column in <a href="#tbl..accessors">the table named “Possible accessors and their implications”</a>.</p>
|
792
|
+
|
793
|
+
|
794
|
+
<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>
|
795
|
+
|
796
|
+
|
797
|
+
<p class="title">Shortcuts for productivity</p>
|
798
|
+
|
799
|
+
|
800
|
+
<p>Given a handle, Ruby-VPI allows you to access (1) its relatives and (2) its properties by simply invoking its methods.</p>
|
801
|
+
|
802
|
+
|
803
|
+
<p>If a handle’s relative happens to have the same name as one of the handle’s properties, then the relative is given preference. However, if you <em>really</em> need to access a handle’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>
|
804
|
+
|
805
|
+
|
806
|
+
<h4 id="anchor9">5.1.1.1 Accessing a handle’s relatives</h4>
|
807
|
+
|
808
|
+
|
809
|
+
<p>To access a handle’s relative (a handle related to it), simply invoke the relative’s name as a method on the handle.</p>
|
810
|
+
|
811
|
+
|
812
|
+
<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 “Declaration of a simple up-counter with synchronous reset”</a>, you would write the following:</p>
|
813
|
+
|
814
|
+
|
815
|
+
<pre class="code">
|
816
|
+
counter_module = vpi_handle_by_name(<span style="background-color:#fff0f0"><span style="color:#710">"</span><span style="color:#D20">counter</span><span style="color:#710">"</span></span>, <span style="color:#038; font-weight:bold">nil</span>)
|
817
|
+
|
818
|
+
reset_signal = counter_module.reset <span style="color:#888"># <== shortcut!</span>
|
819
|
+
</pre>
|
820
|
+
|
821
|
+
<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">"</span><span style="color:#D20">reset</span><span style="color:#710">"</span></span>, counter_module)</code>.</p>
|
822
|
+
|
823
|
+
|
824
|
+
<h4 id="anchor10">5.1.1.2 Accessing a handle’s properties</h4>
|
825
|
+
|
826
|
+
|
827
|
+
<p>To access a handle’s properties, invoke the proprty name, using the following format, as a method on the handle. <a href="#ex..properties">the example named “Examples of accessing a handle’s properties”</a> shows how this naming format is used.</p>
|
508
828
|
|
509
829
|
|
510
830
|
<div class="formal">
|
511
831
|
|
512
|
-
<div class="figure" id="
|
832
|
+
<div class="figure" id="figure4">
|
513
833
|
|
514
|
-
<p class="title">Figure
|
834
|
+
<p class="title">Figure 4. Method naming format for accessing a handle’s properties</p>
|
515
835
|
|
516
836
|
|
517
837
|
<table>
|
@@ -534,7 +854,7 @@ In <a href="#fig..organization.detail">the figure named “Detailed organiza
|
|
534
854
|
|
535
855
|
|
536
856
|
<ul>
|
537
|
-
<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
|
857
|
+
<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>
|
538
858
|
</ul>
|
539
859
|
|
540
860
|
|
@@ -544,21 +864,26 @@ In <a href="#fig..organization.detail">the figure named “Detailed organiza
|
|
544
864
|
|
545
865
|
|
546
866
|
<ul>
|
547
|
-
<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,
|
867
|
+
<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.
|
868
|
+
|
869
|
+
<p><a href="#tbl..accessors">the table named “Possible accessors and their implications”</a> shows a list of valid accessors and how they affect the access to a property.</p></li>
|
548
870
|
</ul>
|
549
871
|
|
550
872
|
|
551
873
|
<ul>
|
552
|
-
<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
|
874
|
+
<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.
|
875
|
+
|
876
|
+
<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>
|
553
877
|
</ul>
|
554
878
|
|
555
879
|
|
556
880
|
</div>
|
557
881
|
|
558
882
|
</div>
|
883
|
+
|
559
884
|
<div class="formal">
|
560
885
|
|
561
|
-
<div class="table" id="
|
886
|
+
<div class="table" id="tbl..accessors">
|
562
887
|
|
563
888
|
<p class="title">Table 1. Possible accessors and their implications</p>
|
564
889
|
|
@@ -607,11 +932,12 @@ In <a href="#fig..organization.detail">the figure named “Detailed organiza
|
|
607
932
|
</div>
|
608
933
|
|
609
934
|
</div>
|
935
|
+
|
610
936
|
<div class="formal">
|
611
937
|
|
612
|
-
<div class="example" id="
|
938
|
+
<div class="example" id="ex..properties">
|
613
939
|
|
614
|
-
<p class="title">Example 1. Examples of accessing a handle’s
|
940
|
+
<p class="title">Example 1. Examples of accessing a handle’s properties</p>
|
615
941
|
|
616
942
|
|
617
943
|
<table>
|
@@ -934,274 +1260,303 @@ In <a href="#fig..organization.detail">the figure named “Detailed organiza
|
|
934
1260
|
|
935
1261
|
</div>
|
936
1262
|
|
937
|
-
<
|
938
|
-
|
939
|
-
|
940
|
-
<p>Unlike an engineer who can verify an electronic component in real-time, the Verilog simulator and the Ruby interpreter (see <a href="#fig..organization.detail">the figure named “Detailed organization of a test”</a>) take turns working with <a href="#glossary.handle">handles</a> when a <a href="#glossary.test">test</a> is run. In particular, they take turns manipulating the Verilog <a href="#glossary.design">design</a> and transfer control to each other when appropriate.</p>
|
1263
|
+
<h3 id="usage.vpi.callbacks">5.1.2 Callbacks</h3>
|
941
1264
|
|
942
1265
|
|
943
|
-
<p>
|
944
|
-
|
945
|
-
|
946
|
-
<h3 id="background.running-tests.init">Initialization</h3>
|
947
|
-
|
948
|
-
|
949
|
-
<p>A <a href="#glossary.test">test</a> is first initialized before it is <a href="#background.running-tests.exec">executed</a>. This process is illustrated by <a href="#fig..ruby_init">the figure named “Initialization of a test”</a>.</p>
|
1266
|
+
<p>A <em>callback</em> is a mechanism that makes the Verilog simuluator execute a block of code, which is known as a “callback handler”, 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>
|
950
1267
|
|
951
1268
|
|
952
1269
|
<div class="formal">
|
953
1270
|
|
954
|
-
<div class="
|
1271
|
+
<div class="example" id="ex..callback">
|
955
1272
|
|
956
|
-
<p class="title">
|
1273
|
+
<p class="title">Example 2. Using a callback for value change notification</p>
|
957
1274
|
|
958
1275
|
|
959
|
-
<p><
|
1276
|
+
<p>This example shows how to use a callback for notification of changes in a handle’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>
|
960
1277
|
|
961
1278
|
|
962
|
-
<
|
963
|
-
<li>The Verilog simulator initializes the Ruby interpreter by invoking the <code class="code"><span style="color:#d70; font-weight:bold">$ruby_init</span>;</code> system task/function, whose parameters represent the command-line invocation of the Ruby interpreter. For example, one would specify <code class="code"><span style="color:#d70; font-weight:bold">$ruby_init</span>(<span style="background-color:#fff0f0"><span style="color:#710">"</span><span style="color:#D20">ruby</span><span style="color:#710">"</span></span>, <span style="background-color:#fff0f0"><span style="color:#710">"</span><span style="color:#D20">-w</span><span style="color:#710">"</span></span>);</code> in Verilog to achieve the same effect as running <pre>ruby -w</pre> at a command-prompt.</li>
|
964
|
-
<li>The Verilog simulator is paused and the Ruby interpreter is initialized with the arguments of the <code class="code"><span style="color:#d70; font-weight:bold">$ruby_init</span>;</code> system task/function.</li>
|
965
|
-
<li>When the Ruby interpreter invokes the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::relay_verilog</code> method, it is paused and the Verilog simulator is given control.</li>
|
966
|
-
</ol>
|
1279
|
+
<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 “Declaration of a simple up-counter with synchronous reset”</a>.</p>
|
967
1280
|
|
968
1281
|
|
969
|
-
|
970
|
-
|
971
|
-
</
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
<p>After a <a href="#glossary.test">test</a> is <a href="#background.running-tests.init">initialized</a>, it is executed such that the design is verified against the <a href="#glossary.specification">specification</a>. This process is illustrated by <a href="#fig..ruby_relay">the figure named “Execution of a test”</a>.</p>
|
977
|
-
|
1282
|
+
<pre class="code">
|
1283
|
+
cb_time = <span style="color:#036; font-weight:bold">S_vpi_time</span>.new
|
1284
|
+
cb_time.type = <span style="color:#036; font-weight:bold">VpiSimTime</span>
|
1285
|
+
cb_time.low = <span style="color:#00D; font-weight:bold">0</span>
|
1286
|
+
cb_time.high = <span style="color:#00D; font-weight:bold">0</span>
|
978
1287
|
|
979
|
-
<
|
1288
|
+
cb_value = <span style="color:#036; font-weight:bold">S_vpi_value</span>.new
|
1289
|
+
cb_value.format = <span style="color:#036; font-weight:bold">VpiIntVal</span>
|
980
1290
|
|
981
|
-
<
|
1291
|
+
cb_data = <span style="color:#036; font-weight:bold">S_cb_data</span>.new
|
1292
|
+
cb_data.reason = <span style="color:#036; font-weight:bold">CbValueChange</span>
|
1293
|
+
cb_data.obj = <span style="color:#036; font-weight:bold">Counter</span>.count
|
1294
|
+
cb_data.time = cb_time
|
1295
|
+
cb_data.value = cb_value
|
1296
|
+
cb_data.index = <span style="color:#00D; font-weight:bold">0</span>
|
982
1297
|
|
983
|
-
|
1298
|
+
cb_handle = vpi_register_cb(cb_data) <span style="color:#080; font-weight:bold">do</span> |data|
|
984
1299
|
|
1300
|
+
time = (data.time.high << <span style="color:#00D; font-weight:bold">32</span>) | data.time.low
|
1301
|
+
count = data.value.value.integer
|
985
1302
|
|
986
|
-
|
1303
|
+
puts <span style="background-color:#fff0f0"><span style="color:#710">"</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">"</span></span>
|
987
1304
|
|
1305
|
+
<span style="color:#080; font-weight:bold">end</span>
|
1306
|
+
</pre>
|
988
1307
|
|
989
|
-
<
|
990
|
-
<li>The Verilog simulator transfers control to the Ruby interpreter by invoking the <code class="code"><span style="color:#d70; font-weight:bold">$ruby_relay</span>;</code> system task/function.</li>
|
991
|
-
<li>The Verilog simulator is paused and the Ruby interpreter is given control.</li>
|
992
|
-
<li>When the Ruby interpreter invokes the <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::relay_verilog</code> method, it is paused and the Verilog simulator is given control.</li>
|
993
|
-
</ol>
|
1308
|
+
<p>To see this code in action, append it to the <tt>counter_rspec_spec.rb</tt> and <tt>counter_xunit_spec.rb</tt> files, which are provided in <a href="#usage.examples">the section named “Sample tests”</a> and discussed in <a href="#usage.tutorial.specification">the section named “Specify your expectations”</a>.</p>
|
994
1309
|
|
995
1310
|
|
996
1311
|
</div>
|
997
1312
|
|
998
1313
|
</div>
|
999
1314
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
<h2 id="setup.manifest">Manifest</h2>
|
1004
|
-
|
1005
|
-
|
1006
|
-
<p>When you extract a release package, the following is what you would expect to find.</p>
|
1007
|
-
|
1008
|
-
|
1009
|
-
<ul>
|
1010
|
-
<li><tt>doc</tt> contains user documentation in various formats.</li>
|
1011
|
-
<li><tt>ref</tt> contains reference <span class="caps">API</span> documentation in <span class="caps">HTML</span> format.</li>
|
1012
|
-
<li><tt>ext</tt> contains source code, written in the C language, for the <a href="#background.org">core of Ruby-VPI</a>.</li>
|
1013
|
-
<li><tt>lib</tt> contains Ruby libraries provided by Ruby-VPI.</li>
|
1014
|
-
<li><tt>bin</tt> contains various tools. See <a href="#usage.tools">the section named “Tools”</a> for more information.</li>
|
1015
|
-
<li><tt>samp</tt> contains example tests. See <a href="#usage.examples">the section named “Sample tests”</a> for more information.</li>
|
1016
|
-
</ul>
|
1315
|
+
<div class="formal">
|
1017
1316
|
|
1317
|
+
<div class="figure" id="figure5">
|
1018
1318
|
|
1019
|
-
<
|
1319
|
+
<p class="title">Figure 5. Output from <a href="#ex..callback">the example named “Using a callback for value change notification”</a></p>
|
1020
1320
|
|
1021
1321
|
|
1022
|
-
<p>
|
1322
|
+
<p>Shown below is the output from running the <a href="#usage.tutorial">counter_rspec test</a> after appending the code shown in <a href="#ex..callback">the example named “Using a callback for value change notification”</a> to the <tt>counter_rspec_spec.rb</tt> file.</p>
|
1023
1323
|
|
1024
1324
|
|
1025
|
-
|
1026
|
-
|
1027
|
-
– 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>.
|
1028
|
-
<ul>
|
1029
|
-
<li><a href="http://www.pragmatic-c.com/gpl-cver/"><span class="caps">GPL</span> Cver</a>
|
1030
|
-
– version 2.11a or newer is acceptable.</li>
|
1031
|
-
<li><a href="http://www.icarus.com/eda/Verilog/">Icarus Verilog</a>
|
1032
|
-
– version 0.8 is <em>mostly</em> acceptable—you <strong>will not</strong> be able to <a href="#background.org.vpi.util">access child handles through method calls</a>. The reason for this limitation is explained in <a href="#problems.ivl.vpi_handle_by_name.absolute-paths">the section named “Give full paths to Verilog objects”</a>.</li>
|
1033
|
-
<li><a href="http://www.synopsys.com/products/simulation/simulation.html">Synopsys <span class="caps">VCS</span></a>
|
1034
|
-
– any version that supports the <tt>-load</tt> option is acceptable.</li>
|
1035
|
-
<li><a href="http://www.model.com">Mentor Modelsim</a>
|
1036
|
-
– any version that supports the <tt>-pli</tt> option is acceptable.</li>
|
1037
|
-
</ul></li>
|
1038
|
-
</ul>
|
1039
|
-
|
1040
|
-
|
1041
|
-
<div class="admonition">
|
1042
|
-
|
1043
|
-
<div class="tip" id="tip1">
|
1044
|
-
|
1045
|
-
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
1325
|
+
<pre>
|
1326
|
+
$ rake -f counter_rspec_runner.rake cver
|
1046
1327
|
|
1328
|
+
(in /home/sun/src/ruby-vpi/samp/counter)
|
1329
|
+
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
|
1330
|
+
GPLCVER_2.11a of 07/05/05 (Linux-elf).
|
1331
|
+
Copyright (c) 1991-2005 Pragmatic C Software Corp.
|
1332
|
+
All Rights reserved. Licensed under the GNU General Public License (GPL).
|
1333
|
+
See the 'COPYING' file for details. NO WARRANTY provided.
|
1334
|
+
Today is Sat Dec 30 09:24:09 2006.
|
1335
|
+
Compiling source file "counter.v"
|
1336
|
+
Compiling source file "counter_rspec_bench.v"
|
1337
|
+
Highest level modules:
|
1338
|
+
counter_rspec_bench
|
1047
1339
|
|
1048
|
-
|
1340
|
+
A resetted counter's value
|
1341
|
+
hello from callback! time=1 count=0
|
1342
|
+
- should be zero
|
1343
|
+
hello from callback! time=5 count=1
|
1344
|
+
hello from callback! time=7 count=2
|
1345
|
+
hello from callback! time=9 count=3
|
1346
|
+
hello from callback! time=11 count=4
|
1347
|
+
hello from callback! time=13 count=5
|
1348
|
+
hello from callback! time=15 count=6
|
1349
|
+
hello from callback! time=17 count=7
|
1350
|
+
hello from callback! time=19 count=8
|
1351
|
+
hello from callback! time=21 count=9
|
1352
|
+
hello from callback! time=23 count=10
|
1353
|
+
hello from callback! time=25 count=11
|
1354
|
+
hello from callback! time=27 count=12
|
1355
|
+
hello from callback! time=29 count=13
|
1356
|
+
hello from callback! time=31 count=14
|
1357
|
+
hello from callback! time=33 count=15
|
1358
|
+
hello from callback! time=35 count=16
|
1359
|
+
hello from callback! time=37 count=17
|
1360
|
+
hello from callback! time=39 count=18
|
1361
|
+
hello from callback! time=41 count=19
|
1362
|
+
hello from callback! time=43 count=20
|
1363
|
+
hello from callback! time=45 count=21
|
1364
|
+
hello from callback! time=47 count=22
|
1365
|
+
hello from callback! time=49 count=23
|
1366
|
+
hello from callback! time=51 count=24
|
1367
|
+
hello from callback! time=53 count=25
|
1368
|
+
hello from callback! time=55 count=26
|
1369
|
+
hello from callback! time=57 count=27
|
1370
|
+
hello from callback! time=59 count=28
|
1371
|
+
hello from callback! time=61 count=29
|
1372
|
+
hello from callback! time=63 count=30
|
1373
|
+
hello from callback! time=65 count=31
|
1374
|
+
hello from callback! time=67 count=0
|
1375
|
+
- should increment by one count upon each rising clock edge
|
1049
1376
|
|
1377
|
+
A counter with the maximum value
|
1378
|
+
hello from callback! time=71 count=1
|
1379
|
+
hello from callback! time=73 count=2
|
1380
|
+
hello from callback! time=75 count=3
|
1381
|
+
hello from callback! time=77 count=4
|
1382
|
+
hello from callback! time=79 count=5
|
1383
|
+
hello from callback! time=81 count=6
|
1384
|
+
hello from callback! time=83 count=7
|
1385
|
+
hello from callback! time=85 count=8
|
1386
|
+
hello from callback! time=87 count=9
|
1387
|
+
hello from callback! time=89 count=10
|
1388
|
+
hello from callback! time=91 count=11
|
1389
|
+
hello from callback! time=93 count=12
|
1390
|
+
hello from callback! time=95 count=13
|
1391
|
+
hello from callback! time=97 count=14
|
1392
|
+
hello from callback! time=99 count=15
|
1393
|
+
hello from callback! time=101 count=16
|
1394
|
+
hello from callback! time=103 count=17
|
1395
|
+
hello from callback! time=105 count=18
|
1396
|
+
hello from callback! time=107 count=19
|
1397
|
+
hello from callback! time=109 count=20
|
1398
|
+
hello from callback! time=111 count=21
|
1399
|
+
hello from callback! time=113 count=22
|
1400
|
+
hello from callback! time=115 count=23
|
1401
|
+
hello from callback! time=117 count=24
|
1402
|
+
hello from callback! time=119 count=25
|
1403
|
+
hello from callback! time=121 count=26
|
1404
|
+
hello from callback! time=123 count=27
|
1405
|
+
hello from callback! time=125 count=28
|
1406
|
+
hello from callback! time=127 count=29
|
1407
|
+
hello from callback! time=129 count=30
|
1408
|
+
hello from callback! time=131 count=31
|
1409
|
+
hello from callback! time=133 count=0
|
1410
|
+
- should overflow upon increment
|
1050
1411
|
|
1051
|
-
|
1412
|
+
Finished in 0.042328 seconds
|
1052
1413
|
|
1414
|
+
3 specifications, 0 failures
|
1415
|
+
</pre>
|
1053
1416
|
|
1054
1417
|
</div>
|
1055
1418
|
|
1056
1419
|
</div>
|
1057
1420
|
|
1058
|
-
<
|
1059
|
-
<li><strong>make</strong>
|
1060
|
-
– any distribution should be acceptable.</li>
|
1061
|
-
</ul>
|
1062
|
-
|
1063
|
-
|
1064
|
-
<ul>
|
1065
|
-
<li>C compiler
|
1066
|
-
– 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>
|
1067
|
-
</ul>
|
1421
|
+
<h2 id="usage.debugger">5.2 Debugging</h2>
|
1068
1422
|
|
1069
1423
|
|
1070
|
-
<
|
1071
|
-
<li><a href="http://en.wikipedia.org/wiki/Pthreads" title="pthreads"><span class="caps">POSIX</span> threads</a>
|
1072
|
-
– header and linkable object files, and operating system support for this library are necessary.</li>
|
1073
|
-
</ul>
|
1424
|
+
<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>
|
1074
1425
|
|
1075
1426
|
|
1076
|
-
<
|
1077
|
-
<li><a href="
|
1078
|
-
|
1079
|
-
</
|
1427
|
+
<ol>
|
1428
|
+
<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 “Test runner”</a> for details).</li>
|
1429
|
+
<li>Put the <code class="code">debugger</code> command in your code—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>
|
1430
|
+
</ol>
|
1080
1431
|
|
1081
1432
|
|
1082
|
-
<
|
1083
|
-
<li><a href="http://rubyforge.org/frs/?group_id=126">RubyGems</a>
|
1084
|
-
– 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>
|
1085
|
-
</ul>
|
1433
|
+
<h3 id="usage.debugger.init">5.2.1 Advanced initialization</h3>
|
1086
1434
|
|
1087
1435
|
|
1088
|
-
<
|
1436
|
+
<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>
|
1089
1437
|
|
1090
1438
|
|
1091
|
-
<
|
1439
|
+
<ol>
|
1440
|
+
<li>Deactivate the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> environment variable.</li>
|
1441
|
+
<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>
|
1442
|
+
</ol>
|
1092
1443
|
|
1093
1444
|
|
1094
|
-
<
|
1445
|
+
<h2 id="usage.test-runner">5.3 Test runner</h2>
|
1095
1446
|
|
1096
1447
|
|
1097
|
-
|
1098
|
-
<ul>
|
1099
|
-
<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>
|
1100
|
-
<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>
|
1101
|
-
<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>
|
1102
|
-
<li><a href="http://furius.ca/xxdiff/"><strong>xxdiff</strong></a> is a graphical, three-way merging tool.</li>
|
1103
|
-
<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>
|
1104
|
-
</ul>
|
1448
|
+
<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—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>
|
1105
1449
|
|
1106
1450
|
|
1107
|
-
|
1451
|
+
<div class="formal">
|
1108
1452
|
|
1453
|
+
<div class="example" id="example3">
|
1109
1454
|
|
1110
|
-
<p
|
1455
|
+
<p class="title">Example 3. Seeing what a test runner can do</p>
|
1111
1456
|
|
1112
1457
|
|
1113
|
-
|
1114
|
-
|
1115
|
-
/usr/lib/ruby/gems/1.8
|
1458
|
+
When you invoke a test runner without any arguments, it will show you a list of available tasks:
|
1459
|
+
<pre>$ rake -f some_test_runner.rake
|
1116
1460
|
|
1117
|
-
|
1118
|
-
|
1461
|
+
(in /home/sun/src/ruby-vpi/doc)
|
1462
|
+
rake clean # Remove any temporary products.
|
1463
|
+
rake clobber # Remove any generated file.
|
1464
|
+
rake cver # Simulate with GPL Cver.
|
1465
|
+
rake default # Show a list of available tasks.
|
1466
|
+
rake ivl # Simulate with Icarus Verilog.
|
1467
|
+
rake vcs # Simulate with Synopsys VCS.
|
1468
|
+
rake vsim # Simulate with Mentor Modelsim.
|
1119
1469
|
</pre>
|
1120
1470
|
|
1121
|
-
|
1471
|
+
</div>
|
1122
1472
|
|
1473
|
+
</div>
|
1123
1474
|
|
1124
|
-
|
1125
|
-
<li>Install <a href="http://www.cygwin.com">Cygwin</a>, the Linux-like environment for Windows.</li>
|
1126
|
-
</ul>
|
1475
|
+
<div class="admonition">
|
1127
1476
|
|
1477
|
+
<div class="tip" id="tip2">
|
1128
1478
|
|
1129
|
-
<
|
1479
|
+
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
1130
1480
|
|
1131
|
-
<div class="note" id="note2">
|
1132
1481
|
|
1133
|
-
<p
|
1482
|
+
<p class="title">Tip: Running multiple tests at once.</p>
|
1134
1483
|
|
1135
1484
|
|
1136
|
-
<p
|
1485
|
+
<p>Create a file named <tt>Rakefile</tt> containing the following line.</p>
|
1137
1486
|
|
1138
1487
|
|
1139
|
-
<
|
1488
|
+
<blockquote>
|
1489
|
+
<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>
|
1490
|
+
</blockquote>
|
1140
1491
|
|
1141
1492
|
|
1142
|
-
<p>
|
1493
|
+
<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>
|
1143
1494
|
|
1144
1495
|
|
1145
1496
|
</div>
|
1146
1497
|
|
1147
1498
|
</div>
|
1148
|
-
* Search for object files whose names end with <tt>.so</tt>, <tt>.o</tt>, or <tt>.dll</tt> in your Verilog simulator’s installation directory.
|
1149
1499
|
|
1150
|
-
<
|
1151
|
-
<li>Determine which object files, among those found in the previous step, contain symbols whose names begin with “_vpi” by running the <pre>for x in *.{o,so,dll}; do nm $x | grep -q '[Tt] _vpi' && echo $x; done</pre> command in Cygwin.
|
1152
|
-
<ul>
|
1153
|
-
<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>
|
1154
|
-
<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>
|
1155
|
-
</ul></li>
|
1156
|
-
</ul>
|
1500
|
+
<h3 id="usage.test-runner.env-vars">5.3.1 Environment variables</h3>
|
1157
1501
|
|
1158
1502
|
|
1159
|
-
<
|
1160
|
-
<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’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>
|
1161
|
-
</ul>
|
1503
|
+
<p>Test runners support the following <em>environment</em> variables, which allow you to easily change the behavior of the test runner.</p>
|
1162
1504
|
|
1163
1505
|
|
1164
1506
|
<ul>
|
1165
|
-
<li
|
1507
|
+
<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>
|
1508
|
+
<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>
|
1509
|
+
<li><code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> enables the Ruby prototype for the design under test.</li>
|
1166
1510
|
</ul>
|
1167
1511
|
|
1168
1512
|
|
1169
|
-
<
|
1513
|
+
<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>
|
1170
1514
|
|
1171
1515
|
|
1172
|
-
<
|
1173
|
-
<li>You can uninstall Ruby-VPI by running the <pre>gem uninstall ruby-vpi</pre> command.</li>
|
1174
|
-
<li>You can upgrade to the latest release of Ruby-VPI by running the <pre>gem update ruby-vpi</pre> command.</li>
|
1175
|
-
</ul>
|
1516
|
+
<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>
|
1176
1517
|
|
1177
1518
|
|
1178
|
-
<
|
1519
|
+
<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>
|
1520
|
+
$ DEBUG=1
|
1521
|
+
$ export DEBUG
|
1522
|
+
$ rake
|
1523
|
+
</pre> in Bourne shell or <pre>
|
1524
|
+
% setenv DEBUG 1
|
1525
|
+
% rake
|
1526
|
+
</pre> in C shell.</p>
|
1179
1527
|
|
1180
|
-
<div class="note" id="note3">
|
1181
1528
|
|
1182
|
-
|
1529
|
+
<div class="formal">
|
1183
1530
|
|
1531
|
+
<div class="example" id="example4">
|
1184
1532
|
|
1185
|
-
<p class="title">
|
1533
|
+
<p class="title">Example 4. Running a test with environment variables</p>
|
1186
1534
|
|
1187
1535
|
|
1188
|
-
|
1536
|
+
Here we enable the prototype and code coverage analysis:
|
1537
|
+
<pre>rake -f some_test_runner.rake PROTOTYPE=1 COVERAGE=1</pre>
|
1189
1538
|
|
1539
|
+
Here we <em>disable</em> the prototype and enable the code coverage analysis. Note that both of these invocations are equivalent:
|
1540
|
+
<pre>rake -f some_test_runner.rake PROTOTYPE= COVERAGE=1</pre>
|
1541
|
+
<pre>rake -f some_test_runner.rake COVERAGE=1</pre>
|
1190
1542
|
|
1191
1543
|
</div>
|
1192
1544
|
|
1193
1545
|
</div>
|
1194
1546
|
|
1195
|
-
<
|
1547
|
+
<h2 id="usage.examples">5.4 Sample tests</h2>
|
1548
|
+
|
1549
|
+
|
1550
|
+
<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>
|
1196
1551
|
|
1197
1552
|
|
1198
|
-
<h2 id="usage.tools">Tools</h2>
|
1553
|
+
<h2 id="usage.tools">5.5 Tools</h2>
|
1199
1554
|
|
1200
1555
|
|
1201
1556
|
<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>
|
1202
1557
|
|
1203
1558
|
|
1204
|
-
<h3 id="usage.tools.generate-test">Automated test generation</h3>
|
1559
|
+
<h3 id="usage.tools.generate-test">5.5.1 Automated test generation</h3>
|
1205
1560
|
|
1206
1561
|
|
1207
1562
|
<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>
|
@@ -1226,7 +1581,7 @@ $ ls -d /usr/lib/ruby/gems/1.8/gems/ruby-vpi*
|
|
1226
1581
|
|
1227
1582
|
<div class="admonition">
|
1228
1583
|
|
1229
|
-
<div class="tip" id="
|
1584
|
+
<div class="tip" id="tip3">
|
1230
1585
|
|
1231
1586
|
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
1232
1587
|
|
@@ -1253,7 +1608,7 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
|
|
1253
1608
|
|
1254
1609
|
</div>
|
1255
1610
|
|
1256
|
-
<h3 id="usage.tools.verilog-ruby-conv">Verilog to Ruby conversion</h3>
|
1611
|
+
<h3 id="usage.tools.verilog-ruby-conv">5.5.2 Verilog to Ruby conversion</h3>
|
1257
1612
|
|
1258
1613
|
|
1259
1614
|
<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>
|
@@ -1262,7 +1617,7 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
|
|
1262
1617
|
<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>
|
1263
1618
|
|
1264
1619
|
|
1265
|
-
<h2 id="usage.tutorial">Tutorial</h2>
|
1620
|
+
<h2 id="usage.tutorial">5.6 Tutorial</h2>
|
1266
1621
|
|
1267
1622
|
|
1268
1623
|
<ol>
|
@@ -1276,7 +1631,7 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
|
|
1276
1631
|
</ol>
|
1277
1632
|
|
1278
1633
|
|
1279
|
-
<h3 id="usage.tutorial.declare-design">Start with a design</h3>
|
1634
|
+
<h3 id="usage.tutorial.declare-design">5.6.1 Start with a design</h3>
|
1280
1635
|
|
1281
1636
|
|
1282
1637
|
<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 “Declaration of a simple up-counter with synchronous reset”</a> will serve as our design. Its interface is composed of the following parts:</p>
|
@@ -1294,7 +1649,7 @@ kdiff3 --auto --output <span style="background-color:#fff0f0"><span style="color
|
|
1294
1649
|
|
1295
1650
|
<div class="example" id="fig..counter.v_decl">
|
1296
1651
|
|
1297
|
-
<p class="title">Example
|
1652
|
+
<p class="title">Example 5. Declaration of a simple up-counter with synchronous reset</p>
|
1298
1653
|
|
1299
1654
|
|
1300
1655
|
<pre class="code" lang="verilog">
|
@@ -1309,6 +1664,7 @@ endmodule
|
|
1309
1664
|
</div>
|
1310
1665
|
|
1311
1666
|
</div>
|
1667
|
+
|
1312
1668
|
<div class="admonition">
|
1313
1669
|
|
1314
1670
|
<div class="important" id="important1">
|
@@ -1326,7 +1682,7 @@ endmodule
|
|
1326
1682
|
|
1327
1683
|
</div>
|
1328
1684
|
|
1329
|
-
<h3 id="usage.tutorial.generate-test">Generate a test</h3>
|
1685
|
+
<h3 id="usage.tutorial.generate-test">5.6.2 Generate a test</h3>
|
1330
1686
|
|
1331
1687
|
|
1332
1688
|
<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>
|
@@ -1342,7 +1698,7 @@ Each format represents a different software development methodology:
|
|
1342
1698
|
|
1343
1699
|
<div class="admonition">
|
1344
1700
|
|
1345
|
-
<div class="note" id="
|
1701
|
+
<div class="note" id="note5">
|
1346
1702
|
|
1347
1703
|
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
1348
1704
|
|
@@ -1356,13 +1712,15 @@ Each format represents a different software development methodology:
|
|
1356
1712
|
</div>
|
1357
1713
|
|
1358
1714
|
</div>
|
1359
|
-
|
1715
|
+
|
1716
|
+
<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 “Generating a test with specification in rSpec format”</a> and <a href="#fig..generate-test.unit-test">the example named “Generating a test with specification in xUnit format”</a>.</p>
|
1717
|
+
|
1360
1718
|
|
1361
1719
|
<div class="formal">
|
1362
1720
|
|
1363
1721
|
<div class="example" id="fig..generate-test.rspec">
|
1364
1722
|
|
1365
|
-
<p class="title">Example
|
1723
|
+
<p class="title">Example 6. Generating a test with specification in rSpec format</p>
|
1366
1724
|
|
1367
1725
|
|
1368
1726
|
<pre>
|
@@ -1380,11 +1738,12 @@ $ generate_test.rb counter.v --rspec --name rspec
|
|
1380
1738
|
</div>
|
1381
1739
|
|
1382
1740
|
</div>
|
1741
|
+
|
1383
1742
|
<div class="formal">
|
1384
1743
|
|
1385
1744
|
<div class="example" id="fig..generate-test.unit-test">
|
1386
1745
|
|
1387
|
-
<p class="title">Example
|
1746
|
+
<p class="title">Example 7. Generating a test with specification in xUnit format</p>
|
1388
1747
|
|
1389
1748
|
|
1390
1749
|
<pre>
|
@@ -1403,7 +1762,7 @@ $ generate_test.rb counter.v --xunit --name xunit
|
|
1403
1762
|
|
1404
1763
|
</div>
|
1405
1764
|
|
1406
|
-
<h3 id="usage.tutorial.specification">Specify your expectations</h3>
|
1765
|
+
<h3 id="usage.tutorial.specification">5.6.3 Specify your expectations</h3>
|
1407
1766
|
|
1408
1767
|
|
1409
1768
|
<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>
|
@@ -1424,7 +1783,7 @@ Here are some reasonable expectations for our simple counter:
|
|
1424
1783
|
|
1425
1784
|
<div class="example" id="fig..counter_rspec_spec.rb">
|
1426
1785
|
|
1427
|
-
<p class="title">Example
|
1786
|
+
<p class="title">Example 8. Specification implemented in rSpec format</p>
|
1428
1787
|
|
1429
1788
|
|
1430
1789
|
<pre class="code"><span style="color:#888"># This file is a behavioral specification for the design under test.</span>
|
@@ -1447,7 +1806,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1447
1806
|
specify <span style="background-color:#fff0f0"><span style="color:#710">"</span><span style="color:#D20">should increment by one count upon each rising clock edge</span><span style="color:#710">"</span></span> <span style="color:#080; font-weight:bold">do</span>
|
1448
1807
|
<span style="color:#036; font-weight:bold">LIMIT</span>.times <span style="color:#080; font-weight:bold">do</span> |i|
|
1449
1808
|
<span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == i
|
1450
|
-
|
1809
|
+
simulate <span style="color:#888"># increment the counter</span>
|
1451
1810
|
<span style="color:#080; font-weight:bold">end</span>
|
1452
1811
|
<span style="color:#080; font-weight:bold">end</span>
|
1453
1812
|
<span style="color:#080; font-weight:bold">end</span>
|
@@ -1457,12 +1816,12 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1457
1816
|
<span style="color:#036; font-weight:bold">Counter</span>.reset!
|
1458
1817
|
|
1459
1818
|
<span style="color:#888"># increment the counter to maximum value</span>
|
1460
|
-
<span style="color:#036; font-weight:bold">MAX</span>.times {
|
1819
|
+
<span style="color:#036; font-weight:bold">MAX</span>.times {simulate}
|
1461
1820
|
<span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == <span style="color:#036; font-weight:bold">MAX</span>
|
1462
1821
|
<span style="color:#080; font-weight:bold">end</span>
|
1463
1822
|
|
1464
1823
|
specify <span style="background-color:#fff0f0"><span style="color:#710">"</span><span style="color:#D20">should overflow upon increment</span><span style="color:#710">"</span></span> <span style="color:#080; font-weight:bold">do</span>
|
1465
|
-
|
1824
|
+
simulate <span style="color:#888"># increment the counter</span>
|
1466
1825
|
<span style="color:#036; font-weight:bold">Counter</span>.count.intVal.should == <span style="color:#00D; font-weight:bold">0</span>
|
1467
1826
|
<span style="color:#080; font-weight:bold">end</span>
|
1468
1827
|
<span style="color:#080; font-weight:bold">end</span>
|
@@ -1471,11 +1830,12 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1471
1830
|
</div>
|
1472
1831
|
|
1473
1832
|
</div>
|
1833
|
+
|
1474
1834
|
<div class="formal">
|
1475
1835
|
|
1476
1836
|
<div class="example" id="fig..counter_xunit_spec.rb">
|
1477
1837
|
|
1478
|
-
<p class="title">Example
|
1838
|
+
<p class="title">Example 9. Specification implemented in xUnit format</p>
|
1479
1839
|
|
1480
1840
|
|
1481
1841
|
<pre class="code"><span style="color:#888"># This file is a behavioral specification for the design under test.</span>
|
@@ -1498,7 +1858,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1498
1858
|
<span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">test_increment</span>
|
1499
1859
|
<span style="color:#036; font-weight:bold">LIMIT</span>.times <span style="color:#080; font-weight:bold">do</span> |i|
|
1500
1860
|
assert_equal i, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
|
1501
|
-
|
1861
|
+
simulate <span style="color:#888"># increment the counter</span>
|
1502
1862
|
<span style="color:#080; font-weight:bold">end</span>
|
1503
1863
|
<span style="color:#080; font-weight:bold">end</span>
|
1504
1864
|
<span style="color:#080; font-weight:bold">end</span>
|
@@ -1508,12 +1868,12 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1508
1868
|
<span style="color:#036; font-weight:bold">Counter</span>.reset!
|
1509
1869
|
|
1510
1870
|
<span style="color:#888"># increment the counter to maximum value</span>
|
1511
|
-
<span style="color:#036; font-weight:bold">MAX</span>.times {
|
1871
|
+
<span style="color:#036; font-weight:bold">MAX</span>.times {simulate}
|
1512
1872
|
assert_equal <span style="color:#036; font-weight:bold">MAX</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
|
1513
1873
|
<span style="color:#080; font-weight:bold">end</span>
|
1514
1874
|
|
1515
1875
|
<span style="color:#080; font-weight:bold">def</span> <span style="color:#06B; font-weight:bold">test_overflow</span>
|
1516
|
-
|
1876
|
+
simulate <span style="color:#888"># increment the counter</span>
|
1517
1877
|
assert_equal <span style="color:#00D; font-weight:bold">0</span>, <span style="color:#036; font-weight:bold">Counter</span>.count.intVal
|
1518
1878
|
<span style="color:#080; font-weight:bold">end</span>
|
1519
1879
|
<span style="color:#080; font-weight:bold">end</span>
|
@@ -1522,6 +1882,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1522
1882
|
</div>
|
1523
1883
|
|
1524
1884
|
</div>
|
1885
|
+
|
1525
1886
|
<div class="admonition">
|
1526
1887
|
|
1527
1888
|
<div class="important" id="important2">
|
@@ -1539,9 +1900,8 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1539
1900
|
|
1540
1901
|
<span style="color:#888"># This method resets the design under test.</span>
|
1541
1902
|
<span style="color:#080; font-weight:bold">def</span> <span style="color:#036; font-weight:bold">Counter</span>.reset!
|
1542
|
-
<span style="color:#888"># assert the reset signal for two clock cycles</span>
|
1543
1903
|
reset.intVal = <span style="color:#00D; font-weight:bold">1</span>
|
1544
|
-
|
1904
|
+
simulate
|
1545
1905
|
reset.intVal = <span style="color:#00D; font-weight:bold">0</span>
|
1546
1906
|
<span style="color:#080; font-weight:bold">end</span>
|
1547
1907
|
</pre></li>
|
@@ -1552,7 +1912,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1552
1912
|
|
1553
1913
|
</div>
|
1554
1914
|
|
1555
|
-
<h3 id="usage.tutorial.implement-proto">Implement the prototype</h3>
|
1915
|
+
<h3 id="usage.tutorial.implement-proto">5.6.4 Implement the prototype</h3>
|
1556
1916
|
|
1557
1917
|
|
1558
1918
|
<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 “Ruby prototype of our Verilog design”</a>.</p>
|
@@ -1562,7 +1922,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1562
1922
|
|
1563
1923
|
<div class="example" id="fig..counter_proto.rb">
|
1564
1924
|
|
1565
|
-
<p class="title">Example
|
1925
|
+
<p class="title">Example 10. Ruby prototype of our Verilog design</p>
|
1566
1926
|
|
1567
1927
|
|
1568
1928
|
<pre class="code">
|
@@ -1578,6 +1938,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1578
1938
|
</div>
|
1579
1939
|
|
1580
1940
|
</div>
|
1941
|
+
|
1581
1942
|
<div class="admonition">
|
1582
1943
|
|
1583
1944
|
<div class="important" id="important3">
|
@@ -1595,7 +1956,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1595
1956
|
|
1596
1957
|
</div>
|
1597
1958
|
|
1598
|
-
<h3 id="usage.tutorial.test-proto">Verify the prototype</h3>
|
1959
|
+
<h3 id="usage.tutorial.test-proto">5.6.5 Verify the prototype</h3>
|
1599
1960
|
|
1600
1961
|
|
1601
1962
|
<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 “Running a test with specification in rSpec format”</a> and <a href="#fig..test-proto.unit-test">the example named “Running a test with specification in xUnit format”</a>.</p>
|
@@ -1605,7 +1966,7 @@ context <span style="background-color:#fff0f0"><span style="color:#710">"</
|
|
1605
1966
|
|
1606
1967
|
<div class="example" id="fig..test-proto.rspec">
|
1607
1968
|
|
1608
|
-
<p class="title">Example
|
1969
|
+
<p class="title">Example 11. Running a test with specification in rSpec format</p>
|
1609
1970
|
|
1610
1971
|
|
1611
1972
|
<pre>
|
@@ -1628,11 +1989,12 @@ Finished in 0.018199 seconds
|
|
1628
1989
|
</div>
|
1629
1990
|
|
1630
1991
|
</div>
|
1992
|
+
|
1631
1993
|
<div class="formal">
|
1632
1994
|
|
1633
1995
|
<div class="example" id="fig..test-proto.unit-test">
|
1634
1996
|
|
1635
|
-
<p class="title">Example
|
1997
|
+
<p class="title">Example 12. Running a test with specification in xUnit format</p>
|
1636
1998
|
|
1637
1999
|
|
1638
2000
|
<pre>
|
@@ -1651,11 +2013,13 @@ Finished in 0.040668 seconds.
|
|
1651
2013
|
</div>
|
1652
2014
|
|
1653
2015
|
</div>
|
1654
|
-
|
2016
|
+
|
2017
|
+
<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’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>
|
2018
|
+
|
1655
2019
|
|
1656
2020
|
<div class="admonition">
|
1657
2021
|
|
1658
|
-
<div class="tip" id="
|
2022
|
+
<div class="tip" id="tip4">
|
1659
2023
|
|
1660
2024
|
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
1661
2025
|
|
@@ -1670,7 +2034,7 @@ In these examples, the <code class="code"><span style="color:#036; font-weight:b
|
|
1670
2034
|
|
1671
2035
|
</div>
|
1672
2036
|
|
1673
|
-
<h3 id="usage.tutorial.implement-design">Implement the design</h3>
|
2037
|
+
<h3 id="usage.tutorial.implement-design">5.6.6 Implement the design</h3>
|
1674
2038
|
|
1675
2039
|
|
1676
2040
|
<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 “Implementation of a simple up-counter with synchronous reset”</a>.</p>
|
@@ -1680,7 +2044,7 @@ In these examples, the <code class="code"><span style="color:#036; font-weight:b
|
|
1680
2044
|
|
1681
2045
|
<div class="example" id="fig..counter.v_impl">
|
1682
2046
|
|
1683
|
-
<p class="title">Example
|
2047
|
+
<p class="title">Example 13. Implementation of a simple up-counter with synchronous reset</p>
|
1684
2048
|
|
1685
2049
|
|
1686
2050
|
<pre class="code" lang="verilog">/**
|
@@ -1708,6 +2072,7 @@ endmodule
|
|
1708
2072
|
</div>
|
1709
2073
|
|
1710
2074
|
</div>
|
2075
|
+
|
1711
2076
|
<div class="admonition">
|
1712
2077
|
|
1713
2078
|
<div class="important" id="important4">
|
@@ -1725,7 +2090,7 @@ endmodule
|
|
1725
2090
|
|
1726
2091
|
</div>
|
1727
2092
|
|
1728
|
-
<h3 id="usage.tutorial.test-design">Verify the design</h3>
|
2093
|
+
<h3 id="usage.tutorial.test-design">5.6.7 Verify the design</h3>
|
1729
2094
|
|
1730
2095
|
|
1731
2096
|
<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 “Running a test with specification in rSpec format”</a> and <a href="#fig..test-design.unit-test">the example named “Running a test with specification in xUnit format”</a> illustrate this process.</p>
|
@@ -1735,7 +2100,7 @@ endmodule
|
|
1735
2100
|
|
1736
2101
|
<div class="example" id="fig..test-design.rspec">
|
1737
2102
|
|
1738
|
-
<p class="title">Example
|
2103
|
+
<p class="title">Example 14. Running a test with specification in rSpec format</p>
|
1739
2104
|
|
1740
2105
|
|
1741
2106
|
<pre>
|
@@ -1756,11 +2121,12 @@ Finished in 0.005628 seconds
|
|
1756
2121
|
</div>
|
1757
2122
|
|
1758
2123
|
</div>
|
2124
|
+
|
1759
2125
|
<div class="formal">
|
1760
2126
|
|
1761
2127
|
<div class="example" id="fig..test-design.unit-test">
|
1762
2128
|
|
1763
|
-
<p class="title">Example
|
2129
|
+
<p class="title">Example 15. Running a test with specification in xUnit format</p>
|
1764
2130
|
|
1765
2131
|
|
1766
2132
|
<pre>
|
@@ -1777,143 +2143,14 @@ Finished in 0.006766 seconds.
|
|
1777
2143
|
</div>
|
1778
2144
|
|
1779
2145
|
</div>
|
1780
|
-
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’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.
|
1781
|
-
|
1782
|
-
<h2 id="usage.test-runner">Test runner</h2>
|
1783
|
-
|
1784
|
-
|
1785
|
-
<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—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>
|
1786
|
-
|
1787
|
-
|
1788
|
-
<div class="formal">
|
1789
|
-
|
1790
|
-
<div class="example" id="example13">
|
1791
|
-
|
1792
|
-
<p class="title">Example 13. Seeing what a test runner can do</p>
|
1793
|
-
|
1794
|
-
|
1795
|
-
When you invoke a test runner without any arguments, it will show you a list of available tasks:
|
1796
|
-
<pre>$ rake -f some_test_runner.rake
|
1797
|
-
|
1798
|
-
(in /home/sun/src/ruby-vpi/doc)
|
1799
|
-
rake clean # Remove any temporary products.
|
1800
|
-
rake clobber # Remove any generated file.
|
1801
|
-
rake cver # Simulate with GPL Cver.
|
1802
|
-
rake default # Show a list of available tasks.
|
1803
|
-
rake ivl # Simulate with Icarus Verilog.
|
1804
|
-
rake vcs # Simulate with Synopsys VCS.
|
1805
|
-
rake vsim # Simulate with Mentor Modelsim.
|
1806
|
-
</pre>
|
1807
|
-
|
1808
|
-
</div>
|
1809
|
-
|
1810
|
-
</div>
|
1811
|
-
<div class="admonition">
|
1812
|
-
|
1813
|
-
<div class="tip" id="tip4">
|
1814
|
-
|
1815
|
-
<p style="float:left"><img src="images/tip.png" title="tip" alt="tip" /></p>
|
1816
|
-
|
1817
|
-
|
1818
|
-
<p class="title">Tip: Running multiple tests at once.</p>
|
1819
|
-
|
1820
|
-
|
1821
|
-
<p>Create a file named <tt>Rakefile</tt> containing the following line.</p>
|
1822
|
-
|
1823
|
-
|
1824
|
-
<blockquote>
|
1825
|
-
<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>
|
1826
|
-
</blockquote>
|
1827
|
-
|
1828
|
-
|
1829
|
-
<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>
|
1830
|
-
|
1831
|
-
|
1832
|
-
</div>
|
1833
|
-
|
1834
|
-
</div>
|
1835
|
-
|
1836
|
-
<h3 id="usage.test-runner.env-vars">Environment variables</h3>
|
1837
|
-
|
1838
|
-
|
1839
|
-
<p>Test runners support the following <em>environment</em> variables, which allow you to easily change the behavior of the test runner.</p>
|
1840
|
-
|
1841
|
-
|
1842
|
-
<ul>
|
1843
|
-
<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>
|
1844
|
-
<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>
|
1845
|
-
<li><code class="code"><span style="color:#036; font-weight:bold">PROTOTYPE</span></code> enables the Ruby prototype for the design under test.</li>
|
1846
|
-
</ul>
|
1847
|
-
|
1848
|
-
|
1849
|
-
<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>
|
1850
|
-
|
1851
|
-
|
1852
|
-
<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>
|
1853
|
-
|
1854
|
-
|
1855
|
-
<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>
|
1856
|
-
$ DEBUG=1
|
1857
|
-
$ export DEBUG
|
1858
|
-
$ rake
|
1859
|
-
</pre> in Bourne shell or <pre>
|
1860
|
-
% setenv DEBUG 1
|
1861
|
-
% rake
|
1862
|
-
</pre> in C shell.</p>
|
1863
|
-
|
1864
|
-
|
1865
|
-
<div class="formal">
|
1866
|
-
|
1867
|
-
<div class="example" id="example14">
|
1868
|
-
|
1869
|
-
<p class="title">Example 14. Running a test with environment variables</p>
|
1870
|
-
|
1871
|
-
|
1872
|
-
Here we enable the prototype and code coverage analysis:
|
1873
|
-
<pre>rake -f some_test_runner.rake PROTOTYPE=1 COVERAGE=1</pre>
|
1874
|
-
|
1875
|
-
Here we <em>disable</em> the prototype and enable the code coverage analysis. Note that both of these invocations are equivalent:
|
1876
|
-
<pre>rake -f some_test_runner.rake PROTOTYPE= COVERAGE=1</pre>
|
1877
|
-
<pre>rake -f some_test_runner.rake COVERAGE=1</pre>
|
1878
|
-
|
1879
|
-
</div>
|
1880
|
-
|
1881
|
-
</div>
|
1882
|
-
|
1883
|
-
<h2 id="usage.debugger">Interactive debugger</h2>
|
1884
|
-
|
1885
|
-
|
1886
|
-
<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>
|
1887
|
-
|
1888
|
-
|
1889
|
-
<ol>
|
1890
|
-
<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 “Test runner”</a> for details).</li>
|
1891
|
-
<li>Put the <code class="code">debugger</code> command in your code—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>
|
1892
|
-
</ol>
|
1893
|
-
|
1894
|
-
|
1895
|
-
<h3 id="usage.debugger.init">Advanced initialization</h3>
|
1896
|
-
|
1897
|
-
|
1898
|
-
<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>
|
1899
|
-
|
1900
|
-
|
1901
|
-
<ol>
|
1902
|
-
<li>Deactivate the <code class="code"><span style="color:#036; font-weight:bold">DEBUG</span></code> environment variable.</li>
|
1903
|
-
<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>
|
1904
|
-
</ol>
|
1905
2146
|
|
2147
|
+
<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’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>
|
1906
2148
|
|
1907
|
-
<h2 id="usage.examples">Sample tests</h2>
|
1908
2149
|
|
1909
|
-
|
1910
|
-
<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>
|
1911
|
-
|
1912
|
-
|
1913
|
-
<h1 id="hacking">Hacking</h1>
|
2150
|
+
<h1 id="hacking">6 Hacking</h1>
|
1914
2151
|
|
1915
2152
|
|
1916
|
-
<h2 id="hacking.release-packages">Building release packages</h2>
|
2153
|
+
<h2 id="hacking.release-packages">6.1 Building release packages</h2>
|
1917
2154
|
|
1918
2155
|
|
1919
2156
|
<p>In addition to the <a href="#setup.reqs">normal requirements</a>, you need the following software to build release packages:</p>
|
@@ -1929,21 +2166,21 @@ Here we <em>disable</em> the prototype and enable the code coverage analysis. No
|
|
1929
2166
|
<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>
|
1930
2167
|
|
1931
2168
|
|
1932
|
-
<h1 id="problems">Known problems</h1>
|
2169
|
+
<h1 id="problems">7 Known problems</h1>
|
1933
2170
|
|
1934
2171
|
|
1935
2172
|
<p>This chapter presents known problems and possible solutions. In addition, previously solved problems have been retained for historical reference.</p>
|
1936
2173
|
|
1937
2174
|
|
1938
|
-
<h2 id="problems.ruby">Ruby</h2>
|
2175
|
+
<h2 id="problems.ruby">7.1 Ruby</h2>
|
1939
2176
|
|
1940
2177
|
|
1941
|
-
<h3 id="problems.ruby.SystemStackError">SystemStackError</h3>
|
2178
|
+
<h3 id="problems.ruby.SystemStackError">7.1.1 SystemStackError</h3>
|
1942
2179
|
|
1943
2180
|
|
1944
2181
|
<div class="admonition">
|
1945
2182
|
|
1946
|
-
<div class="note" id="
|
2183
|
+
<div class="note" id="note6">
|
1947
2184
|
|
1948
2185
|
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
1949
2186
|
|
@@ -1957,14 +2194,16 @@ Here we <em>disable</em> the prototype and enable the code coverage analysis. No
|
|
1957
2194
|
</div>
|
1958
2195
|
|
1959
2196
|
</div>
|
1960
|
-
If a “stack level too deep (SystemStackError)” 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.
|
1961
2197
|
|
1962
|
-
<
|
2198
|
+
<p>If a “stack level too deep (SystemStackError)” 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>
|
2199
|
+
|
2200
|
+
|
2201
|
+
<h3 id="problems.ruby.xUnit">7.1.2 test/unit</h3>
|
1963
2202
|
|
1964
2203
|
|
1965
2204
|
<div class="admonition">
|
1966
2205
|
|
1967
|
-
<div class="note" id="
|
2206
|
+
<div class="note" id="note7">
|
1968
2207
|
|
1969
2208
|
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
1970
2209
|
|
@@ -1978,15 +2217,17 @@ If a “stack level too deep (SystemStackError)” error occurs during t
|
|
1978
2217
|
</div>
|
1979
2218
|
|
1980
2219
|
</div>
|
1981
|
-
If your specification employs Ruby’s unit testing framework, then you will encounter an error saying “[BUG] cross-thread violation on rb_gc()”.
|
1982
2220
|
|
1983
|
-
<
|
2221
|
+
<p>If your specification employs Ruby’s unit testing framework, then you will encounter an error saying “[BUG] cross-thread violation on rb_gc()”.</p>
|
2222
|
+
|
2223
|
+
|
2224
|
+
<h2 id="problem.ivl">7.2 Icarus Verilog</h2>
|
1984
2225
|
|
1985
2226
|
|
1986
|
-
<h3 id="problems.ivl.vpi_handle_by_name">Vpi::vpi_handle_by_name</h3>
|
2227
|
+
<h3 id="problems.ivl.vpi_handle_by_name">7.2.1 Vpi::vpi_handle_by_name</h3>
|
1987
2228
|
|
1988
2229
|
|
1989
|
-
<h4 id="problems.ivl.vpi_handle_by_name.absolute-paths">Give full paths to Verilog objects</h4>
|
2230
|
+
<h4 id="problems.ivl.vpi_handle_by_name.absolute-paths">7.2.1.1 Give full paths to Verilog objects</h4>
|
1990
2231
|
|
1991
2232
|
|
1992
2233
|
<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>
|
@@ -1999,7 +2240,7 @@ If your specification employs Ruby’s unit testing framework, then you will
|
|
1999
2240
|
|
2000
2241
|
<div class="example" id="ex..TestFoo">
|
2001
2242
|
|
2002
|
-
<p class="title">Example
|
2243
|
+
<p class="title">Example 16. Part of a bench which instantiates a Verilog design</p>
|
2003
2244
|
|
2004
2245
|
|
2005
2246
|
<pre class="code" lang="verilog">
|
@@ -2013,7 +2254,7 @@ endmodule
|
|
2013
2254
|
|
2014
2255
|
</div>
|
2015
2256
|
|
2016
|
-
<h4 id="problems.ivl.vpi_handle_by_name.connect-registers">Registers must be connected</h4>
|
2257
|
+
<h4 id="problems.ivl.vpi_handle_by_name.connect-registers">7.2.1.2 Registers must be connected</h4>
|
2017
2258
|
|
2018
2259
|
|
2019
2260
|
<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>
|
@@ -2029,7 +2270,7 @@ endmodule
|
|
2029
2270
|
|
2030
2271
|
<div class="example" id="ex..TestFoo_bad">
|
2031
2272
|
|
2032
|
-
<p class="title">Example
|
2273
|
+
<p class="title">Example 17. Bad design with unconnected registers</p>
|
2033
2274
|
|
2034
2275
|
|
2035
2276
|
<pre class="code" lang="verilog">
|
@@ -2044,11 +2285,12 @@ endmodule
|
|
2044
2285
|
</div>
|
2045
2286
|
|
2046
2287
|
</div>
|
2288
|
+
|
2047
2289
|
<div class="formal">
|
2048
2290
|
|
2049
2291
|
<div class="example" id="ex..TestFoo_fix">
|
2050
2292
|
|
2051
|
-
<p class="title">Example
|
2293
|
+
<p class="title">Example 18. Fixed design with wired registers</p>
|
2052
2294
|
|
2053
2295
|
|
2054
2296
|
<pre class="code" lang="verilog">
|
@@ -2066,7 +2308,7 @@ endmodule
|
|
2066
2308
|
|
2067
2309
|
</div>
|
2068
2310
|
|
2069
|
-
<h3 id="problems.ivl.vpi_reset">Vpi::reset</h3>
|
2311
|
+
<h3 id="problems.ivl.vpi_reset">7.2.2 Vpi::reset</h3>
|
2070
2312
|
|
2071
2313
|
|
2072
2314
|
<div class="caution">The <code class="code">vpi_control</code> method was removed in release 3.0.0 (2006-04-23). Please use <code class="code"><span style="color:#036; font-weight:bold">Vpi</span>::vpi_control(<span style="color:#036; font-weight:bold">VpiReset</span>)</code> instead.</div>
|
@@ -2074,15 +2316,15 @@ endmodule
|
|
2074
2316
|
<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>
|
2075
2317
|
|
2076
2318
|
|
2077
|
-
<h2 id="problems.vsim">Mentor Modelsim</h2>
|
2319
|
+
<h2 id="problems.vsim">7.3 Mentor Modelsim</h2>
|
2078
2320
|
|
2079
2321
|
|
2080
|
-
<h3 id="problems.vsim.ruby_run">ruby_run();</h3>
|
2322
|
+
<h3 id="problems.vsim.ruby_run">7.3.1 ruby_run();</h3>
|
2081
2323
|
|
2082
2324
|
|
2083
2325
|
<div class="admonition">
|
2084
2326
|
|
2085
|
-
<div class="note" id="
|
2327
|
+
<div class="note" id="note8">
|
2086
2328
|
|
2087
2329
|
<p style="float:left"><img src="images/note.png" title="note" alt="note" /></p>
|
2088
2330
|
|
@@ -2096,18 +2338,20 @@ endmodule
|
|
2096
2338
|
</div>
|
2097
2339
|
|
2098
2340
|
</div>
|
2099
|
-
Version 6.1b of Mentor Modelsim doesn’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.
|
2100
2341
|
|
2101
|
-
<
|
2342
|
+
<p>Version 6.1b of Mentor Modelsim doesn’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>
|
2343
|
+
|
2344
|
+
|
2345
|
+
<h1 id="glossary">8 Glossary</h1>
|
2102
2346
|
|
2103
2347
|
|
2104
|
-
<h2 id="glossary.bench">Bench</h2>
|
2348
|
+
<h2 id="glossary.bench">8.1 Bench</h2>
|
2105
2349
|
|
2106
2350
|
|
2107
2351
|
<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>
|
2108
2352
|
|
2109
2353
|
|
2110
|
-
<h2 id="glossary.BDD">Behavior driven development (BDD)</h2>
|
2354
|
+
<h2 id="glossary.BDD">8.2 Behavior driven development (BDD)</h2>
|
2111
2355
|
|
2112
2356
|
|
2113
2357
|
<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>
|
@@ -2116,25 +2360,25 @@ Version 6.1b of Mentor Modelsim doesn’t play nicely with either an embedde
|
|
2116
2360
|
<p>See the <a href="http://behaviour-driven.org/">official wiki</a> for more information.</p>
|
2117
2361
|
|
2118
2362
|
|
2119
|
-
<h2 id="glossary.design">Design</h2>
|
2363
|
+
<h2 id="glossary.design">8.3 Design</h2>
|
2120
2364
|
|
2121
2365
|
|
2122
2366
|
<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>
|
2123
2367
|
|
2124
2368
|
|
2125
|
-
<h2 id="glossary.expectation">Expectation</h2>
|
2369
|
+
<h2 id="glossary.expectation">8.4 Expectation</h2>
|
2126
2370
|
|
2127
2371
|
|
2128
2372
|
<p>The desired response to some stimulus.</p>
|
2129
2373
|
|
2130
2374
|
|
2131
|
-
<h2 id="glossary.handle">Handle</h2>
|
2375
|
+
<h2 id="glossary.handle">8.5 Handle</h2>
|
2132
2376
|
|
2133
2377
|
|
2134
2378
|
<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>
|
2135
2379
|
|
2136
2380
|
|
2137
|
-
<h2 id="glossary.rake">Rake</h2>
|
2381
|
+
<h2 id="glossary.rake">8.6 Rake</h2>
|
2138
2382
|
|
2139
2383
|
|
2140
2384
|
<blockquote>
|
@@ -2147,7 +2391,7 @@ Version 6.1b of Mentor Modelsim doesn’t play nicely with either an embedde
|
|
2147
2391
|
</blockquote>
|
2148
2392
|
|
2149
2393
|
|
2150
|
-
<h2 id="glossary.rspec">rSpec</h2>
|
2394
|
+
<h2 id="glossary.rspec">8.7 rSpec</h2>
|
2151
2395
|
|
2152
2396
|
|
2153
2397
|
<p>The <a href="#glossary.BDD"><span class="caps">BDD</span></a> framework for Ruby.</p>
|
@@ -2156,13 +2400,13 @@ Version 6.1b of Mentor Modelsim doesn’t play nicely with either an embedde
|
|
2156
2400
|
<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>
|
2157
2401
|
|
2158
2402
|
|
2159
|
-
<h2 id="glossary.specification">Specification</h2>
|
2403
|
+
<h2 id="glossary.specification">8.8 Specification</h2>
|
2160
2404
|
|
2161
2405
|
|
2162
2406
|
<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>
|
2163
2407
|
|
2164
2408
|
|
2165
|
-
<h2 id="glossary.TDD">Test driven development (TDD)</h2>
|
2409
|
+
<h2 id="glossary.TDD">8.9 Test driven development (TDD)</h2>
|
2166
2410
|
|
2167
2411
|
|
2168
2412
|
<p>An <a href="http://agilemanifesto.org/">agile software development methodology</a> which emphasizes (1) testing functionality before implementing it and (2) refactoring.</p>
|
@@ -2171,13 +2415,13 @@ Version 6.1b of Mentor Modelsim doesn’t play nicely with either an embedde
|
|
2171
2415
|
<p>See <a href="http://www.agiledata.org/essays/tdd.html">this introductory article</a> for more information.</p>
|
2172
2416
|
|
2173
2417
|
|
2174
|
-
<h2 id="glossary.test">Test</h2>
|
2418
|
+
<h2 id="glossary.test">9.0 Test</h2>
|
2175
2419
|
|
2176
2420
|
|
2177
2421
|
<p>Something that checks if a <a href="#glossary.design">design</a> satisfies a <a href="#glossary.specification">specification</a>.</p>
|
2178
2422
|
|
2179
2423
|
|
2180
|
-
<h2 id="glossary.test_bench">Test bench</h2>
|
2424
|
+
<h2 id="glossary.test_bench">9.1 Test bench</h2>
|
2181
2425
|
|
2182
2426
|
|
2183
2427
|
<p>An allusion to <a href="#background.vocab">a bench in an electronics laboratory</a>, or so it seems.</p>
|