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