ruby-vpi 18.0.2 → 19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. data/Rakefile +15 -19
  2. data/bin/generate/proto.rb +15 -10
  3. data/bin/ruby-vpi +2 -0
  4. data/doc/README +3 -5
  5. data/doc/Rakefile +3 -3
  6. data/doc/common.css +24 -136
  7. data/doc/common.tpl +48 -37
  8. data/doc/figures/figures.dia +19 -19
  9. data/doc/figures/ruby_relay.png +0 -0
  10. data/doc/history.html +252 -67
  11. data/doc/history.inc +98 -1
  12. data/doc/history.yaml +105 -0
  13. data/doc/intro.inc +43 -32
  14. data/doc/lib/doc_format.rb +19 -13
  15. data/doc/lib/doc_proxy.rb +7 -7
  16. data/doc/manual.doc +156 -117
  17. data/doc/manual.html +601 -560
  18. data/doc/memo.html +29 -25
  19. data/doc/print.css +63 -4
  20. data/doc/readme.doc +4 -6
  21. data/doc/readme.html +129 -111
  22. data/doc/rss.xml +168 -7
  23. data/doc/screen.css +146 -0
  24. data/doc/spacing.css +57 -0
  25. data/{samp → examples}/counter/RSpec/Rakefile +0 -0
  26. data/{samp → examples}/counter/RSpec/counter_design.rb +0 -0
  27. data/examples/counter/RSpec/counter_proto.rb +9 -0
  28. data/{samp → examples}/counter/RSpec/counter_runner.rake +0 -0
  29. data/{samp → examples}/counter/RSpec/counter_spec.rb +0 -0
  30. data/{samp → examples}/counter/Rakefile +0 -0
  31. data/{samp → examples}/counter/counter.v +0 -0
  32. data/{samp → examples}/counter/xUnit/Rakefile +0 -0
  33. data/{samp → examples}/counter/xUnit/counter_bench.rb +0 -0
  34. data/{samp → examples}/counter/xUnit/counter_bench.v +0 -0
  35. data/{samp → examples}/counter/xUnit/counter_design.rb +0 -0
  36. data/examples/counter/xUnit/counter_proto.rb +9 -0
  37. data/{samp → examples}/counter/xUnit/counter_runner.rake +0 -0
  38. data/{samp → examples}/counter/xUnit/counter_spec.rb +0 -0
  39. data/{samp → examples}/pipelined_alu/Hw5UnitModel.rb +0 -0
  40. data/{samp → examples}/pipelined_alu/README +0 -0
  41. data/{samp → examples}/pipelined_alu/Rakefile +0 -0
  42. data/{samp → examples}/pipelined_alu/TestHw5UnitModel.rb +0 -0
  43. data/{samp → examples}/pipelined_alu/hw5_unit.v +0 -0
  44. data/{samp → examples}/pipelined_alu/hw5_unit_design.rb +0 -7
  45. data/examples/pipelined_alu/hw5_unit_proto.rb +2 -0
  46. data/{samp → examples}/pipelined_alu/hw5_unit_runner.rake +0 -0
  47. data/{samp → examples}/pipelined_alu/hw5_unit_spec.rb +0 -0
  48. data/{samp → examples}/pipelined_alu/int_gen.rb +0 -0
  49. data/{samp → examples}/register_file/LICENSE +0 -0
  50. data/{samp → examples}/register_file/README +0 -0
  51. data/{samp → examples}/register_file/Rakefile +0 -0
  52. data/{samp → examples}/register_file/register_file.v +0 -0
  53. data/{samp → examples}/register_file/register_file_design.rb +0 -0
  54. data/examples/register_file/register_file_proto.rb +11 -0
  55. data/{samp → examples}/register_file/register_file_runner.rake +0 -0
  56. data/{samp → examples}/register_file/register_file_spec.rb +0 -0
  57. data/ext/main.c +5 -5
  58. data/ext/swig_vpi.i +6 -2
  59. data/lib/ruby-vpi/core/callback.rb +142 -0
  60. data/lib/ruby-vpi/core/edge.rb +128 -0
  61. data/lib/ruby-vpi/core/handle.rb +421 -0
  62. data/lib/ruby-vpi/core/scheduler.rb +244 -0
  63. data/lib/ruby-vpi/core/struct.rb +123 -0
  64. data/lib/ruby-vpi/core.rb +41 -0
  65. data/lib/ruby-vpi/rcov.rb +25 -12
  66. data/lib/ruby-vpi/runner.rb +30 -26
  67. data/lib/ruby-vpi/runner_boot_loader.rb +67 -37
  68. data/lib/ruby-vpi.rb +2 -2
  69. data/ref/c/annotated.html +1 -1
  70. data/ref/c/common_8h.html +1 -1
  71. data/ref/c/files.html +1 -1
  72. data/ref/c/functions.html +1 -1
  73. data/ref/c/functions_vars.html +1 -1
  74. data/ref/c/globals.html +1 -1
  75. data/ref/c/globals_0x63.html +1 -1
  76. data/ref/c/globals_0x65.html +1 -1
  77. data/ref/c/globals_0x66.html +1 -1
  78. data/ref/c/globals_0x6d.html +1 -1
  79. data/ref/c/globals_0x70.html +1 -1
  80. data/ref/c/globals_0x72.html +1 -1
  81. data/ref/c/globals_0x73.html +1 -1
  82. data/ref/c/globals_0x74.html +1 -1
  83. data/ref/c/globals_0x76.html +1 -1
  84. data/ref/c/globals_0x78.html +1 -1
  85. data/ref/c/globals_defs.html +1 -1
  86. data/ref/c/globals_defs_0x65.html +1 -1
  87. data/ref/c/globals_defs_0x70.html +1 -1
  88. data/ref/c/globals_defs_0x76.html +1 -1
  89. data/ref/c/globals_defs_0x78.html +1 -1
  90. data/ref/c/globals_enum.html +1 -1
  91. data/ref/c/globals_eval.html +1 -1
  92. data/ref/c/globals_func.html +1 -1
  93. data/ref/c/globals_type.html +1 -1
  94. data/ref/c/globals_vars.html +1 -1
  95. data/ref/c/index.html +1 -1
  96. data/ref/c/main_8c.html +1 -1
  97. data/ref/c/main_8h.html +1 -1
  98. data/ref/c/relay_8c.html +1 -1
  99. data/ref/c/relay_8h.html +1 -1
  100. data/ref/c/structt__cb__data.html +1 -1
  101. data/ref/c/structt__vpi__delay.html +1 -1
  102. data/ref/c/structt__vpi__error__info.html +1 -1
  103. data/ref/c/structt__vpi__strengthval.html +1 -1
  104. data/ref/c/structt__vpi__systf__data.html +1 -1
  105. data/ref/c/structt__vpi__time.html +1 -1
  106. data/ref/c/structt__vpi__value.html +1 -1
  107. data/ref/c/structt__vpi__vecval.html +1 -1
  108. data/ref/c/structt__vpi__vlog__info.html +1 -1
  109. data/ref/c/verilog_8h.html +1 -1
  110. data/ref/c/vlog_8c.html +1 -1
  111. data/ref/c/vlog_8h.html +1 -1
  112. data/ref/c/vpi__user_8h.html +1 -1
  113. data/ref/ruby/classes/ERB.html +7 -5
  114. data/ref/ruby/classes/ERB.src/{M000026.html → M000024.html} +0 -0
  115. data/ref/ruby/classes/FileUtils.html +11 -11
  116. data/ref/ruby/classes/FileUtils.src/{M000027.html → M000025.html} +0 -0
  117. data/ref/ruby/classes/FileUtils.src/{M000028.html → M000026.html} +0 -0
  118. data/ref/ruby/classes/Float.html +8 -6
  119. data/ref/ruby/classes/Float.src/{M000021.html → M000019.html} +0 -0
  120. data/ref/ruby/classes/Integer.html +67 -65
  121. data/ref/ruby/classes/Integer.src/M000007.html +25 -0
  122. data/ref/ruby/classes/Integer.src/{M000014.html → M000008.html} +5 -5
  123. data/ref/ruby/classes/Integer.src/M000009.html +5 -12
  124. data/ref/ruby/classes/Integer.src/M000010.html +5 -5
  125. data/ref/ruby/classes/Integer.src/M000011.html +5 -5
  126. data/ref/ruby/classes/Integer.src/M000012.html +5 -5
  127. data/ref/ruby/classes/Integer.src/M000015.html +25 -0
  128. data/ref/ruby/classes/Integer.src/M000016.html +31 -0
  129. data/ref/ruby/classes/Integer.src/M000017.html +12 -12
  130. data/ref/ruby/classes/Integer.src/M000018.html +17 -18
  131. data/ref/ruby/classes/Object.html +126 -0
  132. data/ref/ruby/classes/RDoc.html +5 -5
  133. data/ref/ruby/classes/RDoc.src/{M000061.html → M000081.html} +0 -0
  134. data/ref/ruby/classes/RubyVPI.html +50 -9
  135. data/ref/ruby/classes/String.html +22 -20
  136. data/ref/ruby/classes/String.src/M000020.html +36 -0
  137. data/ref/ruby/classes/String.src/M000021.html +41 -0
  138. data/ref/ruby/classes/String.src/M000022.html +5 -23
  139. data/ref/ruby/classes/String.src/M000023.html +5 -28
  140. data/ref/ruby/classes/{Vpi → VPI}/Handle.html +442 -140
  141. data/ref/ruby/classes/{Vpi/Handle.src/M000042.html → VPI/Handle.src/M000037.html} +4 -4
  142. data/ref/ruby/classes/VPI/Handle.src/M000038.html +21 -0
  143. data/ref/ruby/classes/VPI/Handle.src/M000039.html +18 -0
  144. data/ref/ruby/classes/{Vpi/Handle.src/M000036.html → VPI/Handle.src/M000040.html} +5 -5
  145. data/ref/ruby/classes/VPI/Handle.src/M000045.html +18 -0
  146. data/ref/ruby/classes/{Vpi/Handle.src/M000038.html → VPI/Handle.src/M000046.html} +5 -5
  147. data/ref/ruby/classes/VPI/Handle.src/M000057.html +18 -0
  148. data/ref/ruby/classes/{Vpi/Handle.src/M000040.html → VPI/Handle.src/M000058.html} +5 -5
  149. data/ref/ruby/classes/VPI/Handle.src/M000061.html +18 -0
  150. data/ref/ruby/classes/VPI/Handle.src/M000062.html +18 -0
  151. data/ref/ruby/classes/{Vpi/Handle.src/M000054.html → VPI/Handle.src/M000065.html} +11 -11
  152. data/ref/ruby/classes/VPI/Handle.src/M000067.html +21 -0
  153. data/ref/ruby/classes/VPI/Handle.src/M000068.html +28 -0
  154. data/ref/ruby/classes/VPI/Handle.src/M000069.html +50 -0
  155. data/ref/ruby/classes/{Vpi/Handle.src/M000048.html → VPI/Handle.src/M000070.html} +6 -6
  156. data/ref/ruby/classes/{Vpi/Handle.src/M000049.html → VPI/Handle.src/M000071.html} +6 -6
  157. data/ref/ruby/classes/{Vpi/Handle.src/M000050.html → VPI/Handle.src/M000072.html} +5 -5
  158. data/ref/ruby/classes/{Vpi/Handle.src/M000051.html → VPI/Handle.src/M000073.html} +17 -17
  159. data/ref/ruby/classes/VPI/Handle.src/M000075.html +18 -0
  160. data/ref/ruby/classes/VPI/Handle.src/M000076.html +40 -0
  161. data/ref/ruby/classes/{Vpi/Handle.src/M000056.html → VPI/Handle.src/M000077.html} +18 -18
  162. data/ref/ruby/classes/{Vpi → VPI}/S_vpi_time.html +22 -20
  163. data/ref/ruby/classes/VPI/S_vpi_time.src/M000078.html +18 -0
  164. data/ref/ruby/classes/VPI/S_vpi_time.src/M000079.html +19 -0
  165. data/ref/ruby/classes/{Vpi → VPI}/S_vpi_value.html +37 -23
  166. data/ref/ruby/classes/VPI/S_vpi_value.src/M000034.html +35 -0
  167. data/ref/ruby/classes/VPI/S_vpi_value.src/M000035.html +42 -0
  168. data/ref/ruby/classes/VPI/S_vpi_value.src/M000036.html +42 -0
  169. data/ref/ruby/classes/{Vpi.html → VPI.html} +129 -34
  170. data/ref/ruby/classes/VPI.src/M000027.html +19 -0
  171. data/ref/ruby/classes/VPI.src/M000028.html +18 -0
  172. data/ref/ruby/classes/VPI.src/M000029.html +19 -0
  173. data/ref/ruby/classes/VPI.src/M000031.html +25 -0
  174. data/ref/ruby/classes/VPI.src/M000032.html +26 -0
  175. data/ref/ruby/classes/VerilogParser/Module/Port.html +17 -15
  176. data/ref/ruby/classes/VerilogParser/Module/Port.src/M000004.html +23 -0
  177. data/ref/ruby/classes/VerilogParser/Module/Port.src/{M000007.html → M000005.html} +0 -0
  178. data/ref/ruby/classes/VerilogParser/Module/Port.src/M000006.html +5 -10
  179. data/ref/ruby/classes/VerilogParser/Module.html +7 -5
  180. data/ref/ruby/classes/VerilogParser/Module.src/{M000005.html → M000003.html} +0 -0
  181. data/ref/ruby/classes/VerilogParser.html +7 -5
  182. data/ref/ruby/classes/VerilogParser.src/{M000004.html → M000002.html} +0 -0
  183. data/ref/ruby/created.rid +1 -1
  184. data/ref/ruby/files/bin/generate_rb.html +2 -2
  185. data/ref/ruby/files/lib/ruby-vpi/{vpi_rb.html → core/callback_rb.html} +7 -8
  186. data/ref/ruby/files/lib/ruby-vpi/core/edge_rb.html +114 -0
  187. data/ref/ruby/files/lib/ruby-vpi/core/handle_rb.html +107 -0
  188. data/ref/ruby/files/lib/ruby-vpi/core/scheduler_rb.html +114 -0
  189. data/ref/ruby/files/lib/ruby-vpi/core/struct_rb.html +108 -0
  190. data/ref/ruby/files/lib/ruby-vpi/core_rb.html +121 -0
  191. data/ref/ruby/files/lib/ruby-vpi/rcov_rb.html +1 -1
  192. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.html +5 -41
  193. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.src/M000001.html +3 -3
  194. data/ref/ruby/files/lib/ruby-vpi/runner_rb.html +1 -1
  195. data/ref/ruby/files/lib/ruby-vpi_rb.html +1 -1
  196. data/ref/ruby/fr_class_index.html +5 -4
  197. data/ref/ruby/fr_file_index.html +6 -1
  198. data/ref/ruby/fr_method_index.html +80 -60
  199. metadata +126 -103
  200. data/ext/swig_vpi.h +0 -924
  201. data/ext/swig_wrap.cin +0 -7083
  202. data/lib/ruby-vpi/vpi.rb +0 -651
  203. data/ref/ruby/classes/Integer.src/M000013.html +0 -18
  204. data/ref/ruby/classes/Integer.src/M000019.html +0 -25
  205. data/ref/ruby/classes/Integer.src/M000020.html +0 -30
  206. data/ref/ruby/classes/String.src/M000024.html +0 -18
  207. data/ref/ruby/classes/String.src/M000025.html +0 -18
  208. data/ref/ruby/classes/VerilogParser/Module/Port.src/M000008.html +0 -18
  209. data/ref/ruby/classes/Vpi/Handle.src/M000035.html +0 -18
  210. data/ref/ruby/classes/Vpi/Handle.src/M000037.html +0 -18
  211. data/ref/ruby/classes/Vpi/Handle.src/M000039.html +0 -18
  212. data/ref/ruby/classes/Vpi/Handle.src/M000041.html +0 -18
  213. data/ref/ruby/classes/Vpi/Handle.src/M000043.html +0 -21
  214. data/ref/ruby/classes/Vpi/Handle.src/M000044.html +0 -21
  215. data/ref/ruby/classes/Vpi/Handle.src/M000045.html +0 -22
  216. data/ref/ruby/classes/Vpi/Handle.src/M000046.html +0 -50
  217. data/ref/ruby/classes/Vpi/Handle.src/M000047.html +0 -91
  218. data/ref/ruby/classes/Vpi/Handle.src/M000053.html +0 -18
  219. data/ref/ruby/classes/Vpi/Handle.src/M000057.html +0 -40
  220. data/ref/ruby/classes/Vpi/S_vpi_time.src/M000058.html +0 -18
  221. data/ref/ruby/classes/Vpi/S_vpi_time.src/M000059.html +0 -19
  222. data/ref/ruby/classes/Vpi/S_vpi_value.src/M000032.html +0 -18
  223. data/ref/ruby/classes/Vpi/S_vpi_value.src/M000033.html +0 -18
  224. data/ref/ruby/classes/Vpi/S_vpi_value.src/M000034.html +0 -18
  225. data/ref/ruby/classes/Vpi.src/M000029.html +0 -28
  226. data/ref/ruby/classes/Vpi.src/M000030.html +0 -39
  227. data/ref/ruby/classes/Vpi.src/M000031.html +0 -20
  228. data/ref/ruby/files/lib/ruby-vpi/runner_boot_loader_rb.src/M000002.html +0 -18
  229. data/samp/counter/RSpec/counter_proto.rb +0 -10
  230. data/samp/counter/xUnit/counter_proto.rb +0 -10
  231. data/samp/pipelined_alu/hw5_unit_proto.rb +0 -4
  232. data/samp/register_file/register_file_proto.rb +0 -11
data/lib/ruby-vpi/vpi.rb DELETED
@@ -1,651 +0,0 @@
1
- # A utility layer which transforms the VPI interface
2
- # into one that is more suitable for Ruby.
3
- #--
4
- # Copyright 2006 Suraj N. Kurapati
5
- # See the file named LICENSE for details.
6
-
7
- require 'ruby-vpi/util'
8
-
9
- module Vpi
10
- # Number of bits in PLI_INT32.
11
- INTEGER_BITS = 32
12
-
13
- # Lowest upper bound of PLI_INT32.
14
- INTEGER_LIMIT = 2 ** INTEGER_BITS
15
-
16
- # Bit-mask capable of capturing PLI_INT32.
17
- INTEGER_MASK = INTEGER_LIMIT - 1
18
-
19
-
20
- ##############################################################################
21
- # handles
22
- ##############################################################################
23
-
24
- Handle = SWIG::TYPE_p_unsigned_int
25
-
26
- # A handle is an object inside a Verilog simulation (see
27
- # *vpiHandle* in IEEE Std. 1364-2005). VPI types and
28
- # properties listed in ext/vpi_user.h can be specified by
29
- # their names (strings or symbols) or integer constants.
30
- #
31
- # = Example names
32
- # * "intVal"
33
- # * :intVal
34
- # * "vpiIntVal"
35
- # * :vpiIntVal
36
- # * "VpiIntVal"
37
- # * :VpiIntVal
38
- #
39
- # = Example constants
40
- # * VpiIntVal
41
- # * VpiModule
42
- # * VpiReg
43
- #
44
- class Handle
45
- undef type # used to access vpiType
46
- include Vpi
47
-
48
- # Tests if the logic value of this handle is unknown (x).
49
- def x?
50
- self.hexStrVal =~ /x/i
51
- end
52
-
53
- # Sets the logic value of this handle to unknown (x).
54
- def x!
55
- self.hexStrVal = 'x'
56
- end
57
-
58
- # Tests if the logic value of this handle is high impedance (z).
59
- def z?
60
- self.hexStrVal =~ /z/i
61
- end
62
-
63
- # Sets the logic value of this handle to high impedance (z).
64
- def z!
65
- self.hexStrVal = 'z'
66
- end
67
-
68
- # Tests if the logic value of this handle is at "logic high" level.
69
- def high?
70
- self.intVal != 0
71
- end
72
-
73
- # Sets the logic value of this handle to "logic high" level.
74
- def high!
75
- self.intVal = 1
76
- end
77
-
78
- # Tests if the logic value of this handle is at "logic low" level.
79
- def low?
80
- self.hexStrVal =~ /^0+$/
81
- end
82
-
83
- # Sets the logic value of this handle to "logic low" level.
84
- def low!
85
- self.intVal = 0
86
- end
87
-
88
- # Tests if the logic value of this handle is currently at a positive edge.
89
- def posedge?
90
- old = @lastVal
91
- new = @lastVal = self.intVal
92
-
93
- old == 0 && new == 1
94
- end
95
-
96
- # Tests if the logic value of this handle is currently at a negative edge.
97
- def negedge?
98
- old = @lastVal
99
- new = @lastVal = self.intVal
100
-
101
- old == 1 && new == 0
102
- end
103
-
104
- # Reads the value using the given
105
- # format (integer constant) and
106
- # returns a +S_vpi_value+ object.
107
- def get_value_wrapper aFormat
108
- val = S_vpi_value.new
109
- val.format = aFormat
110
-
111
- vpi_get_value self, val
112
- val
113
- end
114
-
115
- # Reads the value using the given format (name or
116
- # integer constant) and returns it. If a format is
117
- # not given, then it is assumed to be VpiIntVal.
118
- def get_value aFormat = VpiIntVal
119
- val = get_value_wrapper(resolve_prop_type(aFormat))
120
-
121
- case val.format
122
- when VpiBinStrVal, VpiOctStrVal, VpiDecStrVal, VpiHexStrVal, VpiStringVal
123
- val.value.str.to_s
124
-
125
- when VpiScalarVal
126
- val.value.scalar.to_i
127
-
128
- when VpiIntVal
129
- @size ||= vpi_get(VpiSize, self)
130
-
131
- if @size < INTEGER_BITS
132
- val.value.integer.to_i
133
- else
134
- get_value_wrapper(VpiHexStrVal).value.str.to_s.to_i(16)
135
- end
136
-
137
- when VpiRealVal
138
- val.value.real.to_f
139
-
140
- when VpiTimeVal
141
- val.value.time
142
-
143
- when VpiVectorVal
144
- val.value.vector
145
-
146
- when VpiStrengthVal
147
- val.value.strength
148
-
149
- else
150
- raise "unknown S_vpi_value.format: #{val.format.inspect}"
151
- end
152
- end
153
-
154
- # Writes the given value using the given format (name or integer
155
- # constant), time, and delay, and then returns the written value.
156
- #
157
- # * If a format is not given, then the Verilog simulator
158
- # will attempt to determine the correct format.
159
- #
160
- def put_value aValue, aFormat = nil, aTime = nil, aDelay = VpiNoDelay
161
- if vpi_get(VpiType, self) == VpiNet
162
- aDelay = VpiForceFlag
163
-
164
- if driver = self[VpiDriver].find {|d| d.vpiType != VpiForce}
165
- warn "forcing value #{aValue.inspect} onto wire #{self} that is already driven by #{driver.inspect}"
166
- end
167
- end
168
-
169
- aFormat =
170
- if aFormat
171
- resolve_prop_type(aFormat)
172
-
173
- elsif aValue.respond_to? :to_int
174
- VpiIntVal
175
-
176
- elsif aValue.respond_to? :to_float
177
- VpiRealVal
178
-
179
- elsif aValue.respond_to? :to_str
180
- VpiStringVal
181
-
182
- elsif aValue.is_a? S_vpi_time
183
- VpiTimeVal
184
-
185
- elsif aValue.is_a? S_vpi_vecval
186
- VpiVectorVal
187
-
188
- elsif aValue.is_a? S_vpi_strengthval
189
- VpiStrengthVal
190
-
191
- else
192
- get_value_wrapper(VpiObjTypeVal).format
193
- end
194
-
195
- newVal = S_vpi_value.new(:format => aFormat)
196
-
197
- writtenVal =
198
- case aFormat
199
- when VpiBinStrVal, VpiOctStrVal, VpiDecStrVal, VpiHexStrVal, VpiStringVal
200
- newVal.value.str = aValue.to_s
201
-
202
- when VpiScalarVal
203
- newVal.value.scalar = aValue.to_i
204
-
205
- when VpiIntVal
206
- @size ||= vpi_get(VpiSize, self)
207
-
208
- if @size < INTEGER_BITS
209
- newVal.format = VpiIntVal
210
- newVal.value.integer = aValue.to_i
211
- else
212
- newVal.format = VpiHexStrVal
213
- newVal.value.str = aValue.to_i.to_s(16)
214
- end
215
-
216
- when VpiRealVal
217
- newVal.value.real = aValue.to_f
218
-
219
- when VpiTimeVal
220
- newVal.value.time = aValue
221
-
222
- when VpiVectorVal
223
- newVal.value.vector = aValue
224
-
225
- when VpiStrengthVal
226
- newVal.value.strength = aValue
227
-
228
- else
229
- raise "unknown S_vpi_value.format: #{newVal.format.inspect}"
230
- end
231
-
232
- vpi_put_value(self, newVal, aTime, aDelay)
233
-
234
- writtenVal
235
- end
236
-
237
- # Forces the given value (see arguments for #put_value) onto this handle.
238
- def force_value *args
239
- args[3] = VpiForceFlag
240
- put_value(*args)
241
- end
242
-
243
- # Releases a previously forced value on this handle.
244
- def release_value
245
- # this doesn't really change the value, it only removes the force flag
246
- put_value(0, VpiIntVal, nil, VpiReleaseFlag)
247
- end
248
-
249
- # Tests if there is currently a value forced onto this handle.
250
- def value_forced?
251
- self[VpiDriver].any? {|d| d.vpiType == VpiForce}
252
- end
253
-
254
-
255
- # Returns an array of child handles of the
256
- # given types (name or integer constant).
257
- def [] *aTypes
258
- handles = []
259
-
260
- aTypes.each do |arg|
261
- t = resolve_prop_type(arg)
262
-
263
- if itr = vpi_iterate(t, self)
264
- while h = vpi_scan(itr)
265
- handles << h
266
- end
267
- end
268
- end
269
-
270
- handles
271
- end
272
-
273
- # inherit Enumerable methods, such as #each, #map, #select, etc.
274
- Enumerable.instance_methods.push('each').each do |meth|
275
- # using a string because define_method
276
- # does not accept a block until Ruby 1.9
277
- class_eval %{
278
- def #{meth}(*args, &block)
279
- if ary = self[*args]
280
- ary.#{meth}(&block)
281
- end
282
- end
283
- }, __FILE__, __LINE__
284
- end
285
-
286
- # bypass Enumerable's #to_a method, which relies on #each
287
- alias to_a []
288
-
289
- # Sort by absolute VPI path.
290
- def <=> other
291
- self.fullName <=> other.fullName
292
- end
293
-
294
-
295
- # Inspects the given VPI property names, in
296
- # addition to those common to all handles.
297
- def inspect *aPropNames
298
- aPropNames.unshift :name, :fullName, :size, :file, :lineNo, :hexStrVal
299
-
300
- aPropNames.map! do |name|
301
- "#{name}=#{self.send(name.to_sym).inspect}"
302
- end
303
-
304
- "#<Vpi::Handle #{vpiType_s} #{aPropNames.join(', ')}>"
305
- end
306
-
307
- alias to_s inspect
308
-
309
- # Registers a callback that is invoked
310
- # whenever the value of this object changes.
311
- def cbValueChange aOptions = {}, &aHandler
312
- raise ArgumentError unless block_given?
313
-
314
- aOptions[:time] ||= S_vpi_time.new(:type => VpiSuppressTime)
315
- aOptions[:value] ||= S_vpi_value.new(:format => VpiSuppressVal)
316
-
317
- alarm = S_cb_data.new(
318
- :reason => CbValueChange,
319
- :obj => self,
320
- :time => aOptions[:time],
321
- :value => aOptions[:value],
322
- :index => 0
323
- )
324
-
325
- vpi_register_cb alarm, &aHandler
326
- end
327
-
328
-
329
- @@propCache = Hash.new {|h, k| h[k] = Property.new(k)}
330
-
331
- # Provides access to this handle's (1) child handles
332
- # and (2) VPI properties through method calls. In the
333
- # case that a child handle has the same name as a VPI
334
- # property, the child handle will be accessed instead
335
- # of the VPI property. However, you can still access
336
- # the VPI property via #get_value and #put_value.
337
- def method_missing aMeth, *aArgs, &aBlockArg
338
- # cache the result for future accesses, in order
339
- # to cut down number of calls to method_missing()
340
- eigen_class = (class << self; self; end)
341
-
342
- if child = vpi_handle_by_name(aMeth.to_s, self)
343
- eigen_class.class_eval do
344
- define_method aMeth do
345
- child
346
- end
347
- end
348
-
349
- child
350
- else
351
- # XXX: using a string because define_method() does
352
- # not support a block argument until Ruby 1.9
353
- eigen_class.class_eval %{
354
- def #{aMeth}(*a, &b)
355
- @@propCache[#{aMeth.inspect}].execute(self, *a, &b)
356
- end
357
- }, __FILE__, __LINE__
358
-
359
- self.__send__(aMeth, *aArgs, &aBlockArg)
360
- end
361
- end
362
-
363
- private
364
-
365
- class Property # :nodoc:
366
- def initialize aMethName
367
- @methName = aMethName.to_s
368
-
369
- # parse property information from the given method name
370
- tokens = @methName.split('_')
371
-
372
- tokens.last.sub!(/[\?!=]$/, '')
373
- addendum = $&
374
- @isAssign = $& == '='
375
- isQuery = $& == '?'
376
-
377
- tokens.last =~ /^[a-z]$/ && tokens.pop
378
- @accessor = $&
379
-
380
- @name = tokens.pop
381
-
382
- @operation = unless tokens.empty?
383
- tokens.join('_') << (addendum || '')
384
- end
385
-
386
- # determine the VPI integer type for the property
387
- @name = @name.to_ruby_const_name
388
- @name.insert 0, 'Vpi' unless @name =~ /^[Vv]pi/
389
-
390
- begin
391
- @type = Vpi.const_get(@name)
392
- rescue NameError
393
- raise ArgumentError, "#{@name.inspect} is not a valid VPI property"
394
- end
395
-
396
- @accessor = if @accessor
397
- @accessor.to_sym
398
- else
399
- # infer accessor from VPI property @name
400
- if isQuery
401
- :b
402
- else
403
- case @name
404
- when /Time$/
405
- :d
406
-
407
- when /Val$/
408
- :l
409
-
410
- when /Type$/, /Direction$/, /Index$/, /Size$/, /Strength\d?$/, /Polarity$/, /Edge$/, /Offset$/, /Mode$/, /LineNo$/
411
- :i
412
-
413
- when /Is[A-Z]/, /ed$/
414
- :b
415
-
416
- when /Name$/, /File$/, /Decompile$/
417
- :s
418
-
419
- when /Parent$/, /Inst$/, /Range$/, /Driver$/, /Net$/, /Load$/, /Conn$/, /Bit$/, /Word$/, /[LR]hs$/, /(In|Out)$/, /Term$/, /Argument$/, /Condition$/, /Use$/, /Operand$/, /Stmt$/, /Expr$/, /Scope$/, /Memory$/, /Delay$/
420
- :h
421
- end
422
- end
423
- end
424
- end
425
-
426
- def execute aHandle, *aArgs, &aBlockArg
427
- if @operation
428
- aHandle.__send__(@operation, @type, *aArgs, &aBlockArg)
429
- else
430
- case @accessor
431
- when :d # delay values
432
- raise NotImplementedError, 'processing of delay values is not yet implemented.'
433
- # TODO: vpi_put_delays
434
- # TODO: vpi_get_delays
435
-
436
- when :l # logic values
437
- if @isAssign
438
- value = aArgs.shift
439
- aHandle.put_value(value, @type, *aArgs)
440
- else
441
- aHandle.get_value(@type)
442
- end
443
-
444
- when :i # integer values
445
- if @isAssign
446
- raise NotImplementedError
447
- else
448
- vpi_get(@type, aHandle)
449
- end
450
-
451
- when :b # boolean values
452
- if @isAssign
453
- raise NotImplementedError
454
- else
455
- value = vpi_get(@type, aHandle)
456
- value && (value != 0) # zero is false in C
457
- end
458
-
459
- when :s # string values
460
- if @isAssign
461
- raise NotImplementedError
462
- else
463
- vpi_get_str(@type, aHandle)
464
- end
465
-
466
- when :h # handle values
467
- if @isAssign
468
- raise NotImplementedError
469
- else
470
- vpi_handle(@type, aHandle)
471
- end
472
-
473
- when :a # array of child handles
474
- if @isAssign
475
- raise NotImplementedError
476
- else
477
- aHandle[@type]
478
- end
479
-
480
- else
481
- raise NoMethodError, "cannot access VPI property #{@name.inspect} for handle #{aHandle.inspect} through method #{@methName.inspect} with arguments #{aArgs.inspect}"
482
- end
483
- end
484
- end
485
- end
486
-
487
- # resolve type names into type constants
488
- def resolve_prop_type aNameOrType
489
- if aNameOrType.respond_to? :to_int
490
- aNameOrType.to_int
491
- else
492
- @@propCache[aNameOrType.to_sym].type
493
- end
494
- end
495
- end
496
-
497
-
498
- ##############################################################################
499
- # callbacks
500
- ##############################################################################
501
-
502
- Callback = Struct.new :handler, :token #:nodoc:
503
- @@callbacks = {}
504
-
505
- alias vpi_register_cb_old vpi_register_cb
506
-
507
- # This is a Ruby version of the vpi_register_cb C function. It is
508
- # identical to the C function, except for the following differences:
509
- #
510
- # * This method accepts a block (callback handler)
511
- # which is executed whenever the callback occurs.
512
- #
513
- # * This method overwrites the +cb_rtn+ and +user_data+
514
- # fields of the given +S_cb_data+ object.
515
- #
516
- def vpi_register_cb aData, &aHandler # :yields: Vpi::S_cb_data
517
- raise ArgumentError, "block must be given" unless block_given?
518
-
519
- key = aHandler.object_id.to_s
520
-
521
- # register the callback with Verilog
522
- aData.user_data = key
523
- aData.cb_rtn = Vlog_relay_ruby
524
- token = vpi_register_cb_old(aData)
525
-
526
- @@callbacks[key] = Callback.new(aHandler, token)
527
- token
528
- end
529
-
530
- alias vpi_remove_cb_old vpi_remove_cb
531
-
532
- def vpi_remove_cb aData # :nodoc:
533
- key = aData.user_data
534
-
535
- if c = @@callbacks[key]
536
- vpi_remove_cb_old c.token
537
- @@callbacks.delete key
538
- end
539
- end
540
-
541
- # Proxy for relay_verilog which supports callbacks. This method
542
- # should NOT be invoked from callback handlers (see vpi_register_cb)
543
- # and threads -- otherwise the situation will be like seven remote
544
- # controls changing the channel on a single television set!
545
- def relay_verilog_proxy # :nodoc:
546
- loop do
547
- relay_verilog
548
-
549
- if reason = relay_ruby_reason # might be nil
550
- dst = reason.user_data
551
-
552
- if c = @@callbacks[dst]
553
- c.handler.call reason
554
- else
555
- break # main thread is receiver
556
- end
557
- end
558
- end
559
- end
560
-
561
-
562
- ##############################################################################
563
- # simulation control
564
- ##############################################################################
565
-
566
- # Advances the simulation by the given number of steps.
567
- def advance_time aNumSteps = 1
568
- # schedule wake-up callback from verilog
569
- time = S_vpi_time.new
570
- time.integer = aNumSteps
571
- time.type = VpiSimTime
572
-
573
- value = S_vpi_value.new
574
- value.format = VpiSuppressVal
575
-
576
- alarm = S_cb_data.new
577
- alarm.reason = CbAfterDelay
578
- alarm.cb_rtn = Vlog_relay_ruby
579
- alarm.obj = nil
580
- alarm.time = time
581
- alarm.value = value
582
- alarm.index = 0
583
- alarm.user_data = nil
584
-
585
- vpi_free_object(vpi_register_cb_old(alarm))
586
-
587
-
588
- # transfer control to verilog
589
- relay_verilog_proxy
590
- end
591
-
592
-
593
- ##############################################################################
594
- # utility
595
- ##############################################################################
596
-
597
- # Returns the current simulation time as an integer.
598
- def simulation_time
599
- t = S_vpi_time.new :type => VpiSimTime
600
- vpi_get_time nil, t
601
- t.to_i
602
- end
603
-
604
- class S_vpi_time
605
- # Returns the high and low portions of
606
- # this time as a single 64-bit integer.
607
- def integer
608
- (self.high << INTEGER_BITS) | self.low
609
- end
610
-
611
- # Sets the high and low portions of this
612
- # time from the given 64-bit integer.
613
- def integer= aValue
614
- self.low = aValue & INTEGER_MASK
615
- self.high = (aValue >> INTEGER_BITS) & INTEGER_MASK
616
- end
617
-
618
- alias to_i integer
619
- alias to_f real
620
- end
621
-
622
- class S_vpi_value
623
- def to_i
624
- value.integer
625
- end
626
-
627
- def to_f
628
- value.real
629
- end
630
-
631
- def to_s
632
- value.str
633
- end
634
- end
635
-
636
- # make VPI structs more accessible by allowing their
637
- # members to be initialized through the constructor
638
- constants.grep(/^S_/).each do |s|
639
- const_get(s).class_eval do
640
- alias old_initialize initialize
641
-
642
- def initialize aMembers = {} #:nodoc:
643
- old_initialize
644
-
645
- aMembers.each_pair do |k, v|
646
- __send__ "#{k}=", v
647
- end
648
- end
649
- end
650
- end
651
- end
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>mask (Integer)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/integer.rb, line 40</span>
14
- 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mask</span>
15
- 41: <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_mask</span>
16
- 42: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
@@ -1,25 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>extend_sign (Integer)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/ruby-vpi/integer.rb, line 97</span>
14
- 97: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extend_sign</span> <span class="ruby-identifier">aOrigWidth</span>, <span class="ruby-identifier">aExtWidth</span>
15
- 98: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>
16
- 99: <span class="ruby-identifier">maskWidth</span> = <span class="ruby-identifier">aExtWidth</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aOrigWidth</span>
17
- 100:
18
- 101: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">maskWidth</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">result</span>[<span class="ruby-identifier">aOrigWidth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
19
- 102: <span class="ruby-identifier">result</span> <span class="ruby-operator">|=</span> (<span class="ruby-identifier">maskWidth</span>.<span class="ruby-identifier">to_mask</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">aOrigWidth</span>)
20
- 103: <span class="ruby-keyword kw">end</span>
21
- 104:
22
- 105: <span class="ruby-identifier">result</span> <span class="ruby-operator">&amp;</span> <span class="ruby-identifier">aExtWidth</span>.<span class="ruby-identifier">to_mask</span>
23
- 106: <span class="ruby-keyword kw">end</span></pre>
24
- </body>
25
- </html>