HDLRuby 2.11.11 → 3.0.0

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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/README.html +3274 -0
  3. data/README.md +608 -99
  4. data/ext/hruby_sim/hruby_rcsim_build.c +27 -0
  5. data/ext/hruby_sim/hruby_sim.h +3 -0
  6. data/ext/hruby_sim/hruby_sim_calc.c +2 -0
  7. data/ext/hruby_sim/hruby_sim_core.c +17 -5
  8. data/ext/hruby_sim/hruby_sim_stack_calc.c +1 -1
  9. data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
  10. data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
  11. data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
  12. data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
  13. data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
  14. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
  15. data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
  16. data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
  17. data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
  18. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +12 -12
  19. data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
  20. data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
  21. data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
  22. data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
  23. data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
  24. data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
  25. data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
  26. data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
  27. data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
  28. data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
  29. data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
  30. data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
  31. data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
  32. data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
  33. data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
  34. data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
  35. data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
  36. data/lib/HDLRuby/hdr_samples/with_register_stack.rb +150 -0
  37. data/lib/HDLRuby/hdr_samples/with_sequencer.rb +190 -0
  38. data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
  39. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +405 -0
  40. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
  41. data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
  42. data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
  43. data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
  44. data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
  45. data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
  46. data/lib/HDLRuby/hdrcc.rb +29 -3
  47. data/lib/HDLRuby/hdrlib.rb +1 -1
  48. data/lib/HDLRuby/hruby_bstr.rb +10 -5
  49. data/lib/HDLRuby/hruby_db.rb +2 -2
  50. data/lib/HDLRuby/hruby_high.rb +152 -47
  51. data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
  52. data/lib/HDLRuby/hruby_low.rb +189 -18
  53. data/lib/HDLRuby/hruby_low2c.rb +129 -54
  54. data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
  55. data/lib/HDLRuby/hruby_low2high.rb +86 -44
  56. data/lib/HDLRuby/hruby_low2seq.rb +26 -18
  57. data/lib/HDLRuby/hruby_low2sym.rb +14 -13
  58. data/lib/HDLRuby/hruby_low2vhd.rb +80 -44
  59. data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
  60. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
  61. data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
  62. data/lib/HDLRuby/hruby_low_fix_types.rb +65 -32
  63. data/lib/HDLRuby/hruby_low_mutable.rb +83 -119
  64. data/lib/HDLRuby/hruby_low_resolve.rb +38 -30
  65. data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
  66. data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
  67. data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
  68. data/lib/HDLRuby/hruby_low_without_concat.rb +45 -19
  69. data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
  70. data/lib/HDLRuby/hruby_low_without_parinseq.rb +32 -16
  71. data/lib/HDLRuby/hruby_low_without_select.rb +37 -24
  72. data/lib/HDLRuby/hruby_low_without_subsignals.rb +280 -0
  73. data/lib/HDLRuby/hruby_rcsim.rb +158 -134
  74. data/lib/HDLRuby/hruby_rsim.rb +194 -20
  75. data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
  76. data/lib/HDLRuby/hruby_rsim_vcd.rb +125 -50
  77. data/lib/HDLRuby/hruby_values.rb +48 -33
  78. data/lib/HDLRuby/hruby_verilog.rb +90 -48
  79. data/lib/HDLRuby/soft/stacks.rb +219 -0
  80. data/lib/HDLRuby/std/bram.rb +26 -0
  81. data/lib/HDLRuby/std/clocks.rb +1 -1
  82. data/lib/HDLRuby/std/fixpoint.rb +2 -2
  83. data/lib/HDLRuby/std/fsm.rb +48 -11
  84. data/lib/HDLRuby/std/function_generator.rb +2 -2
  85. data/lib/HDLRuby/std/sequencer.rb +1857 -0
  86. data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
  87. data/lib/HDLRuby/std/std.rb +12 -0
  88. data/lib/HDLRuby/version.rb +1 -1
  89. data/tuto/adder_sat_flags_vcd.png +0 -0
  90. data/tuto/addsub_vcd.png +0 -0
  91. data/tuto/alu_vcd.png +0 -0
  92. data/tuto/bit_pong_vcd.png +0 -0
  93. data/tuto/checksum_vcd.png +0 -0
  94. data/tuto/circuit_hdr.odg +0 -0
  95. data/tuto/circuit_hdr.png +0 -0
  96. data/tuto/circuit_hie.odg +0 -0
  97. data/tuto/circuit_hie.png +0 -0
  98. data/tuto/circuit_view.odg +0 -0
  99. data/tuto/circuit_view.png +0 -0
  100. data/tuto/clock_counter_vcd.png +0 -0
  101. data/tuto/counter_ext_vcd.png +0 -0
  102. data/tuto/fact_vcd.png +0 -0
  103. data/tuto/hw_flow.odg +0 -0
  104. data/tuto/hw_flow.png +0 -0
  105. data/tuto/maxxer_vcd.png +0 -0
  106. data/tuto/pingpong0_vcd.png +0 -0
  107. data/tuto/pingpong1_vcd.png +0 -0
  108. data/tuto/pingpong2_vcd.png +0 -0
  109. data/tuto/ram_vcd.png +0 -0
  110. data/tuto/serializer_vcd.png +0 -0
  111. data/tuto/sw_flow.odg +0 -0
  112. data/tuto/sw_flow.png +0 -0
  113. data/tuto/the_counter_vcd.png +0 -0
  114. data/tuto/tutorial_sw.html +2359 -0
  115. data/tuto/tutorial_sw.md +2684 -0
  116. data/tuto/tutorial_sw.pdf +0 -0
  117. data/tuto/tutorial_sw_jp.md +417 -0
  118. metadata +49 -3
  119. data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
@@ -13,9 +13,9 @@ module HDLRuby::Low
13
13
  ########################################################################
14
14
 
15
15
 
16
- ## Extends the SystemT class with functionality for converting par blocks
17
- # within seq blocks to seq blocks.
18
16
  class SystemT
17
+ ## Extends the SystemT class with functionality for converting par blocks
18
+ # within seq blocks to seq blocks.
19
19
 
20
20
  # Converts par blocks within seq blocks to seq blocks.
21
21
  def par_in_seq2seq!
@@ -23,9 +23,11 @@ module HDLRuby::Low
23
23
  end
24
24
  end
25
25
 
26
- ## Extends the Scope class with functionality for breaking assingments
27
- # to concats.
26
+
28
27
  class Scope
28
+ ## Extends the Scope class with functionality for converting par blocks
29
+ # within seq blocks to seq blocks.
30
+
29
31
  # Converts par blocks within seq blocks to seq blocks.
30
32
  def par_in_seq2seq!
31
33
  # Recruse on the sub scopes.
@@ -38,9 +40,10 @@ module HDLRuby::Low
38
40
  end
39
41
 
40
42
 
41
- ## Extends the Statement class with functionality for breaking assingments
42
- # to concats.
43
43
  class Statement
44
+ ## Extends the Statement class with functionality for converting par
45
+ # blocks within seq blocks to seq blocks.
46
+
44
47
  # Converts par blocks within seq blocks to seq blocks.
45
48
  def par_in_seq2seq!
46
49
  # By default nothing to do.
@@ -55,9 +58,10 @@ module HDLRuby::Low
55
58
  end
56
59
 
57
60
 
58
- ## Extends the If class with functionality for breaking assingments
59
- # to concats.
60
61
  class If
62
+ ## Extends the If class with functionality for converting par blocks
63
+ # within seq blocks to seq blocks.
64
+
61
65
  # Converts par blocks within seq blocks to seq blocks.
62
66
  def par_in_seq2seq!
63
67
  self.yes.par_in_seq2seq!
@@ -78,9 +82,10 @@ module HDLRuby::Low
78
82
  end
79
83
 
80
84
 
81
- ## Extends the Case class with functionality for breaking assingments
82
- # to concats.
83
85
  class Case
86
+ ## Extends the Case class with functionality for converting par blocks
87
+ # within seq blocks to seq blocks.
88
+
84
89
  # Converts par blocks within seq blocks to seq blocks.
85
90
  def par_in_seq2seq!
86
91
  self.each_when do |w|
@@ -99,9 +104,10 @@ module HDLRuby::Low
99
104
  end
100
105
 
101
106
 
102
- ## Extends the Block class with functionality for breaking assingments
103
- # to concats.
104
107
  class Block
108
+ ## Extends the Block class with functionality for converting par blocks
109
+ # within seq blocks to seq blocks.
110
+
105
111
  # Converts par blocks within seq blocks to seq blocks.
106
112
  def par_in_seq2seq!
107
113
  # Recurse on the sub blocks.
@@ -122,6 +128,9 @@ module HDLRuby::Low
122
128
  def to_seq!
123
129
  if self.mode == :par then
124
130
  # Need to convert.
131
+ # Get which module is it.
132
+ modul = self.is_a?(HDLRuby::High::Block) ? HDLRuby::High :
133
+ HDLRuby::Low
125
134
  # First recurse on the sub blocks.
126
135
  self.each_statement(&:to_seq!)
127
136
  # Now replace each left value by a new signal for
@@ -130,16 +139,23 @@ module HDLRuby::Low
130
139
  self.each_statement do |statement|
131
140
  left = statement.left
132
141
  if statement.is_a?(Transmit) then
133
- sig = SignalI.new(HDLRuby.uniq_name,left.type)
134
- self.add_inner(sig)
135
- diff = RefName.new(left.type,RefThis.new,sig.name)
142
+ if modul == HDLRuby::High then
143
+ sig = modul::SignalI.new(HDLRuby.uniq_name,left.type,:inner)
144
+ self.add_inner(sig)
145
+ puts "sig.parent=#{sig.parent}"
146
+ diff = modul::RefObject.new(modul::RefThis.new,sig)
147
+ else
148
+ sig = modul::SignalI.new(HDLRuby.uniq_name,left.type)
149
+ self.add_inner(sig)
150
+ diff = modul::RefName.new(left.type,modul::RefThis.new,sig.name)
151
+ end
136
152
  differeds << [left,diff]
137
153
  statement.set_left!(diff)
138
154
  end
139
155
  end
140
156
  # Adds the differed assignments.
141
157
  differeds.each do |left,diff|
142
- self.add_statement(Transmit.new(left.clone,diff.clone))
158
+ self.add_statement(modul::Transmit.new(left.clone,diff.clone))
143
159
  end
144
160
  # Change the mode.
145
161
  self.set_mode!(:seq)
@@ -52,9 +52,9 @@ module HDLRuby::Low
52
52
  end
53
53
 
54
54
 
55
- ## Extends the SystemT class with functionality for converting select
56
- # expressions to case statements.
57
55
  class SystemT
56
+ ## Extends the SystemT class with functionality for converting select
57
+ # expressions to case statements.
58
58
 
59
59
  # Converts the Select expressions to Case statements.
60
60
  def select2case!
@@ -63,9 +63,10 @@ module HDLRuby::Low
63
63
 
64
64
  end
65
65
 
66
+
67
+ class Scope
66
68
  ## Extends the Scope class with functionality for converting select
67
69
  # expressions to case statements.
68
- class Scope
69
70
 
70
71
  # Converts the Select expressions to Case statements.
71
72
  def select2case!
@@ -82,7 +83,7 @@ module HDLRuby::Low
82
83
  selects = connection.extract_selects!
83
84
  if selects.any? then
84
85
  # Selects have been extract, replace the connection
85
- # be y behavior.
86
+ # by a behavior.
86
87
  # Generate the block with cases.
87
88
  blk = LowWithoutSelect.selects2block(selects)
88
89
  # Add a transmit replacing the connection.
@@ -98,9 +99,10 @@ module HDLRuby::Low
98
99
  end
99
100
 
100
101
 
101
- ## Extends the TimeWait class with functionality for converting booleans
102
- # in assignments to select operators.
103
102
  class TimeWait
103
+ ## Extends the TimeWait class with functionality for converting booleans
104
+ # in assignments to select operators.
105
+
104
106
  # Extract the Select expressions.
105
107
  def extract_selects!
106
108
  # Nothing to extract.
@@ -109,9 +111,10 @@ module HDLRuby::Low
109
111
  end
110
112
 
111
113
 
112
- ## Extends the TimeRepeat class with functionality for converting booleans
113
- # in assignments to select operators.
114
114
  class TimeRepeat
115
+ ## Extends the TimeRepeat class with functionality for converting
116
+ # booleans in assignments to select operators.
117
+
115
118
  # Extract the Select expressions.
116
119
  def extract_selects!
117
120
  # Simply recruse on the statement.
@@ -124,9 +127,9 @@ module HDLRuby::Low
124
127
  end
125
128
 
126
129
 
127
- ## Extends the Block class with functionality for converting select
128
- # expressions to case statements.
129
130
  class Block
131
+ ## Extends the Block class with functionality for converting select
132
+ # expressions to case statements.
130
133
 
131
134
  # Breaks the assignments to concats.
132
135
  #
@@ -151,9 +154,11 @@ module HDLRuby::Low
151
154
  end
152
155
  end
153
156
 
154
- ## Extends the Transmit class with functionality for converting select
155
- # expressions to case statements.
157
+
156
158
  class Transmit
159
+ ## Extends the Transmit class with functionality for converting select
160
+ # expressions to case statements.
161
+
157
162
  # Extract the Select expressions.
158
163
  def extract_selects!
159
164
  selects = []
@@ -163,9 +168,11 @@ module HDLRuby::Low
163
168
  end
164
169
  end
165
170
 
166
- ## Extends the Print class with functionality for converting select
167
- # expressions to case statements.
171
+
168
172
  class Print
173
+ ## Extends the Print class with functionality for converting select
174
+ # expressions to case statements.
175
+
169
176
  # Extract the Select expressions.
170
177
  def extract_selects!
171
178
  selects = []
@@ -176,19 +183,22 @@ module HDLRuby::Low
176
183
  end
177
184
  end
178
185
 
179
- ## Extends the TimeTerminate class with functionality for converting select
180
- # expressions to case statements.
186
+
181
187
  class TimeTerminate
188
+ ## Extends the TimeTerminate class with functionality for converting
189
+ # select expressions to case statements.
190
+
182
191
  # Extract the Select expressions.
183
192
  def extract_selects!
184
193
  # Nothing to extract.
185
194
  return []
186
195
  end
187
196
  end
197
+
188
198
 
189
- ## Extends the If class with functionality for converting select
190
- # expressions to case statements.
191
199
  class If
200
+ ## Extends the If class with functionality for converting select
201
+ # expressions to case statements.
192
202
 
193
203
  # Extract the Select expressions.
194
204
  #
@@ -200,9 +210,10 @@ module HDLRuby::Low
200
210
  end
201
211
  end
202
212
 
203
- ## Extends the If class with functionality for converting select
204
- # expressions to case statements.
213
+
205
214
  class When
215
+ ## Extends the If class with functionality for converting select
216
+ # expressions to case statements.
206
217
 
207
218
  # Extract the Select expressions.
208
219
  #
@@ -214,9 +225,10 @@ module HDLRuby::Low
214
225
  end
215
226
  end
216
227
 
217
- ## Extends the If class with functionality for converting select
218
- # expressions to case statements.
228
+
219
229
  class Case
230
+ ## Extends the Case class with functionality for converting select
231
+ # expressions to case statements.
220
232
 
221
233
  # Extract the Select expressions.
222
234
  #
@@ -231,9 +243,10 @@ module HDLRuby::Low
231
243
  end
232
244
  end
233
245
 
234
- ## Extends the Expression class with functionality for converting select
235
- # expressions to ase statements.
246
+
236
247
  class Expression
248
+ ## Extends the Expression class with functionality for converting select
249
+ # expressions to ase statements.
237
250
 
238
251
  # Extract the Select expressions and put them into +selects+
239
252
  def extract_selects_to!(selects)
@@ -0,0 +1,280 @@
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
+
17
+ class SystemT
18
+ ## Extends the SystemT class with functionality for decomposing the
19
+ # hierachical signals in the statements.
20
+
21
+ # Decompose the hierarchical signals in the statements.
22
+ def signal2subs!
23
+ self.scope.signal2subs!
24
+ end
25
+ end
26
+
27
+
28
+ class Scope
29
+ ## Extends the Scope class with functionality for decomposing the
30
+ # hierachical signals in the statements.
31
+
32
+ # Decompose the hierarchical signals in the statements.
33
+ def signal2subs!
34
+ # Recruse on the sub scopes.
35
+ self.each_scope(&:signal2subs!)
36
+
37
+ # Recurse on the blocks.
38
+ self.each_behavior do |behavior|
39
+ # behavior.block.each_block_deep(&:signal2subs!)
40
+ behavior.signal2subs!
41
+ end
42
+
43
+ # Work on the connections.
44
+ self.each_connection.to_a.each do |connection|
45
+ # Recurse on the left and right.
46
+ connection.set_left!(connection.left.signal2subs!)
47
+ connection.set_right!(connection.right.signal2subs!)
48
+ end
49
+ end
50
+ end
51
+
52
+
53
+ class Behavior
54
+ ## Extends the Behavior class with functionality for decomposing the
55
+ # hierachical signals in the statements.
56
+
57
+ # Decompose the hierarchical signals in the statements.
58
+ def signal2subs!
59
+ # Process the events.
60
+ self.each_event.to_a.each do |ev|
61
+ subrefs = ev.ref.flatten
62
+ if subrefs.any? then
63
+ # The refence have been flattend, remove the event.
64
+ self.delete_event!(ev)
65
+ # And add instead new events for the sub references.
66
+ subrefs.each do |subref|
67
+ nev = Event.new(ev.type,subref)
68
+ self.add_event(nev)
69
+ end
70
+ end
71
+ end
72
+ # Recurse on the blocks.
73
+ self.block.each_block_deep(&:signal2subs!)
74
+ end
75
+ end
76
+
77
+
78
+ class Block
79
+ ## Extends the Block class with functionality for decomposing the
80
+ # hierachical signals in the statements.
81
+
82
+ # Decompose the hierarchical signals in the statements.
83
+ def signal2subs!
84
+ # Recurse on the statments.
85
+ self.map_statements! do |stmnt|
86
+ stmnt.signal2subs!
87
+ end
88
+ return self
89
+ end
90
+ end
91
+
92
+
93
+ class TimeWait
94
+ ## Extends the TimeWait class with functionality for decomposing the
95
+ # hierachical signals in the statements.
96
+
97
+ # Decompose the hierarchical signals in the statements.
98
+ def signal2subs!
99
+ # Nothing to do.
100
+ return self
101
+ end
102
+ end
103
+
104
+
105
+ class TimeRepeat
106
+ ## Extends the TimeRepeat class with functionality for decomposing the
107
+ # hierachical signals in the statements.
108
+
109
+ # Decompose the hierarchical signals in the statements.
110
+ def signal2subs!
111
+ # Recurse on the statement.
112
+ self.set_statement!(self.statement.signal2subs!)
113
+ return self
114
+ end
115
+ end
116
+
117
+
118
+ class Transmit
119
+ ## Extends the Transmit class with functionality for decomposing the
120
+ # hierachical signals in the statements.
121
+
122
+ # Decompose the hierarchical signals in the statements.
123
+ def signal2subs!
124
+ # Recurse on the left and right.
125
+ self.set_left!(self.left.signal2subs!)
126
+ self.set_right!(self.right.signal2subs!)
127
+ return self
128
+ end
129
+ end
130
+
131
+
132
+ class Print
133
+ ## Extends the Print class with functionality for decomposing the
134
+ # hierachical signals in the statements.
135
+
136
+ # Decompose the hierarchical signals in the statements.
137
+ def signal2subs!
138
+ # Recurse on the arguments.
139
+ self.map_args! { |arg| arg.signal2subs! }
140
+ return self
141
+ end
142
+ end
143
+
144
+
145
+ class TimeTerminate
146
+ ## Extends the Print class with functionality for decomposing the
147
+ # hierachical signals in the statements.
148
+
149
+ # Decompose the hierarchical signals in the statements.
150
+ def signal2subs!
151
+ # Nothing to do.
152
+ return self
153
+ end
154
+ end
155
+
156
+
157
+ class If
158
+ ## Extends the If class with functionality for decomposing the
159
+ # hierachical signals in the statements.
160
+
161
+ # Decompose the hierarchical signals in the statements.
162
+ def signal2subs!
163
+ # Recurse on the condition.
164
+ self.set_condition!(self.condition.signal2subs!)
165
+ # Recurse on the yes block.
166
+ self.yes.signal2subs!
167
+ # Recurse on the no block if any.
168
+ self.no.signal2subs! if self.no
169
+ # Recurse on the alternate ifs.
170
+ self.map_noifs! do |cond,stmnt|
171
+ [cond.signal2subs!,stmnt.signal2subs!]
172
+ end
173
+ return self
174
+ end
175
+ end
176
+
177
+
178
+ class When
179
+ ## Extends the When class with functionality for decomposing the
180
+ # hierachical signals in the statements.
181
+
182
+ # Decompose the hierarchical signals in the statements.
183
+ def signal2subs!
184
+ # Recurse on the match.
185
+ self.set_match!(self.match.signal2subs!)
186
+ # Recurse on the statement.
187
+ self.set_statement!(self.statement.signal2subs!)
188
+ return self
189
+ end
190
+
191
+ end
192
+
193
+
194
+ class Case
195
+ ## Extends the Case class with functionality for decomposing the
196
+ # hierachical signals in the statements.
197
+
198
+ # Decompose the hierarchical signals in the statements.
199
+ def signal2subs!
200
+ # Recurse on the case value.
201
+ self.set_value!(self.value.signal2subs!)
202
+ # Recurse on the whens.
203
+ self.each_when(&:signal2subs!)
204
+ # Recurse on the default.
205
+ self.set_default!(self.default.signal2subs!) if self.default
206
+ return self
207
+ end
208
+ end
209
+
210
+
211
+ class Expression
212
+ ## Extends the Expression class with functionality for decomposing the
213
+ # hierachical signals in the statements.
214
+
215
+ # Decompose the hierarchical signals in the statements.
216
+ def signal2subs!
217
+ # puts "signal2subs! for expr=#{self}"
218
+ # Recurse on the subexpressions.
219
+ self.map_expressions!(&:signal2subs!)
220
+ return self
221
+ end
222
+ end
223
+
224
+
225
+ class RefName
226
+ ## Extends the RefName class with functionality for decomposing the
227
+ # hierachical signals in the statements.
228
+
229
+ # Flatten a reference to a list of reference to leaf signals
230
+ # from signal +sig+ and add to result to +subrefs+
231
+ def flatten_to(sig,subrefs)
232
+ # puts "flatten_to with sig name=#{sig.name}"
233
+ # Work on the sub signals if any.
234
+ sig.each_signal do |sub|
235
+ # Create a reference for the sub.
236
+ subref = RefName.new(sub.type,self.clone,sub.name)
237
+ # Recruse on it.
238
+ subref.flatten_to(sub,subrefs)
239
+ # Was it a leaf?
240
+ unless sub.each_signal.any? then
241
+ # Yes, add its new ref to the list of subs.
242
+ subrefs << subref
243
+ end
244
+ end
245
+ end
246
+
247
+ # Flatten the current ref to a list of references.
248
+ # If the reference is not heirachical, returns an empty list.
249
+ def flatten
250
+ subrefs = []
251
+ self.flatten_to(self.resolve,subrefs)
252
+ return subrefs
253
+ end
254
+
255
+ # Decompose the hierarchical signals in the statements.
256
+ def signal2subs!
257
+ # puts "signal2subs! for RefName: #{self.name}"
258
+ # Decompose it to a list of reference to each leaf sub signal.
259
+ subrefs = []
260
+ self.flatten_to(self.resolve,subrefs)
261
+ # puts "subrefs=#{subrefs.map{|subref| subref.name}}"
262
+ # Has it sub signals?
263
+ if (subrefs.any?) then
264
+ # Yes, convert it to a Concat.
265
+ if self.leftvalue? then
266
+ return RefConcat.new(self.type,subrefs)
267
+ else
268
+ return Concat.new(self.type,subrefs)
269
+ end
270
+ else
271
+ # Nothing to do.
272
+ return self
273
+ end
274
+ end
275
+ end
276
+
277
+
278
+
279
+
280
+ end