From: "Kikutani, Makoto" Date: 2000-08-08T00:31:58+09:00 Subject: [ruby-list:24126] embedded Ruby for Verilog VerilogにRubyを組み込もうと思ってはじめたのですが、最初からつまづきました。 # 以下 VerilogのPLI(Programming Language Interface)の関数が出てきますが # 本筋に関係ないので無視してください void init_ruby() { int state; ruby_init(); rb_protect((VALUE (*)())ruby_load, (VALUE) "./verilog-init.rb", &state); if (state) { vpi_printf("ERROR: verilog-init.rb failed\n"); tf_dofinish(); } } などを作り、Verilog起動時に呼ぶようにします。verilog-init.rbの中身は def hello print "Hello Verilog-Ruby World!\n" end だけです。 void ruby_execute_command(char *name) { int state; ID id; id = rb_intern(name); if (rb_method_boundp(rb_cObject, id, NOEX_PUBLIC)) { rb_protect((VALUE (*)())ruby_call_method, id, &state); if (state) { vpi_printf("ERROR: ruby_call_method for %s failed\n", name); tf_dofinish(); } } else { vpi_printf("ERROR: %s not found\n", name); tf_dofinish(); } } などを作り、PLIでユーザ定義の関数 $hello を書き、Verilogのモデルで $hello を呼ぶと ruby_execute_command("hello"); が実行されるようにします。 実行してみると、 ERROR: hello not found になってしまい、helloというメソッドをみつけられません。 helloのかわりに、Kernel.helloとかしてもだめ。 Ruby本9章のJed/Rubyの例を参考にしているのですが、そもそも、 1) 最初にRubyスクリプト(この例ではverilog-init.rb)を読み 2) あとから、そのスクリプトで定義されたメソッドを呼ぶ ということはできるのでしょうか? -- 人生を背負い投げ 菊谷 誠(Kikutani Makoto) g@kondara.org or kikutani@galaxy.net