ref/ruby/classes/Vpi/Handle.src/M000091.html in ruby-vpi-11.1.0 vs ref/ruby/classes/Vpi/Handle.src/M000091.html in ruby-vpi-11.1.1

- old
+ new

@@ -3,22 +3,85 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>inspect (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 194</span> -194: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span> <span class="ruby-operator">*</span><span class="ruby-identifier">aPropNames</span> -195: <span class="ruby-identifier">aPropNames</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-identifier">:fullName</span>, <span class="ruby-identifier">:size</span>, <span class="ruby-identifier">:file</span>, <span class="ruby-identifier">:lineNo</span> -196: -197: <span class="ruby-identifier">aPropNames</span>.<span class="ruby-identifier">map!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> -198: <span class="ruby-node">&quot;#{name}=#{self.send(name.to_sym)}&quot;</span> -199: <span class="ruby-keyword kw">end</span> -200: -201: <span class="ruby-node">&quot;#&lt;Vpi::Handle #{vpiType_s} #{aPropNames.join(', ')}&gt;&quot;</span> -202: <span class="ruby-keyword kw">end</span></pre> + <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/vpi.rb, line 103</span> +103: <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> +104: <span class="ruby-identifier">aFormat</span> = +105: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">aFormat</span> +106: <span class="ruby-identifier">resolve_prop_type</span>(<span class="ruby-identifier">aFormat</span>) +107: <span class="ruby-keyword kw">else</span> +108: <span class="ruby-identifier">get_value_wrapper</span>(<span class="ruby-constant">VpiObjTypeVal</span>).<span class="ruby-identifier">format</span> +109: <span class="ruby-keyword kw">end</span> +110: +111: <span class="ruby-identifier">newVal</span> = <span class="ruby-constant">S_vpi_value</span>.<span class="ruby-identifier">new</span> +112: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">format</span> = <span class="ruby-identifier">aFormat</span> +113: +114: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">aFormat</span> +115: <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> +116: <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> +117: +118: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiScalarVal</span> +119: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">scalar</span> = <span class="ruby-identifier">aValue</span> +120: +121: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiIntVal</span> +122: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">format</span> = <span class="ruby-constant">VpiHexStrVal</span> +123: <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>) +124: +125: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiRealVal</span> +126: <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> +127: +128: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiTimeVal</span> +129: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">time</span> = <span class="ruby-identifier">aValue</span> +130: +131: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiVectorVal</span> +132: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">vector</span> = <span class="ruby-identifier">aValue</span> +133: +134: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiStrengthVal</span> +135: <span class="ruby-identifier">newVal</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">strength</span> = <span class="ruby-identifier">aValue</span> +136: +137: <span class="ruby-keyword kw">else</span> +138: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;unknown S_vpi_value.format: #{newVal.format}&quot;</span> +139: <span class="ruby-keyword kw">end</span> +140: +141: <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> +142: +143: <span class="ruby-comment cmt"># ensure that value was written correctly</span> +144: <span class="ruby-identifier">readenVal</span> = <span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">aFormat</span>) +145: +146: <span class="ruby-identifier">writtenCorrectly</span> = +147: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">aFormat</span> +148: <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> +149: <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> +150: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[xz]/i</span> +151: <span class="ruby-keyword kw">else</span> +152: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_s</span> +153: <span class="ruby-keyword kw">end</span> +154: +155: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiStringVal</span> +156: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_s</span> +157: +158: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiIntVal</span> +159: <span class="ruby-comment cmt"># allow for register overflow when limit reached</span> +160: <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>)) +161: +162: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">VpiRealVal</span> +163: <span class="ruby-identifier">readenVal</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">aValue</span>.<span class="ruby-identifier">to_f</span> +164: +165: <span class="ruby-keyword kw">else</span> +166: <span class="ruby-keyword kw">true</span> +167: <span class="ruby-keyword kw">end</span> +168: +169: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">writtenCorrectly</span> +170: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;value written (#{aValue.inspect}) does not match value read (#{readenVal.inspect}) from handle #{self}&quot;</span> +171: <span class="ruby-keyword kw">end</span> +172: +173: <span class="ruby-identifier">aValue</span> +174: <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file