HDLRuby 2.11.11 → 2.11.12

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -18
  3. data/ext/hruby_sim/hruby_rcsim_build.c +27 -0
  4. data/ext/hruby_sim/hruby_sim.h +3 -0
  5. data/ext/hruby_sim/hruby_sim_core.c +17 -5
  6. data/ext/hruby_sim/hruby_sim_stack_calc.c +1 -1
  7. data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
  8. data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
  9. data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
  10. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
  11. data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
  12. data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
  13. data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
  14. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +11 -11
  15. data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
  16. data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
  17. data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
  18. data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
  19. data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
  20. data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
  21. data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
  22. data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
  23. data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
  24. data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
  25. data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
  26. data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
  27. data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
  28. data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
  29. data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
  30. data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
  31. data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
  32. data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
  33. data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
  34. data/lib/HDLRuby/hdrcc.rb +14 -1
  35. data/lib/HDLRuby/hruby_bstr.rb +10 -5
  36. data/lib/HDLRuby/hruby_high.rb +114 -27
  37. data/lib/HDLRuby/hruby_low.rb +187 -16
  38. data/lib/HDLRuby/hruby_low2c.rb +71 -11
  39. data/lib/HDLRuby/hruby_low2vhd.rb +2 -1
  40. data/lib/HDLRuby/hruby_low_fix_types.rb +1 -0
  41. data/lib/HDLRuby/hruby_low_mutable.rb +30 -1
  42. data/lib/HDLRuby/hruby_low_resolve.rb +15 -2
  43. data/lib/HDLRuby/hruby_low_without_concat.rb +28 -8
  44. data/lib/HDLRuby/hruby_low_without_parinseq.rb +14 -4
  45. data/lib/HDLRuby/hruby_low_without_select.rb +2 -2
  46. data/lib/HDLRuby/hruby_low_without_subsignals.rb +279 -0
  47. data/lib/HDLRuby/hruby_rcsim.rb +80 -71
  48. data/lib/HDLRuby/hruby_rsim.rb +132 -7
  49. data/lib/HDLRuby/hruby_rsim_vcd.rb +99 -27
  50. data/lib/HDLRuby/hruby_values.rb +35 -31
  51. data/lib/HDLRuby/std/bram.rb +22 -0
  52. data/lib/HDLRuby/std/fixpoint.rb +2 -2
  53. data/lib/HDLRuby/std/fsm.rb +20 -3
  54. data/lib/HDLRuby/std/function_generator.rb +2 -2
  55. data/lib/HDLRuby/version.rb +1 -1
  56. metadata +7 -3
  57. data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
@@ -0,0 +1,279 @@
1
+ require 'HDLRuby'
2
+ require 'HDLRuby/hruby_tools'
3
+ require 'HDLRuby/hruby_low_mutable'
4
+ require 'HDLRuby/hruby_low_resolve'
5
+
6
+
7
+ module HDLRuby::Low
8
+
9
+
10
+ ##
11
+ # Replace hierachical signals by the list of their sub signals.
12
+ # Makes handling by some synthesis tools easier.
13
+ #
14
+ ########################################################################
15
+
16
+ ## Extends the SystemT class with functionality for decomposing the
17
+ # hierachical signals in the statements.
18
+ class SystemT
19
+
20
+ # Decompose the hierarchical signals in the statements.
21
+ def signal2subs!
22
+ self.scope.signal2subs!
23
+ end
24
+ end
25
+
26
+
27
+ ## Extends the Scope class with functionality for decomposing the
28
+ # hierachical signals in the statements.
29
+ class Scope
30
+
31
+ # Decompose the hierarchical signals in the statements.
32
+ def signal2subs!
33
+ # Recruse on the sub scopes.
34
+ self.each_scope(&:signal2subs!)
35
+
36
+ # Recurse on the blocks.
37
+ self.each_behavior do |behavior|
38
+ # behavior.block.each_block_deep(&:signal2subs!)
39
+ behavior.signal2subs!
40
+ end
41
+
42
+ # Work on the connections.
43
+ self.each_connection.to_a.each do |connection|
44
+ # Recurse on the left and right.
45
+ connection.set_left!(connection.left.signal2subs!)
46
+ connection.set_right!(connection.right.signal2subs!)
47
+ end
48
+ end
49
+ end
50
+
51
+
52
+ ## Extends the Behavior class with functionality for decomposing the
53
+ # hierachical signals in the statements.
54
+ class Behavior
55
+
56
+ # Decompose the hierarchical signals in the statements.
57
+ def signal2subs!
58
+ # Process the events.
59
+ self.each_event.to_a.each do |ev|
60
+ subrefs = ev.ref.flatten
61
+ if subrefs.any? then
62
+ # The refence have been flattend, remove the event.
63
+ self.delete_event!(ev)
64
+ # And add instead new events for the sub references.
65
+ subrefs.each do |subref|
66
+ nev = Event.new(ev.type,subref)
67
+ self.add_event(nev)
68
+ end
69
+ end
70
+ end
71
+ # Recurse on the blocks.
72
+ self.block.each_block_deep(&:signal2subs!)
73
+ end
74
+ end
75
+
76
+
77
+ ## Extends the Block class with functionality for decomposing the
78
+ # hierachical signals in the statements.
79
+ class Block
80
+
81
+ # Decompose the hierarchical signals in the statements.
82
+ def signal2subs!
83
+ # Recurse on the statments.
84
+ self.map_statements! do |stmnt|
85
+ stmnt.signal2subs!
86
+ end
87
+ return self
88
+ end
89
+ end
90
+
91
+
92
+ ## Extends the TimeWait class with functionality for decomposing the
93
+ # hierachical signals in the statements.
94
+ class TimeWait
95
+
96
+ # Decompose the hierarchical signals in the statements.
97
+ def signal2subs!
98
+ # Nothing to do.
99
+ return self
100
+ end
101
+ end
102
+
103
+
104
+ ## Extends the TimeRepeat class with functionality for decomposing the
105
+ # hierachical signals in the statements.
106
+ class TimeRepeat
107
+
108
+ # Decompose the hierarchical signals in the statements.
109
+ def signal2subs!
110
+ # Recurse on the statement.
111
+ self.set_statement!(self.statement.signal2subs!)
112
+ return self
113
+ end
114
+ end
115
+
116
+
117
+ ## Extends the Transmit class with functionality for decomposing the
118
+ # hierachical signals in the statements.
119
+ class Transmit
120
+
121
+ # Decompose the hierarchical signals in the statements.
122
+ def signal2subs!
123
+ # Recurse on the left and right.
124
+ self.set_left!(self.left.signal2subs!)
125
+ self.set_right!(self.right.signal2subs!)
126
+ return self
127
+ end
128
+ end
129
+
130
+
131
+ ## Extends the Print class with functionality for decomposing the
132
+ # hierachical signals in the statements.
133
+ class Print
134
+
135
+ # Decompose the hierarchical signals in the statements.
136
+ def signal2subs!
137
+ # Recurse on the arguments.
138
+ self.map_args! { |arg| arg.signal2subs! }
139
+ return self
140
+ end
141
+ end
142
+
143
+
144
+ ## Extends the Print class with functionality for decomposing the
145
+ # hierachical signals in the statements.
146
+ class TimeTerminate
147
+
148
+ # Decompose the hierarchical signals in the statements.
149
+ def signal2subs!
150
+ # Nothing to do.
151
+ return self
152
+ end
153
+ end
154
+
155
+
156
+ ## Extends the If class with functionality for decomposing the
157
+ # hierachical signals in the statements.
158
+ class If
159
+
160
+ # Decompose the hierarchical signals in the statements.
161
+ def signal2subs!
162
+ # Recurse on the condition.
163
+ self.set_condition!(self.condition.signal2subs!)
164
+ # Recurse on the yes block.
165
+ self.yes.signal2subs!
166
+ # Recurse on the no block if any.
167
+ self.no.signal2subs! if self.no
168
+ # Recurse on the alternate ifs.
169
+ self.map_noifs! do |cond,stmnt|
170
+ [cond.signal2subs!,stmnt.signal2subs!]
171
+ end
172
+ return self
173
+ end
174
+ end
175
+
176
+
177
+ ## Extends the When class with functionality for decomposing the
178
+ # hierachical signals in the statements.
179
+ class When
180
+
181
+ # Decompose the hierarchical signals in the statements.
182
+ def signal2subs!
183
+ # Recurse on the match.
184
+ self.set_match!(self.match.signal2subs!)
185
+ # Recurse on the statement.
186
+ self.set_statement!(self.statement.signal2subs!)
187
+ return self
188
+ end
189
+
190
+ end
191
+
192
+
193
+ ## Extends the Case class with functionality for decomposing the
194
+ # hierachical signals in the statements.
195
+ class Case
196
+
197
+ # Decompose the hierarchical signals in the statements.
198
+ def signal2subs!
199
+ # Recurse on the case value.
200
+ self.set_value!(self.value.signal2subs!)
201
+ # Recurse on the whens.
202
+ self.each_when(&:signal2subs!)
203
+ # Recurse on the default.
204
+ self.set_default!(self.default.signal2subs!) if self.default
205
+ return self
206
+ end
207
+ end
208
+
209
+
210
+ ## Extends the Expression class with functionality for decomposing the
211
+ # hierachical signals in the statements.
212
+ class Expression
213
+
214
+ # Decompose the hierarchical signals in the statements.
215
+ def signal2subs!
216
+ # puts "signal2subs! for expr=#{self}"
217
+ # Recurse on the subexpressions.
218
+ self.map_expressions!(&:signal2subs!)
219
+ return self
220
+ end
221
+ end
222
+
223
+
224
+ ## Extends the RefName class with functionality for decomposing the
225
+ # hierachical signals in the statements.
226
+ class RefName
227
+
228
+ # Flatten a reference to a list of reference to leaf signals
229
+ # from signal +sig+ and add to result to +subrefs+
230
+ def flatten_to(sig,subrefs)
231
+ # puts "flatten_to with sig name=#{sig.name}"
232
+ # Work on the sub signals if any.
233
+ sig.each_signal do |sub|
234
+ # Create a reference for the sub.
235
+ subref = RefName.new(sub.type,self.clone,sub.name)
236
+ # Recruse on it.
237
+ subref.flatten_to(sub,subrefs)
238
+ # Was it a leaf?
239
+ unless sub.each_signal.any? then
240
+ # Yes, add its new ref to the list of subs.
241
+ subrefs << subref
242
+ end
243
+ end
244
+ end
245
+
246
+ # Flatten the current ref to a list of references.
247
+ # If the reference is not heirachical, returns an empty list.
248
+ def flatten
249
+ subrefs = []
250
+ self.flatten_to(self.resolve,subrefs)
251
+ return subrefs
252
+ end
253
+
254
+ # Decompose the hierarchical signals in the statements.
255
+ def signal2subs!
256
+ # puts "signal2subs! for RefName: #{self.name}"
257
+ # Decompose it to a list of reference to each leaf sub signal.
258
+ subrefs = []
259
+ self.flatten_to(self.resolve,subrefs)
260
+ # puts "subrefs=#{subrefs.map{|subref| subref.name}}"
261
+ # Has it sub signals?
262
+ if (subrefs.any?) then
263
+ # Yes, convert it to a Concat.
264
+ if self.leftvalue? then
265
+ return RefConcat.new(self.type,subrefs)
266
+ else
267
+ return Concat.new(self.type,subrefs)
268
+ end
269
+ else
270
+ # Nothing to do.
271
+ return self
272
+ end
273
+ end
274
+ end
275
+
276
+
277
+
278
+
279
+ end
@@ -17,7 +17,6 @@ module HDLRuby::High
17
17
 
18
18
  ## Gives the width of an int in the current computer.
19
19
  def self.int_width
20
- # puts "int_width=#{[1.to_i].pack("i").size*8}"
21
20
  return [1.to_i].pack("i").size*8
22
21
  end
23
22
 
@@ -105,30 +104,18 @@ module HDLRuby::High
105
104
  RCSim.rcsim_set_owner(@rcsystemT,rcowner)
106
105
  end
107
106
  # Create and add the interface signals.
108
- # self.each_input do |sig|
109
- # rcsig = sig.to_rcsim(@rcsystemT)
110
- # RCSim.rcsim_add_systemT_input(@rcsystemT,rcsig)
111
- # end
112
107
  if self.each_input.any? then
113
108
  RCSim.rcsim_add_systemT_inputs(@rcsystemT,
114
109
  self.each_input.map do |sig|
115
110
  sig.to_rcsim(@rcsystemT)
116
111
  end)
117
112
  end
118
- # self.each_output do |sig|
119
- # rcsig = sig.to_rcsim(@rcsystemT)
120
- # RCSim.rcsim_add_systemT_output(@rcsystemT,rcsig)
121
- # end
122
113
  if self.each_output.any? then
123
114
  RCSim.rcsim_add_systemT_outputs(@rcsystemT,
124
115
  self.each_output.map do |sig|
125
116
  sig.to_rcsim(@rcsystemT)
126
117
  end)
127
118
  end
128
- # self.each_inout do |sig|
129
- # rcsig = sig.to_rcsim(@rcsystemT)
130
- # RCSim.rcsim_add_systemT_inout(@rcsystemT,rcsig)
131
- # end
132
119
  if self.each_inout.any? then
133
120
  RCSim.rcsim_add_systemT_inouts(@rcsystemT,
134
121
  self.each_inout.map do |sig|
@@ -174,10 +161,6 @@ module HDLRuby::High
174
161
  subowner = self.parent.is_a?(SystemT) ? rcowner : @rcscope
175
162
 
176
163
  # Create and add the inner signals.
177
- # self.each_inner do |sig|
178
- # rcsig = sig.to_rcsim(@rcscope)
179
- # RCSim.rcsim_add_scope_inner(@rcscope,rcsig)
180
- # end
181
164
  if self.each_inner.any? then
182
165
  RCSim.rcsim_add_scope_inners(@rcscope,self.each_inner.map do|sig|
183
166
  # sig.to_rcsim(@rcscope)
@@ -186,10 +169,6 @@ module HDLRuby::High
186
169
  end
187
170
 
188
171
  # Create and add the system instances.
189
- # self.each_systemI do |sys|
190
- # rcsys = sys.to_rcsim(@rcscope)
191
- # RCSim.rcsim_add_scope_systemI(@rcscope,rcsys)
192
- # end
193
172
  if self.each_systemI.any? then
194
173
  RCSim.rcsim_add_scope_systemIs(@rcscope,
195
174
  self.each_systemI.map do |sys|
@@ -198,6 +177,14 @@ module HDLRuby::High
198
177
  end)
199
178
  end
200
179
 
180
+ # Create and add the sub scopes.
181
+ if self.each_scope.any? then
182
+ RCSim.rcsim_add_scope_scopes(@rcscope,self.each_scope.map do|sub|
183
+ # sub.to_rcsim(@rcscope)
184
+ sub.to_rcsim(subowner)
185
+ end)
186
+ end
187
+
201
188
  # # Create and add the behaviors.
202
189
  # if self.each_behavior.any? then
203
190
  # RCSim.rcsim_add_scope_behaviors(@rcscope,
@@ -224,18 +211,6 @@ module HDLRuby::High
224
211
  # Create and add the codes.
225
212
  # TODO!!
226
213
 
227
- # Create and add the sub scopes.
228
- # self.each_scope do |sub|
229
- # rcsub = sub.to_rcsim(@rcscope)
230
- # RCSim.rcsim_add_scope_scope(@rcscope,rcsub)
231
- # end
232
- if self.each_scope.any? then
233
- RCSim.rcsim_add_scope_scopes(@rcscope,self.each_scope.map do|sub|
234
- # sub.to_rcsim(@rcscope)
235
- sub.to_rcsim(subowner)
236
- end)
237
- end
238
-
239
214
  return @rcscope
240
215
  end
241
216
  end
@@ -322,6 +297,20 @@ module HDLRuby::High
322
297
 
323
298
  attr_reader :rcbehavior
324
299
 
300
+ # Add sub leaf events from +sig+ of +type+.
301
+ def add_sub_events(type,sig)
302
+ if sig.each_signal.any? then
303
+ # The event is hierarchical, recurse.
304
+ sig.each_signal do |sub|
305
+ self.add_sub_events(type,sub)
306
+ end
307
+ else
308
+ # Te event is not hierarchical, add it.
309
+ ref = RefObject.new(this,sig)
310
+ self.add_event(Event.new(type,ref))
311
+ end
312
+ end
313
+
325
314
  # Generate the C description of the behavior comming from object
326
315
  # whose C description is +rcowner+
327
316
  def to_rcsim(rcowner)
@@ -350,6 +339,16 @@ module HDLRuby::High
350
339
  events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
351
340
  # Add them to the behavior for further processing.
352
341
  events.each {|event| self.add_event(event) }
342
+ else
343
+ # Maybe there are event on hierachical signals.
344
+ events.each do |event|
345
+ if event.ref.object.each_signal.any? then
346
+ # This is a hierarchical event, remove it.
347
+ self.delete_event!(event)
348
+ # And replace it by event of the subs of the signal.
349
+ self.add_sub_events(event.type,event.ref)
350
+ end
351
+ end
353
352
  end
354
353
 
355
354
  # Create the behavior C object.
@@ -360,13 +359,9 @@ module HDLRuby::High
360
359
  RCSim.rcsim_set_owner(@rcbehavior,rcowner)
361
360
 
362
361
  # Create and add the events.
363
- # self.each_event do |ev|
364
- # RCSim.rcsim_add_behavior_event(@rcbehavior,ev.to_rcsim)
365
- # end
366
362
  if self.each_event.any? then
367
363
  RCSim.rcsim_add_behavior_events(@rcbehavior,
368
364
  self.each_event.map do |ev|
369
- # puts "adding event: #{ev.ref.object.name}(#{ev.type})"
370
365
  ev.to_rcsim(@rcbehavior)
371
366
  end)
372
367
  end
@@ -425,6 +420,12 @@ module HDLRuby::High
425
420
  # Set the owner.
426
421
  RCSim.rcsim_set_owner(@rcsignalI,rcowner)
427
422
 
423
+ # Create and add the sub signals if any.
424
+ RCSim.rcsim_add_signal_signals(@rcsignalI,
425
+ self.each_signal.each.map do |sig|
426
+ sig.to_rcsim(@rcsignalI)
427
+ end)
428
+
428
429
  # Set the initial value if any.
429
430
  if self.value then
430
431
  RCSim.rcsim_set_signal_value(@rcsignalI,self.value.to_rcsim)
@@ -480,10 +481,6 @@ module HDLRuby::High
480
481
  RCSim.rcsim_set_owner(@rcsystemI,rcowner)
481
482
 
482
483
  # Add the alternate system types.
483
- # self.each_systemT do |systemT|
484
- # rcsys = systemT.to_rcsim(@rcsystemI)
485
- # RCSim.rcsim_add_systemI_systemT(@rcsystemI,rcsys)
486
- # end
487
484
  if self.each_systemI.any? then
488
485
  RCSim.rcsim_add_systemI_systemTs(@rcsystemI,
489
486
  self.each_systemT.select do|sys|
@@ -547,9 +544,6 @@ module HDLRuby::High
547
544
  @rcstatement = RCSim.rcsim_make_print()
548
545
 
549
546
  # Adds the arguments.
550
- # self.each_arg do |arg|
551
- # RCSim.rcsim_add_print_arg(@rcstatement,arg.to_rcsim)
552
- # end
553
547
  if self.each_arg.any? then
554
548
  RCSim.rcsim_add_print_args(@rcstatement,
555
549
  self.each_arg.map(&:to_rcsim))
@@ -592,9 +586,6 @@ module HDLRuby::High
592
586
  self.no ? self.no.to_rcsim : nil)
593
587
 
594
588
  # Add the alternate ifs if any.
595
- # self.each_noif do |cond,stmnt|
596
- # RCSim.rcsim_add_hif_noif(@rcstatement,cond.to_rcsim,stmnt.to_rcsim)
597
- # end
598
589
  rcsim_conds = self.each_noif.map {|cond,stmnt| cond.to_rcsim }
599
590
  rcsim_stmnts = self.each_noif.map {|cond,stmnt| stmnt.to_rcsim }
600
591
  if rcsim_conds.any? then
@@ -622,10 +613,6 @@ module HDLRuby::High
622
613
  self.default ? self.default.to_rcsim : nil)
623
614
 
624
615
  # Add the hardware whens.
625
- # self.each_when do |wh|
626
- # RCSim.rcsim_add_hcase_when(@rcstatement,
627
- # wh.match.to_rcsim,wh.statement.to_rcsim)
628
- # end
629
616
  rcsim_matches = self.each_when.map {|wh| wh.match.to_rcsim }
630
617
  rcsim_stmnts = self.each_when.map {|wh| wh.statement.to_rcsim }
631
618
  if rcsim_matches.any? then
@@ -695,9 +682,6 @@ module HDLRuby::High
695
682
  end
696
683
 
697
684
  # Add the inner signals.
698
- # self.each_inner do |inner|
699
- # RCSim.rcsim_add_block_inner(@rcstatement,inner.to_rcsim(@rcstatement))
700
- # end
701
685
  if self.each_inner.any? then
702
686
  RCSim.rcsim_add_block_inners(@rcstatement,
703
687
  self.each_inner.map do |sig|
@@ -706,9 +690,6 @@ module HDLRuby::High
706
690
  end
707
691
 
708
692
  # Add the statements.
709
- # self.each_statement do |stmnt|
710
- # RCSim.rcsim_add_block_statement(@rcstatement,stmnt.to_rcsim)
711
- # end
712
693
  if self.each_statement.any? then
713
694
  RCSim.rcsim_add_block_statements(@rcstatement,
714
695
  self.each_statement.map do |stmnt|
@@ -735,6 +716,20 @@ module HDLRuby::High
735
716
  class Connection
736
717
  attr_reader :rcbehavior
737
718
 
719
+ # Add recursively any event to +rcevs+ for activativing the
720
+ # connection from signal +sig+ attached to +rcbehavior+
721
+ def self.add_rcevents(sig,rcevs,rcbehavior)
722
+ # Recurse on sub signals if any.
723
+ sig.each_signal do |sub|
724
+ Connection.add_rcevents(sub,rcevs,rcbehavior)
725
+ end
726
+ # Apply on the current node.
727
+ rcsig = sig.is_a?(SignalI) ? sig.rcsignalI : sig.rcsignalC
728
+ ev = RCSim.rcsim_make_event(:anyedge,rcsig)
729
+ RCSim.rcsim_set_owner(ev,rcbehavior)
730
+ rcevs << ev
731
+ end
732
+
738
733
  # Generate the C description of the connection.
739
734
  # +rcowner+ is a link to the C description of the owner scope.
740
735
  def to_rcsim(rcowner)
@@ -749,9 +744,10 @@ module HDLRuby::High
749
744
  rcevs = []
750
745
  self.right.each_node_deep do |node|
751
746
  if node.is_a?(RefObject) && !node.parent.is_a?(RefObject) then
752
- ev = RCSim.rcsim_make_event(:anyedge,node.to_rcsim)
753
- RCSim.rcsim_set_owner(ev,@rcbehavior)
754
- rcevs << ev
747
+ Connection.add_rcevents(node.object,rcevs,@rcbehavior)
748
+ # ev = RCSim.rcsim_make_event(:anyedge,node.to_rcsim)
749
+ # RCSim.rcsim_set_owner(ev,@rcbehavior)
750
+ # rcevs << ev
755
751
  end
756
752
  end
757
753
  if rcevs.any? then
@@ -892,9 +888,6 @@ module HDLRuby::High
892
888
  self.select.to_rcsim)
893
889
 
894
890
  # Add the choice expressions. */
895
- # self.each_choice do |choice|
896
- # rcsim_add_select_choice(rcexpression,choice.to_rcsim)
897
- # end
898
891
  if self.each_choice.any? then
899
892
  RCSim.rcsim_add_select_choices(rcexpression,
900
893
  self.each_choice.map(&:to_rcsim))
@@ -916,9 +909,6 @@ module HDLRuby::High
916
909
  self.type.direction)
917
910
 
918
911
  # Add the concatenated expressions. */
919
- # self.each_expression do |expr|
920
- # RCSim.rcsim_add_concat_expression(rcexpression,expr.to_rcsim)
921
- # end
922
912
  if self.each_expression.any? then
923
913
  RCSim.rcsim_add_concat_expressions(rcexpression,
924
914
  self.each_expression.map(&:to_rcsim))
@@ -954,9 +944,6 @@ module HDLRuby::High
954
944
  self.type.direction)
955
945
 
956
946
  # Add the concatenated expressions. */
957
- # self.each_ref do |ref|
958
- # RCSim.rcsim_add_refConcat_ref(rcref,ref.to_rcsim)
959
- # end
960
947
  if self.each_ref.any? then
961
948
  RCSim.rcsim_add_refConcat_refs(rcref,self.each_ref.map(&:to_rcsim))
962
949
  end
@@ -1018,14 +1005,36 @@ module HDLRuby::High
1018
1005
  class RefObject
1019
1006
  # attr_reader :rcref
1020
1007
  # alias_method :rcexpression, :rcref
1008
+
1009
+ # Generate the C description of the reference object with sub signals.
1010
+ def to_rcsim_subs
1011
+ # Create the reference concat C object.
1012
+ # The reference is always big endian, it is the sequence
1013
+ # of element which is reversed if necessary.
1014
+ rcref = RCSim.rcsim_make_refConcat(self.type.to_rcsim,:big)
1015
+ # self.type.direction)
1016
+
1017
+ # Add the concatenated expressions. */
1018
+ if self.object.each_signal.any? then
1019
+ iter = self.object.each_signal
1020
+ iter = iter.reverse_each if self.type.direction == :big
1021
+ RCSim.rcsim_add_refConcat_refs(rcref, iter.map do|sig|
1022
+ sig.is_a?(SignalI) ? sig.rcsignalI : sig.rcsignalC
1023
+ end)
1024
+ end
1025
+
1026
+ return rcref
1027
+ end
1021
1028
 
1022
1029
  # Generate the C description of the reference object.
1023
1030
  def to_rcsim
1024
1031
  # puts "object=#{self.object.name}(#{self.object})"
1025
1032
  if self.object.is_a?(SignalI)
1026
- return self.object.rcsignalI
1033
+ return self.object.each_signal.any? ? self.to_rcsim_subs :
1034
+ self.object.rcsignalI
1027
1035
  elsif self.object.is_a?(SignalC)
1028
- return self.object.rcsignalC
1036
+ return self.object.each_signal.any? ? self.to_rcsim_subs :
1037
+ self.object.rcsignalC
1029
1038
  else
1030
1039
  raise "Invalid object: #{self.object}"
1031
1040
  end