ref/ruby/classes/Vpi/Handle.src/M000040.html in ruby-vpi-13.0.0 vs ref/ruby/classes/Vpi/Handle.src/M000040.html in ruby-vpi-14.0.0
- old
+ new
@@ -3,66 +3,85 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title>method_missing (Vpi::Handle)</title>
+ <title>put_value (Vpi::Handle)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/vpi.rb, line 223</span>
-223: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span> <span class="ruby-identifier">aMeth</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">aBlockArg</span>
-224: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> = <span class="ruby-identifier">vpi_handle_by_name</span>(<span class="ruby-identifier">aMeth</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">self</span>)
-225: <span class="ruby-comment cmt"># cache the child for future accesses, in order to cut down number of calls to method_missing</span>
-226: (<span class="ruby-keyword kw">class</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>).<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
-227: <span class="ruby-identifier">define_method</span> <span class="ruby-identifier">aMeth</span> <span class="ruby-keyword kw">do</span>
-228: <span class="ruby-identifier">child</span>
-229: <span class="ruby-keyword kw">end</span>
-230: <span class="ruby-keyword kw">end</span>
-231:
-232: <span class="ruby-identifier">child</span>
-233:
-234: <span class="ruby-keyword kw">else</span>
-235: <span class="ruby-identifier">prop</span> = <span class="ruby-ivar">@@propCache</span>[<span class="ruby-identifier">aMeth</span>]
-236:
-237: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">operation</span>
-238: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">operation</span>, <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">aBlockArg</span>)
-239:
-240: <span class="ruby-keyword kw">else</span>
-241: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">accessor</span>
-242: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:d</span> <span class="ruby-comment cmt"># delay values</span>
-243: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">'processing of delay values is not yet implemented.'</span>
-244: <span class="ruby-comment cmt"># TODO: vpi_put_delays</span>
-245: <span class="ruby-comment cmt"># TODO: vpi_get_delays</span>
-246:
-247: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:l</span> <span class="ruby-comment cmt"># logic values</span>
-248: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span>
-249: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">aArgs</span>.<span class="ruby-identifier">shift</span>
-250: <span class="ruby-identifier">put_value</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">aArgs</span>)
-251: <span class="ruby-keyword kw">else</span>
-252: <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>)
-253: <span class="ruby-keyword kw">end</span>
-254:
-255: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:i</span> <span class="ruby-comment cmt"># integer values</span>
-256: <span class="ruby-identifier">vpi_get</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span>
-257:
-258: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:b</span> <span class="ruby-comment cmt"># boolean values</span>
-259: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span>
-260: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">vpi_get</span>(<span class="ruby-identifier">prop</span>, <span class="ruby-keyword kw">self</span>)
-261: <span class="ruby-identifier">value</span> <span class="ruby-operator">&&</span> (<span class="ruby-identifier">value</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>) <span class="ruby-comment cmt"># zero is false in C</span>
-262: <span class="ruby-keyword kw">end</span>
-263:
-264: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:s</span> <span class="ruby-comment cmt"># string values</span>
-265: <span class="ruby-identifier">vpi_get_str</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span>
-266:
-267: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:h</span> <span class="ruby-comment cmt"># handle values</span>
-268: <span class="ruby-identifier">vpi_handle</span>(<span class="ruby-identifier">prop</span>.<span class="ruby-identifier">type</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">prop</span>.<span class="ruby-identifier">assignment</span>
-269:
-270: <span class="ruby-keyword kw">else</span>
-271: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>, <span class="ruby-node">"unable to access VPI property #{prop.name.inspect} through method #{aMeth.inspect} with arguments #{aArgs.inspect} for handle #{self}"</span>
-272: <span class="ruby-keyword kw">end</span>
-273: <span class="ruby-keyword kw">end</span>
-274: <span class="ruby-keyword kw">end</span>
-275: <span class="ruby-keyword kw">end</span></pre>
+ <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/vpi.rb, line 125</span>
+125: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_value</span> <span class="ruby-identifier">aValue</span>, <span class="ruby-identifier">aFormat</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">aTime</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">aDelay</span> = <span class="ruby-constant">VpiNoDelay</span>
+126: <span class="ruby-identifier">aFormat</span> =
+127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">aFormat</span>
+128: <span class="ruby-identifier">resolve_prop_type</span>(<span class="ruby-identifier">aFormat</span>)
+129: <span class="ruby-keyword kw">else</span>
+130: <span class="ruby-identifier">get_value_wrapper</span>(<span class="ruby-constant">VpiObjTypeVal</span>).<span class="ruby-identifier">format</span>
+131: <span class="ruby-keyword kw">end</span>
+132:
+133: <span class="ruby-identifier">newVal</span> = <span class="ruby-constant">S_vpi_value</span>.<span class="ruby-identifier">new</span>
+134: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">format</span> = <span class="ruby-identifier">aFormat</span>
+135:
+136: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">aFormat</span>
+137: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiBinStrVal</span>, <span class="ruby-constant">VpiOctStrVal</span>, <span class="ruby-constant">VpiDecStrVal</span>, <span class="ruby-constant">VpiHexStrVal</span>, <span class="ruby-constant">VpiStringVal</span>
+138: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">str</span> = <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_s</span>
+139:
+140: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiScalarVal</span>
+141: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">scalar</span> = <span class="ruby-identifier">aValue</span>
+142:
+143: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiIntVal</span>
+144: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">format</span> = <span class="ruby-constant">VpiHexStrVal</span>
+145: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">str</span> = <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-value">16</span>)
+146:
+147: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiRealVal</span>
+148: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">real</span> = <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_f</span>
+149:
+150: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiTimeVal</span>
+151: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">time</span> = <span class="ruby-identifier">aValue</span>
+152:
+153: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiVectorVal</span>
+154: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">vector</span> = <span class="ruby-identifier">aValue</span>
+155:
+156: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiStrengthVal</span>
+157: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">strength</span> = <span class="ruby-identifier">aValue</span>
+158:
+159: <span class="ruby-keyword kw">else</span>
+160: <span class="ruby-identifier">raise</span> <span class="ruby-node">"unknown S_vpi_value.format: #{newVal.format}"</span>
+161: <span class="ruby-keyword kw">end</span>
+162:
+163: <span class="ruby-identifier">vpi_put_value</span> <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">newVal</span>, <span class="ruby-identifier">aTime</span>, <span class="ruby-identifier">aDelay</span>
+164:
+165: <span class="ruby-comment cmt"># ensure that value was written correctly</span>
+166: <span class="ruby-identifier">readenVal</span> = <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">aFormat</span>)
+167:
+168: <span class="ruby-identifier">writtenCorrectly</span> =
+169: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">aFormat</span>
+170: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiBinStrVal</span>, <span class="ruby-constant">VpiOctStrVal</span>, <span class="ruby-constant">VpiDecStrVal</span>, <span class="ruby-constant">VpiHexStrVal</span>
+171: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">aValue</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[xz]/i</span> <span class="ruby-comment cmt"># TODO: verify 'z' behavior</span>
+172: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[xz]/i</span>
+173: <span class="ruby-keyword kw">else</span>
+174: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_s</span>
+175: <span class="ruby-keyword kw">end</span>
+176:
+177: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiStringVal</span>
+178: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_s</span>
+179:
+180: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiIntVal</span>
+181: <span class="ruby-comment cmt"># allow for register overflow when limit reached</span>
+182: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> (<span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">%</span> (<span class="ruby-value">2</span> <span class="ruby-operator">**</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">vpiSize</span>))
+183:
+184: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiRealVal</span>
+185: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_f</span>
+186:
+187: <span class="ruby-keyword kw">else</span>
+188: <span class="ruby-keyword kw">true</span>
+189: <span class="ruby-keyword kw">end</span>
+190:
+191: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">writtenCorrectly</span>
+192: <span class="ruby-identifier">raise</span> <span class="ruby-node">"value written (#{aValue.inspect}) does not match value read (#{readenVal.inspect}) from handle #{self}"</span>
+193: <span class="ruby-keyword kw">end</span>
+194:
+195: <span class="ruby-identifier">aValue</span>
+196: <span class="ruby-keyword kw">end</span></pre>
</body>
</html>
\ No newline at end of file