ruby-vpi 10.0.0 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -12,6 +12,36 @@ We _strictly_ follow the RubyGems project's "rational versioning policy":http://
12
12
  fn1. C. Gross, "Explaining Open Source Version Numbers", [Online document], 2005 Nov 28, [cited 2006 Aug 27], Available HTTP: "http://ablog.apress.com/?p=738":http://ablog.apress.com/?p=738
13
13
 
14
14
 
15
+ h1. Version 11.0.0 (2006-11-05)
16
+
17
+ h2. Summary
18
+
19
+ This release shortens generated Ruby benches and uses the less confusing notation for defining "singleton methods":http://wiki.rubygarden.org/Ruby/page/show/SingletonTutorial in generated designs and prototypes.
20
+
21
+ h2. Notice
22
+
23
+ * The arguments for the "@RubyVPI.init_bench@ method":ref/ruby/classes/RubyVpi.html have changed.
24
+
25
+ * *generate_test.rb* no longer emits undocumented status indicators: _name_ and _format_.
26
+
27
+ * The source code is no longer distributed as a *zip* package, because it seems to be quite underutilized in comparison to the *tgz* and *gem* packages.
28
+
29
+ h2. Detail
30
+
31
+ * Generated Ruby benches have been shortened to just _one_ line of code!
32
+
33
+ * The less confusing notation of <pre>def some_object.a_singleton_method
34
+ do_stuff
35
+ end</pre> is now used instead of the <pre>class << some_object
36
+ def a_singleton_method
37
+ do_stuff
38
+ end
39
+ end</pre> notation.
40
+ ** The tutorial and examples have been updated accordingly.
41
+
42
+ * The pipelined ALU example now has an updated @IntegerGenerator@ class.
43
+
44
+
15
45
  h1. Version 10.0.0 (2006-11-05)
16
46
 
17
47
  h2. Summary
data/Rakefile CHANGED
@@ -244,7 +244,6 @@ spec = Gem::Specification.new do |s|
244
244
  end
245
245
 
246
246
  Rake::GemPackageTask.new(spec) do |pkg|
247
- pkg.need_zip = true
248
247
  pkg.need_tar = true
249
248
  end
250
249
 
@@ -8,9 +8,10 @@
8
8
  # skip:: File will be skipped because it is already up to date.
9
9
  # update:: File will be updated because it is out of date. A backup copy will be made before the file is updated. Use a text merging tool (see MERGER) or manually transfer any necessary information from the backup copy to the updated file.
10
10
  # backup:: A backup copy of a file is being made.
11
+ # module:: A Verilog module has been identified.
11
12
  #
12
13
  # = Environment variables
13
- # MERGER:: A command that invokes a text merging tool with two arguments: old file, new file. The tool's output should be written to the new file.
14
+ # MERGER:: A command that invokes a text merging tool with two arguments: (1) old file, (2) new file. The tool's output should be written to the new file.
14
15
 
15
16
 
16
17
  =begin
@@ -170,15 +171,12 @@ if File.basename($0) == File.basename(__FILE__)
170
171
  optSpecFmt = :rSpec if val
171
172
  end
172
173
 
173
- opts.on '-n', '--name NAME', 'attach NAME indentifier to generated test' do |val|
174
+ opts.on '-n', '--name NAME', 'insert NAME into the names of generated files' do |val|
174
175
  optTestName = val
175
176
  end
176
177
 
177
178
  opts.parse! ARGV
178
179
 
179
- notify :name, optTestName
180
- notify :format, optSpecFmt
181
-
182
180
 
183
181
  v = VerilogParser.new(ARGF.read)
184
182
 
@@ -1,31 +1,7 @@
1
1
  # This file is the Ruby side of the bench.
2
2
 
3
- require 'ruby-vpi'
4
- <%
5
- case aOutputInfo.specFormat
6
- when :xUnit
7
- %>
8
- require 'test/unit'
9
- <%
10
- when :rSpec
11
- %>
12
- require 'ruby-vpi/rspec'
13
- <%
14
- end
15
- %>
3
+ RubyVpi.init_bench :<%= aOutputInfo.designClassName %>, :<%= aOutputInfo.specFormat %>
4
+ <% if aOutputInfo.specFormat == :generic %>
16
5
 
17
- RubyVpi.init_bench '<%= aModuleInfo.name + aOutputInfo.suffix %>', :<%= aOutputInfo.designClassName %>
18
-
19
- # service the $ruby_relay callback
20
- <%
21
- case aOutputInfo.specFormat
22
- when :xUnit, :rSpec
23
- %>
24
- # The <%= aOutputInfo.specFormat %> library will take control henceforth.
25
- <%
26
- else
27
- %>
28
- <%= aOutputInfo.specClassName + '.new' %>
29
- <%
30
- end
31
- %>
6
+ <%= aOutputInfo.specClassName + '.new' %>
7
+ <% end %>
@@ -31,9 +31,7 @@ module <%= aOutputInfo.verilogBenchName %>;
31
31
  // connect to the Ruby side of this bench
32
32
  initial begin
33
33
  <%= clockSignal %> = 0;
34
- $ruby_init("ruby", "-w", "-rubygems", "<%= aOutputInfo.rubyBenchPath %>"<%=
35
- %{, "-f", "s"} if aOutputInfo.specFormat == :rSpec
36
- %>);
34
+ $ruby_init("ruby", "-w", "-rubygems", "-rruby-vpi", "<%= aOutputInfo.rubyBenchPath %>");
37
35
  end
38
36
 
39
37
  always begin
@@ -3,10 +3,9 @@
3
3
  <%= var.name.to_ruby_const_name %> = <%= var.value.verilog_to_ruby %>
4
4
  <% end %>
5
5
 
6
- class << <%= aOutputInfo.designClassName %>
7
- def reset!
6
+ # This method resets the design under test.
7
+ def <%= aOutputInfo.designClassName %>.reset!
8
8
  <% aModuleInfo.ports.select { |p| p.input? }[1..-1].each do |port| # using [1..] because the first signal is the clock %>
9
- <%= port.name %>.hexStrVal = 'x'
9
+ <%= port.name %>.hexStrVal = 'x'
10
10
  <% end %>
11
- end
12
11
  end
@@ -1,15 +1,14 @@
1
1
  # This is a prototype of the design under test.
2
- class << <%= aOutputInfo.designClassName %>
3
- # When prototyping is enabled, this method is invoked
4
- # instead of Vpi::relay_verilog to simulate the design.
5
- def simulate!
6
- # discard old outputs
2
+
3
+ # When prototyping is enabled, relay_verilog invokes this method
4
+ # instead of transferring control to the Verilog simulator.
5
+ def <%= aOutputInfo.designClassName %>.simulate!
6
+ # discard old outputs
7
7
  <% aModuleInfo.ports.reject { |p| p.input? }.each do |port| %>
8
- <%= port.name %>.hexStrVal = 'x'
8
+ <%= port.name %>.hexStrVal = 'x'
9
9
  <% end %>
10
10
 
11
- # process new inputs
11
+ # process new inputs
12
12
 
13
- # produce new outputs
14
- end
13
+ # produce new outputs
15
14
  end
@@ -1033,12 +1033,10 @@ end
1033
1033
  and counter_xunit_design.rb with the following code. This code
1034
1034
  defines the reset! method which resets our Verilog design.
1035
1035
 
1036
- class << Counter
1037
- def reset!
1038
- reset.intVal = 1
1039
- relay_verilog # advance the clock
1040
- reset.intVal = 0
1041
- end
1036
+ def Counter.reset!
1037
+ reset.intVal = 1
1038
+ relay_verilog # advance the clock
1039
+ reset.intVal = 0
1042
1040
  end
1043
1041
 
1044
1042
 
@@ -1052,13 +1050,11 @@ Verilog design” shows the completed prototype for our design.
1052
1050
 
1053
1051
  Figure 4.6. Ruby prototype of our Verilog design
1054
1052
 
1055
- class << Counter
1056
- def simulate!
1057
- if reset.intVal == 1
1058
- count.intVal = 0
1059
- else
1060
- count.intVal += 1
1061
- end
1053
+ def Counter.simulate!
1054
+ if reset.intVal == 1
1055
+ count.intVal = 0
1056
+ else
1057
+ count.intVal += 1
1062
1058
  end
1063
1059
  end
1064
1060
 
@@ -1306,12 +1306,10 @@ kdiff3 --auto --merge --output "$2" "$@" 2>/dev/null
1306
1306
  <para>Replace the contents of the files named <filename>counter_rspec_design.rb</filename> and <filename>counter_xunit_design.rb</filename> with the following code. This code defines the <function>reset!</function> method which resets our &v; design.</para>
1307
1307
 
1308
1308
  <programlisting>
1309
- <token>class</token> &lt;&lt; <constant>Counter</constant>
1310
- <token>def</token> <function>reset!</function>
1311
- <function>reset</function>.<function>intVal</function> = <literal>1</literal>
1312
- <function>relay_verilog</function> <remark># advance the clock</remark>
1313
- <function>reset</function>.<function>intVal</function> = <literal>0</literal>
1314
- <token>end</token>
1309
+ <token>def</token> <constant>Counter</constant>.<function>reset!</function>
1310
+ <function>reset</function>.<function>intVal</function> = <literal>1</literal>
1311
+ <function>relay_verilog</function> <remark># advance the clock</remark>
1312
+ <function>reset</function>.<function>intVal</function> = <literal>0</literal>
1315
1313
  <token>end</token>
1316
1314
  </programlisting>
1317
1315
  </listitem>
@@ -1327,13 +1325,11 @@ kdiff3 --auto --merge --output "$2" "$@" 2>/dev/null
1327
1325
  <figure id="fig..counter_proto.rb">
1328
1326
  <title>Ruby prototype of our &v; design</title>
1329
1327
  <programlisting>
1330
- <token>class</token> &lt;&lt; <constant>Counter</constant>
1331
- <token>def</token> <function>simulate!</function>
1332
- <token>if</token> <function>reset</function>.<function>intVal</function> == <literal>1</literal>
1333
- <function>count</function>.<function>intVal</function> = <literal>0</literal>
1334
- <token>else</token>
1335
- <function>count</function>.<function>intVal</function> += <literal>1</literal>
1336
- <token>end</token>
1328
+ <token>def</token> <constant>Counter</constant>.<function>simulate!</function>
1329
+ <token>if</token> <function>reset</function>.<function>intVal</function> == <literal>1</literal>
1330
+ <function>count</function>.<function>intVal</function> = <literal>0</literal>
1331
+ <token>else</token>
1332
+ <function>count</function>.<function>intVal</function> += <literal>1</literal>
1337
1333
  <token>end</token>
1338
1334
  <token>end</token>
1339
1335
  </programlisting>
@@ -116,21 +116,17 @@
116
116
  <span class="token">end</span>
117
117
  <span class="token">end</span>
118
118
  </pre></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Before we continue…"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png" /></td><th align="left">Before we continue…</th></tr><tr><td align="left" valign="top"><div class="itemizedlist"><ul type="disc"><li><p>Replace the contents of the file named <code class="filename">counter_rspec_spec.rb</code> with the source code shown in <a href="usage.tutorial.html#fig..counter_rspec_spec.rb" title="Figure 4.4. Specification implemented in rSpec format">Figure 4.4, “Specification implemented in rSpec format”</a>.</p></li><li><p>Replace the contents of the file named <code class="filename">counter_xunit_spec.rb</code> with the source code shown in <a href="usage.tutorial.html#fig..counter_xunit_spec.rb" title="Figure 4.5. Specification implemented in xUnit format">Figure 4.5, “Specification implemented in xUnit format”</a>.</p></li><li><p>Replace the contents of the files named <code class="filename">counter_rspec_design.rb</code> and <code class="filename">counter_xunit_design.rb</code> with the following code. This code defines the <code class="function">reset!</code> method which resets our Verilog design.</p><pre class="programlisting">
119
- <span class="token">class</span> &lt;&lt; <code class="constant">Counter</code>
120
- <span class="token">def</span> <code class="function">reset!</code>
121
- <code class="function">reset</code>.<code class="function">intVal</code> = <code class="literal">1</code>
122
- <code class="function">relay_verilog</code> <em><span class="remark"># advance the clock</span></em>
123
- <code class="function">reset</code>.<code class="function">intVal</code> = <code class="literal">0</code>
124
- <span class="token">end</span>
119
+ <span class="token">def</span> <code class="constant">Counter</code>.<code class="function">reset!</code>
120
+ <code class="function">reset</code>.<code class="function">intVal</code> = <code class="literal">1</code>
121
+ <code class="function">relay_verilog</code> <em><span class="remark"># advance the clock</span></em>
122
+ <code class="function">reset</code>.<code class="function">intVal</code> = <code class="literal">0</code>
125
123
  <span class="token">end</span>
126
124
  </pre></li></ul></div></td></tr></table></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="usage.tutorial.implement-proto"></a>Implement the prototype</h3></div></div></div><p>Now that we have a <a href="glossary.html#term..specification">Specification</a> against which to verify our <a href="glossary.html#term..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. <a href="usage.tutorial.html#fig..counter_proto.rb" title="Figure 4.6. Ruby prototype of our Verilog design">Figure 4.6, “Ruby prototype of our Verilog design”</a> shows the completed prototype for our design.</p><div class="figure"><a id="fig..counter_proto.rb"></a><p class="title"><b>Figure 4.6. Ruby prototype of our Verilog design</b></p><pre class="programlisting">
127
- <span class="token">class</span> &lt;&lt; <code class="constant">Counter</code>
128
- <span class="token">def</span> <code class="function">simulate!</code>
129
- <span class="token">if</span> <code class="function">reset</code>.<code class="function">intVal</code> == <code class="literal">1</code>
130
- <code class="function">count</code>.<code class="function">intVal</code> = <code class="literal">0</code>
131
- <span class="token">else</span>
132
- <code class="function">count</code>.<code class="function">intVal</code> += <code class="literal">1</code>
133
- <span class="token">end</span>
125
+ <span class="token">def</span> <code class="constant">Counter</code>.<code class="function">simulate!</code>
126
+ <span class="token">if</span> <code class="function">reset</code>.<code class="function">intVal</code> == <code class="literal">1</code>
127
+ <code class="function">count</code>.<code class="function">intVal</code> = <code class="literal">0</code>
128
+ <span class="token">else</span>
129
+ <code class="function">count</code>.<code class="function">intVal</code> += <code class="literal">1</code>
134
130
  <span class="token">end</span>
135
131
  <span class="token">end</span>
136
132
  </pre></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Before we continue…"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png" /></td><th align="left">Before we continue…</th></tr><tr><td align="left" valign="top"><p>Replace the contents of the files named <code class="filename">counter_rspec_proto.rb</code> and <code class="filename">counter_xunit_proto.rb</code> with the source code shown in <a href="usage.tutorial.html#fig..counter_proto.rb" title="Figure 4.6. Ruby prototype of our Verilog design">Figure 4.6, “Ruby prototype of our Verilog design”</a>.</p></td></tr></table></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="usage.tutorial.test-proto"></a>Verify the prototype</h3></div></div></div><p>Now that we have implemented our prototype, we are ready to verify it against our <a href="glossary.html#term..specification">Specification</a> by running the <a href="glossary.html#term..test">Test</a>. <a href="usage.tutorial.html#fig..test-proto.rspec" title="Figure 4.7. Running a test with specification in rSpec format">Figure 4.7, “Running a test with specification in rSpec format”</a> and <a href="usage.tutorial.html#fig..test-proto.unit-test" title="Figure 4.8. Running a test with specification in xUnit format">Figure 4.8, “Running a test with specification in xUnit format”</a> illustrate this process.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Reuse your past efforts!"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png" /></td><th align="left">Reuse your past efforts!</th></tr><tr><td align="left" valign="top"><p>The <span class="emphasis"><em>same</em></span> specification can be used to verify both prototype and design.</p></td></tr></table></div><p>Here, the <code class="varname">PROTOTYPE</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="varname">PROTOTYPE</code> before running the test, by using your shell's <span><strong class="command">export</strong></span> or <span><strong class="command">setenv</strong></span> command. Finally, the Icarus Verilog simulator, denoted by <em class="replaceable"><code>cver</code></em>, is used to run the simulation.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: What can the test runner do?"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png" /></td><th align="left">What can the test runner do?</th></tr><tr><td align="left" valign="top"><p>If you invoke the test runner (1) without any arguments or (2) with the <code class="option">-T</code> option, it will show you a list of tasks that it can perform for you.</p></td></tr></table></div><div class="figure"><a id="fig..test-proto.rspec"></a><p class="title"><b>Figure 4.7. Running a test with specification in rSpec format</b></p><pre class="screen">
@@ -113,6 +113,60 @@ We <em>strictly</em> follow the RubyGems project&#8217;s <a href="http://www.rub
113
113
  <p id="fn1"><sup>1</sup> C. Gross, &#8220;Explaining Open Source Version Numbers&#8221;, [Online document], 2005 Nov 28, [cited 2006 Aug 27], Available <span class="caps">HTTP</span>: <a href="http://ablog.apress.com/?p=738">http://ablog.apress.com/?p=738</a></p>
114
114
 
115
115
 
116
+ <h1>Version 11.0.0 (2006-11-05)</h1>
117
+
118
+
119
+ <h2>Summary</h2>
120
+
121
+
122
+ <p>This release shortens generated Ruby benches and uses the less confusing notation for defining <a href="http://wiki.rubygarden.org/Ruby/page/show/SingletonTutorial">singleton methods</a> in generated designs and prototypes.</p>
123
+
124
+
125
+ <h2>Notice</h2>
126
+
127
+
128
+ <ul>
129
+ <li>The arguments for the <a href="ref/ruby/classes/RubyVpi.html"><code>RubyVPI.init_bench</code> method</a> have changed.</li>
130
+ </ul>
131
+
132
+
133
+ <ul>
134
+ <li><strong>generate_test.rb</strong> no longer emits undocumented status indicators: <em>name</em> and <em>format</em>.</li>
135
+ </ul>
136
+
137
+
138
+ <ul>
139
+ <li>The source code is no longer distributed as a <strong>zip</strong> package, because it seems to be quite underutilized in comparison to the <strong>tgz</strong> and <strong>gem</strong> packages.</li>
140
+ </ul>
141
+
142
+
143
+ <h2>Detail</h2>
144
+
145
+
146
+ <ul>
147
+ <li>Generated Ruby benches have been shortened to just <em>one</em> line of code!</li>
148
+ </ul>
149
+
150
+
151
+ <ul>
152
+ <li>The less confusing notation of <pre>def some_object.a_singleton_method
153
+ do_stuff
154
+ end</pre> is now used instead of the <pre>class &lt;&lt; some_object
155
+ def a_singleton_method
156
+ do_stuff
157
+ end
158
+ end</pre> notation.
159
+ <ul>
160
+ <li>The tutorial and examples have been updated accordingly.</li>
161
+ </ul></li>
162
+ </ul>
163
+
164
+
165
+ <ul>
166
+ <li>The pipelined <span class="caps">ALU</span> example now has an updated <code>IntegerGenerator</code> class.</li>
167
+ </ul>
168
+
169
+
116
170
  <h1>Version 10.0.0 (2006-11-05)</h1>
117
171
 
118
172
 
@@ -18,6 +18,60 @@ We <em>strictly</em> follow the RubyGems project&#8217;s <a href="http://www.rub
18
18
  <p id="fn1"><sup>1</sup> C. Gross, &#8220;Explaining Open Source Version Numbers&#8221;, [Online document], 2005 Nov 28, [cited 2006 Aug 27], Available <span class="caps">HTTP</span>: <a href="http://ablog.apress.com/?p=738">http://ablog.apress.com/?p=738</a></p>
19
19
 
20
20
 
21
+ <h1>Version 11.0.0 (2006-11-05)</h1>
22
+
23
+
24
+ <h2>Summary</h2>
25
+
26
+
27
+ <p>This release shortens generated Ruby benches and uses the less confusing notation for defining <a href="http://wiki.rubygarden.org/Ruby/page/show/SingletonTutorial">singleton methods</a> in generated designs and prototypes.</p>
28
+
29
+
30
+ <h2>Notice</h2>
31
+
32
+
33
+ <ul>
34
+ <li>The arguments for the <a href="ref/ruby/classes/RubyVpi.html"><code>RubyVPI.init_bench</code> method</a> have changed.</li>
35
+ </ul>
36
+
37
+
38
+ <ul>
39
+ <li><strong>generate_test.rb</strong> no longer emits undocumented status indicators: <em>name</em> and <em>format</em>.</li>
40
+ </ul>
41
+
42
+
43
+ <ul>
44
+ <li>The source code is no longer distributed as a <strong>zip</strong> package, because it seems to be quite underutilized in comparison to the <strong>tgz</strong> and <strong>gem</strong> packages.</li>
45
+ </ul>
46
+
47
+
48
+ <h2>Detail</h2>
49
+
50
+
51
+ <ul>
52
+ <li>Generated Ruby benches have been shortened to just <em>one</em> line of code!</li>
53
+ </ul>
54
+
55
+
56
+ <ul>
57
+ <li>The less confusing notation of <pre>def some_object.a_singleton_method
58
+ do_stuff
59
+ end</pre> is now used instead of the <pre>class &lt;&lt; some_object
60
+ def a_singleton_method
61
+ do_stuff
62
+ end
63
+ end</pre> notation.
64
+ <ul>
65
+ <li>The tutorial and examples have been updated accordingly.</li>
66
+ </ul></li>
67
+ </ul>
68
+
69
+
70
+ <ul>
71
+ <li>The pipelined <span class="caps">ALU</span> example now has an updated <code>IntegerGenerator</code> class.</li>
72
+ </ul>
73
+
74
+
21
75
  <h1>Version 10.0.0 (2006-11-05)</h1>
22
76
 
23
77
 
@@ -18,10 +18,21 @@
18
18
  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
  =end
20
20
 
21
- # Provides configuration information of the Ruby-VPI project.
22
21
  module RubyVpi
23
- # Initializes the current bench using the given parameters.
24
- def RubyVpi.init_bench aTestPrefix, aDesignClassId
22
+ # Initializes the current bench by loading:
23
+ # 1. the design.rb file
24
+ # 2. the proto.rb file (if prototyping is enabled)
25
+ # 3. the spec.rb file
26
+ #
27
+ # aDesignId:: The name of the Ruby interface to the design under test.
28
+ # aSpecFormat:: The format of the specification.
29
+ def RubyVpi.init_bench aDesignId, aSpecFormat
30
+ if caller.find {|s| s =~ /^(.*?)_bench.rb:/}
31
+ testName = $1
32
+ else
33
+ raise 'Unable to determine name of test.'
34
+ end
35
+
25
36
  # set up the VPI utility layer
26
37
  require 'ruby-vpi/vpi'
27
38
 
@@ -29,8 +40,18 @@ module RubyVpi
29
40
  include Vpi
30
41
  end
31
42
 
32
- # service the $ruby_init() callback
33
- relay_verilog
43
+ # set up the specification library
44
+ case aSpecFormat
45
+ when :xUnit
46
+ require 'test/unit'
47
+
48
+ when :rSpec
49
+ ARGV.concat %w[-f s]
50
+ require 'ruby-vpi/rspec'
51
+ end
52
+
53
+ # service the $ruby_init() task
54
+ relay_verilog
34
55
 
35
56
  # set up code coverage analysis
36
57
  unless (ENV['COVERAGE'] || '').empty?
@@ -39,22 +60,22 @@ module RubyVpi
39
60
  RubyVpi.with_coverage_analysis do |a|
40
61
  a.dump_coverage_info [
41
62
  Rcov::TextReport.new,
42
- Rcov::HTMLCoverage.new(:destdir => "#{aTestPrefix}_coverage")
63
+ Rcov::HTMLCoverage.new(:destdir => "#{testName}_coverage")
43
64
  ]
44
65
  end
45
66
  end
46
67
 
47
68
  # load the design under test
48
- unless design = vpi_handle_by_name("#{aTestPrefix}_bench", nil)
49
- raise "Verilog bench for test #{aTestPrefix.inspect} is inaccessible."
69
+ unless design = vpi_handle_by_name("#{testName}_bench", nil)
70
+ raise "Verilog bench for test #{testName.inspect} is inaccessible."
50
71
  end
51
72
 
52
- Kernel.const_set(aDesignClassId, design)
53
- require "#{aTestPrefix}_design.rb"
73
+ Kernel.const_set(aDesignId, design)
74
+ require "#{testName}_design.rb"
54
75
 
55
76
  # load the design's prototype
56
77
  unless (ENV['PROTOTYPE'] || '').empty?
57
- require "#{aTestPrefix}_proto.rb"
78
+ require "#{testName}_proto.rb"
58
79
 
59
80
  Vpi.class_eval do
60
81
  define_method :relay_verilog do
@@ -62,12 +83,14 @@ module RubyVpi
62
83
  end
63
84
  end
64
85
 
65
- puts "#{Config::PROJECT_NAME}: prototype has been enabled for test #{aTestPrefix.inspect}"
86
+ puts "#{Config::PROJECT_NAME}: prototype has been enabled for test #{testName.inspect}"
66
87
  end
67
88
 
68
- require "#{aTestPrefix}_spec.rb"
89
+ # load the design's specification
90
+ require "#{testName}_spec.rb"
69
91
  end
70
92
 
93
+ # Provides information about the Ruby-VPI project's configuration.
71
94
  module Config
72
95
  PROJECT_ID = 'ruby-vpi'
73
96
  PROJECT_NAME = 'Ruby-VPI'
@@ -76,6 +99,8 @@ module RubyVpi
76
99
  PROJECT_DETAIL = "#{PROJECT_NAME} is a #{PROJECT_SUMMARY}. It lets you create complex Verilog test benches easily and wholly in Ruby."
77
100
 
78
101
  Simulator = Struct.new(:id, :name, :compiler_args, :linker_args)
102
+
103
+ # List of supported Verilog simulators.
79
104
  SIMULATORS = [
80
105
  Simulator.new(:cver, 'GPL Cver', '-DPRAGMATIC_CVER', ''),
81
106
  Simulator.new(:ivl, 'Icarus Verilog', '-DICARUS_VERILOG', ''),
@@ -1,9 +1,3 @@
1
1
  # This file is the Ruby side of the bench.
2
2
 
3
- require 'ruby-vpi'
4
- require 'ruby-vpi/rspec'
5
-
6
- RubyVpi.init_bench 'counter_rspec', :Counter
7
-
8
- # service the $ruby_relay callback
9
- # The rSpec library will take control henceforth.
3
+ RubyVpi.init_bench :Counter, :rSpec
@@ -12,7 +12,7 @@ module counter_rspec_bench;
12
12
  // connect to the Ruby side of this bench
13
13
  initial begin
14
14
  clock = 0;
15
- $ruby_init("ruby", "-w", "-rubygems", "counter_rspec_bench.rb", "-f", "s");
15
+ $ruby_init("ruby", "-w", "-rubygems", "-rruby-vpi", "counter_rspec_bench.rb");
16
16
  end
17
17
 
18
18
  always begin
@@ -1,8 +1,8 @@
1
1
  # This is a Ruby interface to the design under test.
2
- class << Counter
3
- def reset!
4
- reset.intVal = 1
5
- relay_verilog
6
- reset.intVal = 0
7
- end
2
+
3
+ # This method resets the design under test.
4
+ def Counter.reset!
5
+ reset.intVal = 1
6
+ relay_verilog
7
+ reset.intVal = 0
8
8
  end
@@ -1,12 +1,11 @@
1
1
  # This is a prototype of the design under test.
2
- class << Counter
3
- # When prototyping is enabled, this method is invoked
4
- # instead of Vpi::relay_verilog to simulate the design.
5
- def simulate!
6
- if reset.intVal == 1
7
- count.intVal = 0
8
- else
9
- count.intVal += 1
10
- end
2
+
3
+ # When prototyping is enabled, relay_verilog invokes this method
4
+ # instead of transferring control to the Verilog simulator.
5
+ def Counter.simulate!
6
+ if reset.intVal == 1
7
+ count.intVal = 0
8
+ else
9
+ count.intVal += 1
11
10
  end
12
11
  end
@@ -1,9 +1,3 @@
1
1
  # This file is the Ruby side of the bench.
2
2
 
3
- require 'ruby-vpi'
4
- require 'test/unit'
5
-
6
- RubyVpi.init_bench 'counter_xunit', :Counter
7
-
8
- # service the $ruby_relay callback
9
- # The xUnit library will take control henceforth.
3
+ RubyVpi.init_bench :Counter, :xUnit
@@ -12,7 +12,7 @@ module counter_xunit_bench;
12
12
  // connect to the Ruby side of this bench
13
13
  initial begin
14
14
  clock = 0;
15
- $ruby_init("ruby", "-w", "-rubygems", "counter_xunit_bench.rb");
15
+ $ruby_init("ruby", "-w", "-rubygems", "-rruby-vpi", "counter_xunit_bench.rb");
16
16
  end
17
17
 
18
18
  always begin
@@ -1,8 +1,8 @@
1
1
  # This is a Ruby interface to the design under test.
2
- class << Counter
3
- def reset!
4
- reset.intVal = 1
5
- relay_verilog
6
- reset.intVal = 0
7
- end
2
+
3
+ # This method resets the design under test.
4
+ def Counter.reset!
5
+ reset.intVal = 1
6
+ relay_verilog
7
+ reset.intVal = 0
8
8
  end
@@ -1,12 +1,11 @@
1
1
  # This is a prototype of the design under test.
2
- class << Counter
3
- # When prototyping is enabled, this method is invoked
4
- # instead of Vpi::relay_verilog to simulate the design.
5
- def simulate!
6
- if reset.intVal == 1
7
- count.intVal = 0
8
- else
9
- count.intVal += 1
10
- end
2
+
3
+ # When prototyping is enabled, relay_verilog invokes this method
4
+ # instead of transferring control to the Verilog simulator.
5
+ def Counter.simulate!
6
+ if reset.intVal == 1
7
+ count.intVal = 0
8
+ else
9
+ count.intVal += 1
11
10
  end
12
11
  end
@@ -1,9 +1,3 @@
1
1
  # This file is the Ruby side of the bench.
2
2
 
3
- require 'ruby-vpi'
4
- require 'test/unit'
5
-
6
- RubyVpi.init_bench 'hw5_unit_test', :Hw5_unit
7
-
8
- # service the $ruby_relay callback
9
- # The xUnit library will take control henceforth.
3
+ RubyVpi.init_bench :Hw5_unit, :xUnit
@@ -17,7 +17,7 @@ module hw5_unit_test_bench;
17
17
  // connect to the Ruby side of this bench
18
18
  initial begin
19
19
  clk = 0;
20
- $ruby_init("ruby", "-w", "-rubygems", "hw5_unit_test_bench.rb");
20
+ $ruby_init("ruby", "-w", "-rubygems", "-rruby-vpi", "hw5_unit_test_bench.rb");
21
21
  end
22
22
 
23
23
  always begin
@@ -11,23 +11,22 @@ OPERATIONS = (OP_NOP..OP_MULT).to_a
11
11
  # Number of cycles needed to reset this design.
12
12
  RESET_DELAY = 5
13
13
 
14
- class << Hw5_unit
15
- def reset!
16
- reset.hexStrVal = 'x'
17
- in_databits.hexStrVal = 'x'
18
- a.hexStrVal = 'x'
19
- b.hexStrVal = 'x'
20
- in_op.hexStrVal = 'x'
14
+ # This method resets the design under test.
15
+ def Hw5_unit.reset!
16
+ reset.hexStrVal = 'x'
17
+ in_databits.hexStrVal = 'x'
18
+ a.hexStrVal = 'x'
19
+ b.hexStrVal = 'x'
20
+ in_op.hexStrVal = 'x'
21
21
 
22
22
 
23
- reset.intVal = 1
23
+ reset.intVal = 1
24
24
 
25
- RESET_DELAY.times do
26
- relay_verilog
27
- end
28
-
29
- reset.intVal = 0
25
+ RESET_DELAY.times do
26
+ relay_verilog
30
27
  end
28
+
29
+ reset.intVal = 0
31
30
  end
32
31
 
33
32
 
@@ -1,17 +1,7 @@
1
1
  # This is a prototype of the design under test.
2
- class << Hw5_unit
3
- # When prototyping is enabled, this method is invoked
4
- # instead of Vpi::relay_verilog to simulate the design.
5
- def simulate!
6
- raise NotImplementedError, "Prototype is not yet implemented."
7
2
 
8
- # discard old outputs
9
- res.hexStrVal = 'x'
10
- out_databits.hexStrVal = 'x'
11
- out_op.hexStrVal = 'x'
12
-
13
- # process new inputs
14
-
15
- # produce new outputs
16
- end
3
+ # When prototyping is enabled, relay_verilog invokes this method
4
+ # instead of transferring control to the Verilog simulator.
5
+ def Hw5_unit.simulate!
6
+ raise NotImplementedError, "Prototype is not yet implemented."
17
7
  end
@@ -20,7 +20,7 @@
20
20
 
21
21
  # This file is a behavioral specification for the design under test.
22
22
 
23
- require 'InputGenerator'
23
+ require 'int_gen'
24
24
 
25
25
  class Hw5_unit_test_spec < Test::Unit::TestCase
26
26
  # Number of input sequences to test.
@@ -34,7 +34,7 @@ class Hw5_unit_test_spec < Test::Unit::TestCase
34
34
 
35
35
  def setup
36
36
  Hw5_unit.reset!
37
- @inputGen = InputGenerator.new(WIDTH)
37
+ @intGen = IntegerGenerator.new(WIDTH)
38
38
  end
39
39
 
40
40
  def test_pipeline
@@ -47,8 +47,8 @@ class Hw5_unit_test_spec < Test::Unit::TestCase
47
47
  op = Operation.new(
48
48
  OPERATIONS[rand(OPERATIONS.size)],
49
49
  numIssued % OPERATION_TAG_LIMIT,
50
- @inputGen.gen,
51
- @inputGen.gen
50
+ @intGen.random,
51
+ @intGen.random
52
52
  )
53
53
 
54
54
  Hw5_unit.a.intVal = op.arg1
@@ -18,52 +18,43 @@
18
18
  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
  =end
20
20
 
21
- # Generates random input sequences of configurable length.
22
- class InputGenerator
21
+ # Generates random integers of configurable length.
22
+ class IntegerGenerator
23
23
  # the first 1000 prime numbers, gotten from <http://en.wikipedia.org/wiki/List_of_prime_numbers#The_first_1000_prime_numbers>
24
- PrimeNums = [
24
+ PRIMES = [
25
25
  2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919
26
26
  ]
27
27
 
28
- # Constructs a new input sequence generator.
29
- # bits:: Number of bits that can be used to represent a generated input sequence
30
- def initialize(bits)
31
- self.bits = bits
32
- end
28
+ attr_reader :bits
33
29
 
34
- # returns the number of bits that can be used to represent a generated input sequence
35
- def bits
36
- @inputBits
37
- end
30
+ # Generates random integers representable by the given number of bits.
31
+ def initialize aBits
32
+ @bits = aBits
33
+ @limit = 2 ** @bits
38
34
 
39
- # sets the number of bits that can be used to represent a generated input sequence
40
- def bits=(num)
41
- @inputBits = num
42
- @inputLimit = 2 ** @inputBits
35
+ PRIMES.reject! {|i| i > @limit}
43
36
  end
44
37
 
45
- # generates a random input sequence
46
- def gen
38
+ # returns a random input sequence
39
+ def random
47
40
  choices = [
48
41
  0,
49
42
  1,
50
- gen_prime,
51
- gen_power_of_two,
52
- rand(@inputLimit),
43
+ prime,
44
+ power_of_two,
45
+ rand(@limit),
53
46
  ]
54
47
 
55
48
  choices[rand(choices.length)]
56
49
  end
57
50
 
58
- # generates a random prime number
59
- def gen_prime
60
- prime = PrimeNums[rand(PrimeNums.length)]
61
- prime < @inputLimit ? prime : 2
51
+ # returns a random prime integer
52
+ def prime
53
+ PRIMES[rand(PRIMES.length)]
62
54
  end
63
55
 
64
- # generates a random power-of-two number
65
- def gen_power_of_two
66
- power = rand(@inputBits) + 1
67
- (2 ** power) - 1
56
+ # returns a random power-of-two integer
57
+ def power_of_two
58
+ 2 ** rand(@bits)
68
59
  end
69
60
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ruby-vpi
5
5
  version: !ruby/object:Gem::Version
6
- version: 10.0.0
6
+ version: 11.0.0
7
7
  date: 2006-11-05 00:00:00 -08:00
8
8
  summary: Ruby interface to Verilog VPI.
9
9
  require_paths:
@@ -188,7 +188,6 @@ files:
188
188
  - samp/counter
189
189
  - samp/pipelined_alu/TestHw5UnitModel.rb
190
190
  - samp/pipelined_alu/Hw5UnitModel.rb
191
- - samp/pipelined_alu/InputGenerator.rb
192
191
  - samp/pipelined_alu/README
193
192
  - samp/pipelined_alu/hw5_unit.v
194
193
  - samp/pipelined_alu/Rakefile
@@ -198,6 +197,7 @@ files:
198
197
  - samp/pipelined_alu/hw5_unit_test_bench.rb
199
198
  - samp/pipelined_alu/hw5_unit_test_design.rb
200
199
  - samp/pipelined_alu/hw5_unit_test_proto.rb
200
+ - samp/pipelined_alu/int_gen.rb
201
201
  - samp/counter/counter.v
202
202
  - samp/counter/Rakefile
203
203
  - samp/counter/counter_xunit_bench.v
@@ -207,10 +207,10 @@ files:
207
207
  - samp/counter/counter_xunit_bench.rb
208
208
  - samp/counter/counter_xunit_runner.rake
209
209
  - samp/counter/counter_xunit_spec.rb
210
- - samp/counter/counter_rspec_bench.rb
211
210
  - samp/counter/counter_xunit_proto.rb
212
211
  - samp/counter/counter_rspec_design.rb
213
212
  - samp/counter/counter_rspec_bench.v
213
+ - samp/counter/counter_rspec_bench.rb
214
214
  - samp/counter/counter_rspec_runner.rake
215
215
  test_files: []
216
216