HDLRuby 2.4.27 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/HDLRuby/drivers/xcd.rb +79 -0
- data/lib/HDLRuby/drivers/xcd/dummy.xcd +4 -0
- data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
- data/lib/HDLRuby/hdr_samples/dff_properties.rb +19 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +54 -0
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/music.rb +79 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
- data/lib/HDLRuby/hdr_samples/seqpar_bench.rb +59 -0
- data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
- data/lib/HDLRuby/hdrcc.rb +140 -24
- data/lib/HDLRuby/hruby_decorator.rb +250 -0
- data/lib/HDLRuby/hruby_high.rb +468 -91
- data/lib/HDLRuby/hruby_low.rb +913 -45
- data/lib/HDLRuby/hruby_low2c.rb +189 -168
- data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
- data/lib/HDLRuby/hruby_low2high.rb +331 -549
- data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
- data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
- data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
- data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +151 -0
- data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
- data/lib/HDLRuby/hruby_tools.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +1602 -1629
- data/lib/HDLRuby/sim/hruby_sim.h +25 -2
- data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
- data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
- data/lib/HDLRuby/std/fixpoint.rb +9 -0
- data/lib/HDLRuby/std/function_generator.rb +139 -0
- data/lib/HDLRuby/std/hruby_unit.rb +75 -0
- data/lib/HDLRuby/template_expander.rb +61 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +22 -5
@@ -5,734 +5,516 @@ module HDLRuby::Low
|
|
5
5
|
|
6
6
|
|
7
7
|
##
|
8
|
-
# Converts a HDLRuby::Low description to
|
9
|
-
# description
|
8
|
+
# Converts a HDLRuby::Low description to HDLRuby::High description.
|
10
9
|
#
|
11
10
|
########################################################################
|
12
11
|
|
13
|
-
## Provides tools for converting HDLRuby::Low objects to HDLRuby::High.
|
14
|
-
module Low2High
|
15
12
|
|
16
|
-
## Tells if an HDLRuby::Low +name+ syntax is compatible for
|
17
|
-
# HDLRuby::High.
|
18
|
-
def self.high_name?(name)
|
19
|
-
return name =~ /^[a-zA-Z_][a-zA-Z_0-9]*$/
|
20
|
-
end
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
# Add the conversion to high.
|
15
|
+
class SystemT
|
16
|
+
# Creates a new high system type named +name+ with +scope+.
|
17
|
+
def to_high
|
18
|
+
# Create the high system type.
|
19
|
+
res = HDLRuby::High::SystemT.new(self.name,self.scope.to_high)
|
20
|
+
# Add the inputs.
|
21
|
+
self.each_input { |i| res.add_input(i.to_high) }
|
22
|
+
# Add the outputs.
|
23
|
+
self.each_output { |o| res.add_output(o.to_high) }
|
24
|
+
# Add the inouts.
|
25
|
+
self.each_inout { |io| res.add_inout(io.to_high) }
|
26
|
+
return res
|
31
27
|
end
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
|
31
|
+
# Add the conversion to high.
|
32
|
+
class Scope
|
33
|
+
# Creates a new high scope.
|
34
|
+
def to_high
|
35
|
+
# Create the high scope.
|
36
|
+
res = new HDLRuby::High::Scope.new(self.name)
|
37
|
+
# Add the local types.
|
38
|
+
self.each_type { |t| res.add_type(t.to_high) }
|
39
|
+
# Add the local system types.
|
40
|
+
self.each_systemT { |s| res.add_systemT(s.to_high) }
|
41
|
+
# Add the sub scopes.
|
42
|
+
self.each_scope { |s| res.add_scope(s.to_high) }
|
43
|
+
# Add the inner signals.
|
44
|
+
self.each_inner { |i| res.add_inner(i.to_high) }
|
45
|
+
# Add the system instances.
|
46
|
+
self.each_systemI { |s| res.add_systemI(s.to_high) }
|
47
|
+
# Add the non-HDLRuby cofe chunks.
|
48
|
+
self.each_code { |c| res.add_code(c.to_high) }
|
49
|
+
# Add the connections.
|
50
|
+
self.each_connection { |c| res.add_connection(c.to_high) }
|
51
|
+
# Add the behaviors.
|
52
|
+
self.each_behavior { |b| res.add_behavior(b.to_high) }
|
53
|
+
return res
|
42
54
|
end
|
55
|
+
end
|
43
56
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
# Incompatible, use the HDLRuby::High "send" operator.
|
52
|
-
return "send(:\"#{name}\",#{[*args].join(",")})"
|
53
|
-
end
|
57
|
+
|
58
|
+
# Add the conversion to high.
|
59
|
+
class Type
|
60
|
+
# Creates a new high type.
|
61
|
+
def to_high
|
62
|
+
return HDLRuby::High::Type.new(self.name)
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
57
66
|
|
67
|
+
# Add the conversion to high.
|
68
|
+
class TypeDef
|
69
|
+
# Creates a new high type definition.
|
70
|
+
def to_high
|
71
|
+
return HDLRuby::High::Typdef.new(self.name,self.type.to_high)
|
72
|
+
end
|
73
|
+
end
|
58
74
|
|
59
|
-
## Extends the SystemT class with generation of HDLRuby::High text.
|
60
|
-
class SystemT
|
61
75
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
res << "system :#{Low2High.high_decl_name(self.name)} do\n"
|
70
|
-
# Generate the interface.
|
71
|
-
# Inputs.
|
72
|
-
self.each_input do |input|
|
73
|
-
res << " " * ((level+1)*3)
|
74
|
-
res << input.type.to_high(level+1)
|
75
|
-
res << ".input :" << Low2High.high_decl_name(input.name)
|
76
|
-
res << "\n"
|
77
|
-
end
|
78
|
-
# Outputs.
|
79
|
-
self.each_output do |output|
|
80
|
-
res << " " * ((level+1)*3)
|
81
|
-
res << output.type.to_high(level+1)
|
82
|
-
res << ".output :" << Low2High.high_decl_name(output.name)
|
83
|
-
res << "\n"
|
84
|
-
end
|
85
|
-
# Inouts.
|
86
|
-
self.each_inout do |inout|
|
87
|
-
res << " " * ((level+1)*3)
|
88
|
-
res << inout.type.to_high(level+1)
|
89
|
-
res << ".inout :" << Low2High.high_decl_name(inout.name)
|
90
|
-
res << "\n"
|
91
|
-
end
|
92
|
-
# Generate the scope.
|
93
|
-
res << " " * (level*3)
|
94
|
-
res << "\n"
|
95
|
-
res << self.scope.to_high(level+1,false)
|
96
|
-
# End of the system.
|
97
|
-
res << " " * (level*3)
|
98
|
-
res << "end\n\n"
|
99
|
-
# Return the result.
|
100
|
-
return res
|
76
|
+
# Add the conversion to high.
|
77
|
+
class TypeVector
|
78
|
+
# Creates a new high type vector.
|
79
|
+
def to_high
|
80
|
+
return HDLRuby::High::TypeVector.new(self.name,
|
81
|
+
self.base.to_high,
|
82
|
+
self.range)
|
101
83
|
end
|
102
84
|
end
|
103
85
|
|
104
86
|
|
105
|
-
|
106
|
-
class
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
# +header+ tells if the header is to generate or not.
|
111
|
-
def to_high(level = 0,header = true)
|
112
|
-
# The resulting string.
|
113
|
-
res = ""
|
114
|
-
# Generate the header if required.
|
115
|
-
if header then
|
116
|
-
res << (" " * (level*3)) << "sub "
|
117
|
-
unless self.name.empty? then
|
118
|
-
res << ":" << Low2High.high_decl_name(self.name) << " "
|
119
|
-
end
|
120
|
-
res << "do\n"
|
121
|
-
end
|
122
|
-
level = level + 1 if header
|
123
|
-
# Generate the sub types.
|
124
|
-
# Assume the types are TypeDef.
|
125
|
-
self.each_type do |type|
|
126
|
-
res << " " * (level*3)
|
127
|
-
res << "typedef :#{type.name} do\n"
|
128
|
-
res << " " * ((level+1)*3) << type.def.to_high(level)
|
129
|
-
res << " " * (level*3) << "end\n"
|
130
|
-
end
|
131
|
-
# Generaste the sub system types.
|
132
|
-
self.each_systemT { |systemT| res << systemT.to_high(level) }
|
133
|
-
# Generate the inners declaration.
|
134
|
-
self.each_inner do |inner|
|
135
|
-
res << " " * (level*3)
|
136
|
-
res << inner.type.to_high(level)
|
137
|
-
res << ".inner :" << Low2High.high_decl_name(inner.name) << "\n"
|
138
|
-
end
|
139
|
-
# Generate the instances.
|
140
|
-
res << "\n" if self.each_inner.any?
|
141
|
-
self.each_systemI do |systemI|
|
142
|
-
res << " " * (level*3)
|
143
|
-
res << systemI.to_high(level) << "\n"
|
144
|
-
end
|
145
|
-
# Generate the sub scopes.
|
146
|
-
self.each_scope do |scope|
|
147
|
-
res << scope.to_high(level)
|
148
|
-
end
|
149
|
-
# Generate the connections.
|
150
|
-
res << "\n" if self.each_scope.any?
|
151
|
-
self.each_connection do |connection|
|
152
|
-
res << connection.to_high(level)
|
153
|
-
end
|
154
|
-
# Generate the behaviors.
|
155
|
-
res << "\n" if self.each_connection.any?
|
156
|
-
self.each_behavior do |behavior|
|
157
|
-
res << behavior.to_high(level)
|
158
|
-
end
|
159
|
-
# Close the scope if required.
|
160
|
-
if header then
|
161
|
-
res << " " * ((level-1)*3) << "end\n"
|
162
|
-
end
|
163
|
-
# Return the result.
|
164
|
-
return res
|
87
|
+
# Add the conversion to high.
|
88
|
+
class TypeSigned
|
89
|
+
# Creates a new high type signed.
|
90
|
+
def to_high
|
91
|
+
return HDLRuby::High::TypeSigned.new(self.name,self.range)
|
165
92
|
end
|
166
93
|
end
|
167
94
|
|
168
95
|
|
169
|
-
|
170
|
-
class
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
def to_high(level = 0)
|
175
|
-
return Low2High.high_use_name(self.name)
|
96
|
+
# Add the conversion to high.
|
97
|
+
class TypeUnsigned
|
98
|
+
# Creates a new high type unsigned.
|
99
|
+
def to_high
|
100
|
+
return HDLRuby::High::TypeUnsigned.new(self.name,self.range)
|
176
101
|
end
|
102
|
+
|
177
103
|
end
|
178
104
|
|
179
|
-
## Extends the TypeDef class with generation of HDLRuby::High text.
|
180
|
-
class TypeDef
|
181
105
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
self.
|
106
|
+
# Add the conversion to high.
|
107
|
+
class TypeTuple
|
108
|
+
# Creates a new high type tuple.
|
109
|
+
def to_high
|
110
|
+
return HDLRuby::High::TypeTuple.new(self.name,self.direction,
|
111
|
+
*self.each_type.map { |typ| typ.to_high })
|
187
112
|
end
|
188
113
|
end
|
189
114
|
|
190
|
-
## Extends the TypeVector class with generation of HDLRuby::High text.
|
191
|
-
class TypeVector
|
192
115
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
res << self.base.to_high(level)
|
200
|
-
# Generate the range.
|
201
|
-
res << "[" << self.range.first.to_high(level) << ".." <<
|
202
|
-
self.range.last.to_high(level) << "]"
|
203
|
-
# Return the result.
|
204
|
-
return res
|
116
|
+
# Add the conversion to high.
|
117
|
+
class TypeStruct
|
118
|
+
# Creates a new high type struct.
|
119
|
+
def to_high
|
120
|
+
return HDLRuby::High::TypeString.new(self.name,self.direction,
|
121
|
+
self.each {|name,typ| [name,typ.to_high]})
|
205
122
|
end
|
206
123
|
end
|
207
124
|
|
208
|
-
## Extends the TypeTuple class with generation of HDLRuby::High text.
|
209
|
-
class TypeTuple
|
210
125
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
#
|
217
|
-
res
|
218
|
-
#
|
219
|
-
res
|
220
|
-
# Return the result.
|
126
|
+
|
127
|
+
# Add the conversion to high.
|
128
|
+
class Behavior
|
129
|
+
# Creates a new high behavior.
|
130
|
+
def to_high
|
131
|
+
# Create the resulting behavior.
|
132
|
+
res = HDLRuby::High::Behavior.new(self.block.to_high)
|
133
|
+
# Adds the events.
|
134
|
+
self.each_event { |ev| res.add_event(ev.to_high) }
|
221
135
|
return res
|
222
136
|
end
|
223
137
|
end
|
224
138
|
|
225
|
-
## Extends the TypeStruct class with generation of HDLRuby::High text.
|
226
|
-
class TypeStruct
|
227
139
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
end.join(", ")
|
237
|
-
# Close the struct.
|
238
|
-
res << " }"
|
239
|
-
# Return the result.
|
140
|
+
# Add the conversion to high.
|
141
|
+
class TimeBehavior
|
142
|
+
# Creates a new high time behavior.
|
143
|
+
def to_high
|
144
|
+
# Create the resulting behavior.
|
145
|
+
res = HDLRuby::High::TimeBehavior.new(self.block.to_high)
|
146
|
+
# Adds the events.
|
147
|
+
self.each_event { |ev| res.add_event(ev.to_high) }
|
240
148
|
return res
|
241
149
|
end
|
242
150
|
end
|
243
151
|
|
244
152
|
|
245
|
-
|
246
|
-
class
|
153
|
+
# Add the conversion to high.
|
154
|
+
class Event
|
155
|
+
# Creates a new high event.
|
156
|
+
def to_high
|
157
|
+
return HDLRuby::High::Event.new(self.type.to_high,self.ref.to_high)
|
158
|
+
end
|
159
|
+
end
|
247
160
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
161
|
+
|
162
|
+
# Add the conversion to high.
|
163
|
+
class SignalI
|
164
|
+
# Creates a new high signal.
|
165
|
+
def to_high
|
166
|
+
# Is there an initial value?
|
167
|
+
if (self.value) then
|
168
|
+
# Yes, create a new high signal with it.
|
169
|
+
return HDLRuby::High::SignalI.new(self.name,self.type.to_high,
|
170
|
+
self.val.to_high)
|
257
171
|
else
|
258
|
-
|
259
|
-
|
260
|
-
if self.each_event.any? then
|
261
|
-
res << "( "
|
262
|
-
res << self.each_event.map do |event|
|
263
|
-
event.to_high(level)
|
264
|
-
end.join(", ")
|
265
|
-
res << " )"
|
172
|
+
# No, create a new high signal with it.
|
173
|
+
return HDLRuby::High::SignalI.new(self.name,self.type.to_high)
|
266
174
|
end
|
267
|
-
res << " do\n"
|
268
|
-
# Generate the content.
|
269
|
-
res << self.block.to_high(level+1,false)
|
270
|
-
# Close the behavior.
|
271
|
-
res << " " * (level*3) << "end\n"
|
272
|
-
# Return the result.
|
273
|
-
return res
|
274
175
|
end
|
275
176
|
end
|
276
177
|
|
277
|
-
## Extends the TimeBehavior class with generation of HDLRuby::High text.
|
278
|
-
class TimeBehavior
|
279
178
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
179
|
+
# Add the conversion to high.
|
180
|
+
class SignalC
|
181
|
+
# Creates a new high constant signal.
|
182
|
+
def to_high
|
183
|
+
# Is there an initial value?
|
184
|
+
if (self.value) then
|
185
|
+
# Yes, create a new high signal with it.
|
186
|
+
return HDLRuby::High::SignalC.new(self.name,self.type.to_high,
|
187
|
+
self.val.to_high)
|
188
|
+
else
|
189
|
+
# No, create a new high signal with it.
|
190
|
+
return HDLRuby::High::SignalC.new(self.name,self.type.to_high)
|
191
|
+
end
|
284
192
|
end
|
285
193
|
end
|
286
194
|
|
287
195
|
|
288
|
-
|
289
|
-
class
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
def to_high(level = 0)
|
294
|
-
return self.ref.to_high(level) + ".#{self.type}"
|
196
|
+
# Add the conversion to high.
|
197
|
+
class SystemI
|
198
|
+
# Creates a new high system instance.
|
199
|
+
def to_high
|
200
|
+
return HDLRuby::High::SystemI.new(self.name,self.systemT.to_high)
|
295
201
|
end
|
296
202
|
end
|
297
203
|
|
298
204
|
|
299
|
-
|
300
|
-
class
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
return Low2High.high_use_name(self.name)
|
205
|
+
# Add the conversion to high.
|
206
|
+
class Chunk
|
207
|
+
# Creates a new high code chunk.
|
208
|
+
def to_high
|
209
|
+
return HDLRuby::High::Chunk.new(self.name,
|
210
|
+
*self.each_lump { |lump| lump.to_high })
|
306
211
|
end
|
307
212
|
end
|
308
213
|
|
309
214
|
|
310
|
-
|
311
|
-
class
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
215
|
+
# Add the conversion to high.
|
216
|
+
class Code
|
217
|
+
# Creates a new high code.
|
218
|
+
def to_high
|
219
|
+
# Create the new code.
|
220
|
+
res = HDLRuby::High::Code.new
|
221
|
+
# Add the events.
|
222
|
+
self.each_event { |ev| res.add_event(ev.to_high) }
|
223
|
+
# Add the code chunks.
|
224
|
+
self.each_chunk { |ch| res.add_chunk(ch.to_high) }
|
318
225
|
end
|
319
226
|
end
|
320
227
|
|
321
228
|
|
322
|
-
|
229
|
+
# Add the conversion to high.
|
323
230
|
class Statement
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
# Should never be here.
|
329
|
-
raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
|
231
|
+
# Creates a new high statement.
|
232
|
+
def to_high
|
233
|
+
raise AnyError,
|
234
|
+
"Internal error: to_high is not defined for class: #{self.class}"
|
330
235
|
end
|
331
236
|
end
|
332
237
|
|
333
|
-
## Extends the Transmit class with generation of HDLRuby::High text.
|
334
|
-
class Transmit
|
335
238
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
239
|
+
# Add the conversion to high.
|
240
|
+
class Transmit
|
241
|
+
# Creates a new high transmit statement.
|
242
|
+
def to_high
|
243
|
+
return HDLRuby::High::Transmit.new(self.left.to_high,
|
244
|
+
self.right.to_high)
|
342
245
|
end
|
343
246
|
end
|
344
|
-
|
345
|
-
## Extends the If class with generation of HDLRuby::High text.
|
346
|
-
class If
|
347
247
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
#
|
354
|
-
res << "hif " << self.condition.to_high(level) << " do\n"
|
355
|
-
# Generate the yes part.
|
356
|
-
res << self.yes.to_high(level+1)
|
357
|
-
res << " " * (level*3) << "end\n"
|
358
|
-
# Generate the alternate if parts.
|
359
|
-
self.each_noif do |cond,stmnt|
|
360
|
-
res << " " * (level*3)
|
361
|
-
res << "helsif " << cond.to_high(level) << " do\n"
|
362
|
-
res << stmnt.to_high(level+1)
|
363
|
-
res << " " * (level*3) << "end\n"
|
364
|
-
end
|
365
|
-
# Generate the no part if any.
|
248
|
+
|
249
|
+
# Add the conversion to high.
|
250
|
+
class If
|
251
|
+
# Creates a new high if statement.
|
252
|
+
def to_high
|
253
|
+
# Is there a no?
|
366
254
|
if self.no then
|
367
|
-
|
368
|
-
res
|
369
|
-
|
255
|
+
# Yes, create a new if statement with it.
|
256
|
+
res = HDLRuby::High::If.new(self.condition.to_high,
|
257
|
+
self.yes.to_high,self.no.to_high)
|
258
|
+
else
|
259
|
+
# No, create a new if statement without it.
|
260
|
+
res = HDLRuby::High::If.new(self.condition.to_high,
|
261
|
+
self.yes.to_high)
|
262
|
+
end
|
263
|
+
# Add the noifs if any.
|
264
|
+
self.each_noif do |cond,stmnt|
|
265
|
+
res.add_noif(cond.to_high,stmt.to_high)
|
370
266
|
end
|
371
|
-
# Return the result.
|
372
267
|
return res
|
373
268
|
end
|
374
269
|
end
|
375
270
|
|
376
|
-
## Extends the When class with generation of HDLRuby::High text.
|
377
|
-
class When
|
378
271
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
res << "hwhen " << self.match.to_high(level+1) << " do\n"
|
386
|
-
# Generate the statement.
|
387
|
-
res << self.statement.to_high(level+1)
|
388
|
-
# Close the when.
|
389
|
-
res << " " * (level*3) << "end\n"
|
390
|
-
# Returns the result.
|
391
|
-
return res
|
272
|
+
# Add the conversion to high.
|
273
|
+
class When
|
274
|
+
# Creates a new high when.
|
275
|
+
def to_high
|
276
|
+
return HDLRuby::High::When.new(self.match.to_high,
|
277
|
+
self.statement.to_high)
|
392
278
|
end
|
393
279
|
end
|
394
280
|
|
395
|
-
## Extends the Case class with generation of HDLRuby::High text.
|
396
|
-
class Case
|
397
281
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
# Generate the test.
|
404
|
-
res << "hcase " << self.value.to_high(level) << "\n"
|
405
|
-
# Generate the whens.
|
406
|
-
self.each_when do |w|
|
407
|
-
res << w.to_high(level)
|
408
|
-
end
|
409
|
-
# Generatethe default.
|
282
|
+
# Add the conversion to high.
|
283
|
+
class Case
|
284
|
+
# Creates a new high case statement.
|
285
|
+
def to_high
|
286
|
+
# Is there a default?
|
410
287
|
if self.default then
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
res << "end\n"
|
288
|
+
# Yes, create the new case statement with it.
|
289
|
+
return HDLRuby::High::Case.new(self.value.to_high,
|
290
|
+
self.default.to_high,
|
291
|
+
self.each_when.map { |w| w.to_high })
|
416
292
|
end
|
417
|
-
# Return the resulting string.
|
418
|
-
return res
|
419
293
|
end
|
420
294
|
end
|
421
295
|
|
422
296
|
|
423
|
-
|
297
|
+
# Add the conversion to high.
|
424
298
|
class Delay
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
def to_high(level = 0)
|
429
|
-
return self.value.to_high(level) + ".#{self.unit}"
|
299
|
+
# Creates a new high delay.
|
300
|
+
def to_high
|
301
|
+
return HDLRuby::High::Delay.new(self.value,self.unit)
|
430
302
|
end
|
431
303
|
end
|
432
304
|
|
433
305
|
|
434
|
-
|
435
|
-
class
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
# The resulting string.
|
441
|
-
res = " " * (level*3)
|
442
|
-
# Generate the wait.
|
443
|
-
res << "wait " << self.delay.to_high(level) << "\n"
|
444
|
-
# Return the resulting string.
|
445
|
-
return res
|
306
|
+
# Add the conversion to high.
|
307
|
+
class Print
|
308
|
+
# Creates a new high print statement.
|
309
|
+
def to_high
|
310
|
+
return HDLRuby::High::Print.new(
|
311
|
+
*self.each_arg.map {|arg| arg.to_high })
|
446
312
|
end
|
447
313
|
end
|
448
314
|
|
449
|
-
## Extends the TimeRepeat class with generation of HDLRuby::High text.
|
450
|
-
class TimeRepeat
|
451
315
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
# Generate the header.
|
458
|
-
res << "repeat " << self.delay.to_high(level) << " do\n"
|
459
|
-
# Generate the statement to repeat.
|
460
|
-
res << self.statement.to_high(level+1)
|
461
|
-
# Close the repeat.
|
462
|
-
res << " " * (level*3) << "end\n"
|
463
|
-
# Return the resulting string.
|
464
|
-
return res
|
316
|
+
# Add the conversion to high.
|
317
|
+
class TimeWait
|
318
|
+
# Creates a new high wait statement.
|
319
|
+
def to_high
|
320
|
+
return HDLRuby::High::TimeWait.new(self.delay.to_high)
|
465
321
|
end
|
466
322
|
end
|
467
323
|
|
468
|
-
## Extends the Block class with generation of HDLRuby::High text.
|
469
|
-
class Block
|
470
324
|
|
471
|
-
|
472
|
-
|
473
|
-
#
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
res = ""
|
478
|
-
# Generate the header if required.
|
479
|
-
if header then
|
480
|
-
if timed then
|
481
|
-
res << " " * (level*3) << "timed "
|
482
|
-
else
|
483
|
-
res << " " * (level*3) << "#{self.mode} "
|
484
|
-
end
|
485
|
-
unless self.name.empty? then
|
486
|
-
res << ":" << Low2High.high_decl_name(self.name) << " "
|
487
|
-
end
|
488
|
-
res << "do\n"
|
489
|
-
end
|
490
|
-
level = level + 1 if header
|
491
|
-
# Generate the inners declaration.
|
492
|
-
self.each_inner do |inner|
|
493
|
-
res << " " * (level*3)
|
494
|
-
res << inner.type.to_high(level)
|
495
|
-
res << ".inner :" << Low2High.high_decl_name(inner.name) << "\n"
|
496
|
-
end
|
497
|
-
# Generate the statements.
|
498
|
-
self.each_statement do |stmnt|
|
499
|
-
res << stmnt.to_high(level)
|
500
|
-
end
|
501
|
-
# Close the block.
|
502
|
-
if header then
|
503
|
-
res << " " * ((level-1)*3) << "end\n"
|
504
|
-
end
|
505
|
-
# Return the result.
|
506
|
-
return res
|
325
|
+
# Add the conversion to high.
|
326
|
+
class TimeRepeat
|
327
|
+
# Creates a new high repreat statement.
|
328
|
+
def to_high
|
329
|
+
return HDLRuby::High::TimeReapeat.new(self.delay.to_high,
|
330
|
+
self.statement.to_high)
|
507
331
|
end
|
508
332
|
end
|
509
333
|
|
510
|
-
## Extends the TimeBlock class with generation of HDLRuby::High text.
|
511
|
-
class TimeBlock
|
512
334
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
335
|
+
# Add the conversion to high.
|
336
|
+
class Block
|
337
|
+
# Creates a new high block statement.
|
338
|
+
def to_high
|
339
|
+
# Create the new block statement.
|
340
|
+
res = HDLRuby::High::Block.new(self.mode,self.name)
|
341
|
+
# Add the statements.
|
342
|
+
self.each_statement { |stmnt| res.add_statement(stmnt.to_high) }
|
343
|
+
return res
|
517
344
|
end
|
518
345
|
end
|
519
346
|
|
520
347
|
|
521
|
-
|
522
|
-
class
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
348
|
+
# Add the conversion to high.
|
349
|
+
class TimeBlock
|
350
|
+
# Creates a new high time block statement.
|
351
|
+
def to_high
|
352
|
+
# Create the new block statement.
|
353
|
+
res = HDLRuby::High::TimeBlock.new(self.mode,self.name)
|
354
|
+
# Add the statements.
|
355
|
+
self.each_statement { |stmnt| res.add_statement(stmnt.to_high) }
|
356
|
+
return res
|
528
357
|
end
|
529
358
|
end
|
530
359
|
|
531
|
-
|
360
|
+
|
361
|
+
# Add the conversion to high.
|
532
362
|
class Connection
|
533
|
-
#
|
363
|
+
# Creates a new high connection.
|
364
|
+
def to_high
|
365
|
+
return HDLRuby::High::Connection.new(self.left.to_high,
|
366
|
+
self.right.to_high)
|
367
|
+
end
|
534
368
|
end
|
535
369
|
|
536
370
|
|
537
|
-
|
371
|
+
# Add the conversion to high.
|
538
372
|
class Expression
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
# Should never be here.
|
544
|
-
raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
|
373
|
+
# Creates a new high expression.
|
374
|
+
def to_high
|
375
|
+
raise AnyError,
|
376
|
+
"Internal error: to_high is not defined for class: #{self.class}"
|
545
377
|
end
|
546
378
|
end
|
547
379
|
|
548
|
-
|
380
|
+
|
381
|
+
# Add the conversion to high.
|
549
382
|
class Value
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
return
|
383
|
+
# Creates a new high value expression.
|
384
|
+
def to_high
|
385
|
+
# Is there a content?
|
386
|
+
if (self.content) then
|
387
|
+
# Yes, use it for creating the new value.
|
388
|
+
return HDLRuby::High::Value.new(self.type.to_high,
|
389
|
+
self.content.to_high)
|
556
390
|
else
|
557
|
-
|
391
|
+
# puts "Self.type.name=#{self.type.name}"
|
392
|
+
# No (this should be a void value).
|
393
|
+
return HDLRuby::High::Value.new(self.type.to_high,nil)
|
558
394
|
end
|
559
395
|
end
|
560
396
|
end
|
561
397
|
|
562
|
-
## Extends the Cast class with generation of HDLRuby::High text.
|
563
|
-
class Cast
|
564
398
|
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
399
|
+
# Add the conversion to high.
|
400
|
+
class Cast
|
401
|
+
# Creates a new high cast expression.
|
402
|
+
def to_high
|
403
|
+
return HDLRuby::High::Cast(self.type.to_high, self.child.to_high)
|
570
404
|
end
|
571
405
|
end
|
572
406
|
|
573
|
-
## Extends the Operation class with generation of HDLRuby::High text.
|
574
|
-
class Operation
|
575
407
|
|
576
|
-
|
577
|
-
|
578
|
-
def to_high(level = 0)
|
579
|
-
# Should never be here.
|
580
|
-
raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
|
581
|
-
end
|
408
|
+
# Add the conversion to high.
|
409
|
+
class Operation
|
582
410
|
end
|
583
411
|
|
584
|
-
## Extends the Unary class with generation of HDLRuby::High text.
|
585
|
-
class Unary
|
586
412
|
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
413
|
+
# Add the conversion to high.
|
414
|
+
class Unary
|
415
|
+
# Creates a new high unary expression.
|
416
|
+
def to_high
|
417
|
+
return HDLRuby::High::Unary.new(self.type.to_high,self.operator,
|
418
|
+
self.child.to_high)
|
591
419
|
end
|
592
420
|
end
|
593
421
|
|
594
|
-
## Extends the Binary class with generation of HDLRuby::High text.
|
595
|
-
class Binary
|
596
422
|
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
423
|
+
# Add the conversion to high.
|
424
|
+
class Binary
|
425
|
+
# Creates a new high binary expression.
|
426
|
+
def to_high
|
427
|
+
return HDLRuby::High::Binary.new(self.type.to_high,self.operator,
|
428
|
+
self.left.to_high,
|
429
|
+
self.right.to_high)
|
602
430
|
end
|
603
431
|
end
|
604
432
|
|
605
|
-
## Extends the Select class with generation of HDLRuby::High text.
|
606
|
-
class Select
|
607
433
|
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
# Generate the choices
|
616
|
-
res << self.each_choice.map do |choice|
|
617
|
-
choice.to_high(level+1)
|
618
|
-
end.join(", ")
|
619
|
-
# Close the select.
|
620
|
-
res << ")"
|
621
|
-
# Return the resulting string.
|
622
|
-
return res
|
434
|
+
# Add the conversion to high.
|
435
|
+
class Select
|
436
|
+
# Creates a new high select expression.
|
437
|
+
def to_high
|
438
|
+
return HDLRuby::High::Select(self.type.to_high,self.operator,
|
439
|
+
self.select.to_high,
|
440
|
+
self.each_choice.map { |ch| ch.to_high })
|
623
441
|
end
|
624
442
|
end
|
625
443
|
|
626
|
-
## Extends the Concat class with generation of HDLRuby::High text.
|
627
|
-
class Concat
|
628
444
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
res << "[ "
|
636
|
-
# Generate the expressions.
|
637
|
-
res << self.each_expression.map do |expression|
|
638
|
-
expression.to_high(level+1)
|
639
|
-
end.join(", ")
|
640
|
-
# Close the select.
|
641
|
-
res << " ]"
|
642
|
-
# Return the resulting string.
|
643
|
-
return res
|
445
|
+
# Add the conversion to high.
|
446
|
+
class Concat
|
447
|
+
# Creates a new high concat expression.
|
448
|
+
def to_high
|
449
|
+
return HDLRuby::High::Concat.new(self.type.to_high,
|
450
|
+
self.each_expression.map { |ex| ex.to_high })
|
644
451
|
end
|
645
452
|
end
|
646
453
|
|
647
454
|
|
648
|
-
|
455
|
+
# Add the conversion to high.
|
649
456
|
class Ref
|
650
|
-
|
651
|
-
# Generates the text of the equivalent HDLRuby::High code.
|
652
|
-
# +level+ is the hierachical level of the object.
|
653
|
-
def to_high(level = 0)
|
654
|
-
# Should never be here.
|
655
|
-
raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
|
656
|
-
end
|
657
457
|
end
|
658
458
|
|
659
|
-
## Extends the RefConcat class with generation of HDLRuby::High text.
|
660
|
-
class RefConcat
|
661
459
|
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
res << "[ "
|
669
|
-
# Generate the references.
|
670
|
-
res << self.each_ref.map do |ref|
|
671
|
-
ref.to_high(level+1)
|
672
|
-
end.join(", ")
|
673
|
-
# Close the select.
|
674
|
-
res << " ]"
|
675
|
-
# Return the resulting string.
|
676
|
-
return res
|
460
|
+
# Add the conversion to high.
|
461
|
+
class RefConcat
|
462
|
+
# Creates a new high concat reference.
|
463
|
+
def to_high
|
464
|
+
return HDLRuby::High::Ref.new(self.type.to_high,
|
465
|
+
self.each_ref.map { |ref| ref.to_high })
|
677
466
|
end
|
678
467
|
end
|
679
468
|
|
680
|
-
## Extends the RefIndex class with generation of HDLRuby::High text.
|
681
|
-
class RefIndex
|
682
469
|
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
470
|
+
# Add the conversion to high.
|
471
|
+
class RefIndex
|
472
|
+
# Creates a new high index reference.
|
473
|
+
def to_high
|
474
|
+
return HDLRuby::High::RefIndex.new(self.type.to_high,
|
475
|
+
self.ref.to_high,
|
476
|
+
self.index.to_high)
|
687
477
|
end
|
688
478
|
end
|
689
479
|
|
690
|
-
## Extends the RefRange class with generation of HDLRuby::High text.
|
691
|
-
class RefRange
|
692
480
|
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
481
|
+
# Add the conversion to high.
|
482
|
+
class RefRange
|
483
|
+
# Creates a new high range reference.
|
484
|
+
def to_high
|
485
|
+
return HDLRuby::High::RefRange.new(self.type.to_high,
|
486
|
+
self.ref.to_high,
|
487
|
+
self.range.first.to_high..self.range.last.to_high)
|
698
488
|
end
|
699
489
|
end
|
700
490
|
|
701
|
-
## Extends the RefName class with generation of HDLRuby::High text.
|
702
|
-
class RefName
|
703
491
|
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
# Generates the current reference.
|
712
|
-
res << Low2High.high_use_name(self.name)
|
713
|
-
# Returns the resulting string.
|
714
|
-
return res
|
492
|
+
# Add the conversion to high.
|
493
|
+
class RefName
|
494
|
+
# Creates a new high range reference.
|
495
|
+
def to_high
|
496
|
+
return HDLRuby::High::RefName.new(self.type.to_high,
|
497
|
+
self.ref.to_high,
|
498
|
+
self.name)
|
715
499
|
end
|
716
500
|
end
|
717
501
|
|
718
|
-
## Extends the RefThis class with generation of HDLRuby::High text.
|
719
|
-
class RefThis
|
720
502
|
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
503
|
+
# Add the conversion to high.
|
504
|
+
class RefThis
|
505
|
+
# Creates a new high ref this.
|
506
|
+
def to_high
|
507
|
+
return HDLRuby::High::RefThis.new
|
725
508
|
end
|
726
509
|
end
|
727
510
|
|
728
|
-
## Extends the Numeric class with generation of HDLRuby::High text.
|
729
|
-
class ::Numeric
|
730
511
|
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
512
|
+
# Add the conversion to high.
|
513
|
+
class StringE
|
514
|
+
# Creates a new high string expression.
|
515
|
+
def to_high
|
516
|
+
return HDLRuby::High::StringE.new(self.content,
|
517
|
+
*self.each_arg.map {|arg| arg.to_high })
|
735
518
|
end
|
736
519
|
end
|
737
|
-
|
738
520
|
end
|