HDLRuby 2.11.12 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.html +3274 -0
  3. data/README.md +660 -128
  4. data/ext/hruby_sim/hruby_sim_calc.c +2 -0
  5. data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
  6. data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
  7. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +2 -1
  8. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
  9. data/lib/HDLRuby/hdr_samples/with_bram.rb +3 -3
  10. data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
  11. data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
  12. data/lib/HDLRuby/hdr_samples/with_ref_expr.rb +30 -0
  13. data/lib/HDLRuby/hdr_samples/with_sequencer.rb +185 -0
  14. data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
  15. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +439 -0
  16. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
  17. data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +63 -0
  18. data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
  19. data/lib/HDLRuby/hdrcc.rb +16 -3
  20. data/lib/HDLRuby/hdrlib.rb +1 -1
  21. data/lib/HDLRuby/hruby_db.rb +2 -2
  22. data/lib/HDLRuby/hruby_high.rb +61 -25
  23. data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
  24. data/lib/HDLRuby/hruby_low.rb +2 -2
  25. data/lib/HDLRuby/hruby_low2c.rb +58 -43
  26. data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
  27. data/lib/HDLRuby/hruby_low2high.rb +86 -44
  28. data/lib/HDLRuby/hruby_low2seq.rb +26 -18
  29. data/lib/HDLRuby/hruby_low2sym.rb +14 -13
  30. data/lib/HDLRuby/hruby_low2vhd.rb +78 -43
  31. data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
  32. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
  33. data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
  34. data/lib/HDLRuby/hruby_low_fix_types.rb +64 -32
  35. data/lib/HDLRuby/hruby_low_mutable.rb +53 -118
  36. data/lib/HDLRuby/hruby_low_resolve.rb +26 -31
  37. data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
  38. data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
  39. data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
  40. data/lib/HDLRuby/hruby_low_without_concat.rb +19 -13
  41. data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
  42. data/lib/HDLRuby/hruby_low_without_parinseq.rb +18 -12
  43. data/lib/HDLRuby/hruby_low_without_select.rb +36 -23
  44. data/lib/HDLRuby/hruby_low_without_subsignals.rb +79 -39
  45. data/lib/HDLRuby/hruby_rcsim.rb +79 -64
  46. data/lib/HDLRuby/hruby_rsim.rb +64 -15
  47. data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
  48. data/lib/HDLRuby/hruby_rsim_vcd.rb +28 -25
  49. data/lib/HDLRuby/hruby_types.rb +5 -5
  50. data/lib/HDLRuby/hruby_values.rb +19 -8
  51. data/lib/HDLRuby/hruby_verilog.rb +191 -65
  52. data/lib/HDLRuby/hruby_verilog_name.rb +49 -42
  53. data/lib/HDLRuby/soft/stacks.rb +219 -0
  54. data/lib/HDLRuby/std/bram.rb +9 -5
  55. data/lib/HDLRuby/std/clocks.rb +1 -1
  56. data/lib/HDLRuby/std/fsm.rb +39 -10
  57. data/lib/HDLRuby/std/sequencer.rb +2085 -0
  58. data/lib/HDLRuby/std/sequencer_func.rb +533 -0
  59. data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
  60. data/lib/HDLRuby/std/std.rb +13 -0
  61. data/lib/HDLRuby/version.rb +1 -1
  62. data/tuto/adder_sat_flags_vcd.png +0 -0
  63. data/tuto/addsub_vcd.png +0 -0
  64. data/tuto/alu_vcd.png +0 -0
  65. data/tuto/bit_pong_vcd.png +0 -0
  66. data/tuto/checksum_vcd.png +0 -0
  67. data/tuto/circuit_hdr.odg +0 -0
  68. data/tuto/circuit_hdr.png +0 -0
  69. data/tuto/circuit_hie.odg +0 -0
  70. data/tuto/circuit_hie.png +0 -0
  71. data/tuto/circuit_view.odg +0 -0
  72. data/tuto/circuit_view.png +0 -0
  73. data/tuto/clock_counter_vcd.png +0 -0
  74. data/tuto/counter_ext_vcd.png +0 -0
  75. data/tuto/fact_vcd.png +0 -0
  76. data/tuto/hw_flow.odg +0 -0
  77. data/tuto/hw_flow.png +0 -0
  78. data/tuto/maxxer_vcd.png +0 -0
  79. data/tuto/pingpong0_vcd.png +0 -0
  80. data/tuto/pingpong1_vcd.png +0 -0
  81. data/tuto/pingpong2_vcd.png +0 -0
  82. data/tuto/ram_vcd.png +0 -0
  83. data/tuto/serializer_vcd.png +0 -0
  84. data/tuto/sw_flow.odg +0 -0
  85. data/tuto/sw_flow.png +0 -0
  86. data/tuto/the_counter_vcd.png +0 -0
  87. data/tuto/tutorial_sw.html +2359 -0
  88. data/tuto/tutorial_sw.md +2890 -0
  89. data/tuto/tutorial_sw.pdf +0 -0
  90. data/tuto/tutorial_sw_jp.md +417 -0
  91. metadata +46 -2
@@ -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!
@@ -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 Case 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)
@@ -12,21 +12,36 @@ module HDLRuby::Low
12
12
  # Makes handling by some synthesis tools easier.
13
13
  #
14
14
  ########################################################################
15
+
15
16
 
16
- ## Extends the SystemT class with functionality for decomposing the
17
- # hierachical signals in the statements.
18
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
19
25
 
20
26
  # Decompose the hierarchical signals in the statements.
21
- def signal2subs!
27
+ # If +decompose_vec2d+ is true then also decompose 2 dimension vectors
28
+ # (e.g., for Verilog HDL that does not support handling such signals
29
+ # as usual expressions).
30
+ def signal2subs!(decompose_vec2d = false)
31
+ @@decompose_vec2d = decompose_vec2d == true
22
32
  self.scope.signal2subs!
23
33
  end
34
+
35
+ ## Tell if 2d vector signals must be decomposed too.
36
+ def self.decompose_vec2d?
37
+ @@decompose_vec2d
38
+ end
24
39
  end
25
40
 
26
41
 
27
- ## Extends the Scope class with functionality for decomposing the
28
- # hierachical signals in the statements.
29
42
  class Scope
43
+ ## Extends the Scope class with functionality for decomposing the
44
+ # hierachical signals in the statements.
30
45
 
31
46
  # Decompose the hierarchical signals in the statements.
32
47
  def signal2subs!
@@ -49,9 +64,9 @@ module HDLRuby::Low
49
64
  end
50
65
 
51
66
 
52
- ## Extends the Behavior class with functionality for decomposing the
53
- # hierachical signals in the statements.
54
67
  class Behavior
68
+ ## Extends the Behavior class with functionality for decomposing the
69
+ # hierachical signals in the statements.
55
70
 
56
71
  # Decompose the hierarchical signals in the statements.
57
72
  def signal2subs!
@@ -74,9 +89,9 @@ module HDLRuby::Low
74
89
  end
75
90
 
76
91
 
77
- ## Extends the Block class with functionality for decomposing the
78
- # hierachical signals in the statements.
79
92
  class Block
93
+ ## Extends the Block class with functionality for decomposing the
94
+ # hierachical signals in the statements.
80
95
 
81
96
  # Decompose the hierarchical signals in the statements.
82
97
  def signal2subs!
@@ -89,9 +104,9 @@ module HDLRuby::Low
89
104
  end
90
105
 
91
106
 
92
- ## Extends the TimeWait class with functionality for decomposing the
93
- # hierachical signals in the statements.
94
107
  class TimeWait
108
+ ## Extends the TimeWait class with functionality for decomposing the
109
+ # hierachical signals in the statements.
95
110
 
96
111
  # Decompose the hierarchical signals in the statements.
97
112
  def signal2subs!
@@ -101,9 +116,9 @@ module HDLRuby::Low
101
116
  end
102
117
 
103
118
 
104
- ## Extends the TimeRepeat class with functionality for decomposing the
105
- # hierachical signals in the statements.
106
119
  class TimeRepeat
120
+ ## Extends the TimeRepeat class with functionality for decomposing the
121
+ # hierachical signals in the statements.
107
122
 
108
123
  # Decompose the hierarchical signals in the statements.
109
124
  def signal2subs!
@@ -114,9 +129,9 @@ module HDLRuby::Low
114
129
  end
115
130
 
116
131
 
117
- ## Extends the Transmit class with functionality for decomposing the
118
- # hierachical signals in the statements.
119
132
  class Transmit
133
+ ## Extends the Transmit class with functionality for decomposing the
134
+ # hierachical signals in the statements.
120
135
 
121
136
  # Decompose the hierarchical signals in the statements.
122
137
  def signal2subs!
@@ -128,9 +143,9 @@ module HDLRuby::Low
128
143
  end
129
144
 
130
145
 
131
- ## Extends the Print class with functionality for decomposing the
132
- # hierachical signals in the statements.
133
146
  class Print
147
+ ## Extends the Print class with functionality for decomposing the
148
+ # hierachical signals in the statements.
134
149
 
135
150
  # Decompose the hierarchical signals in the statements.
136
151
  def signal2subs!
@@ -141,9 +156,9 @@ module HDLRuby::Low
141
156
  end
142
157
 
143
158
 
144
- ## Extends the Print class with functionality for decomposing the
145
- # hierachical signals in the statements.
146
159
  class TimeTerminate
160
+ ## Extends the Print class with functionality for decomposing the
161
+ # hierachical signals in the statements.
147
162
 
148
163
  # Decompose the hierarchical signals in the statements.
149
164
  def signal2subs!
@@ -153,9 +168,9 @@ module HDLRuby::Low
153
168
  end
154
169
 
155
170
 
156
- ## Extends the If class with functionality for decomposing the
157
- # hierachical signals in the statements.
158
171
  class If
172
+ ## Extends the If class with functionality for decomposing the
173
+ # hierachical signals in the statements.
159
174
 
160
175
  # Decompose the hierarchical signals in the statements.
161
176
  def signal2subs!
@@ -174,9 +189,9 @@ module HDLRuby::Low
174
189
  end
175
190
 
176
191
 
177
- ## Extends the When class with functionality for decomposing the
178
- # hierachical signals in the statements.
179
192
  class When
193
+ ## Extends the When class with functionality for decomposing the
194
+ # hierachical signals in the statements.
180
195
 
181
196
  # Decompose the hierarchical signals in the statements.
182
197
  def signal2subs!
@@ -190,9 +205,9 @@ module HDLRuby::Low
190
205
  end
191
206
 
192
207
 
193
- ## Extends the Case class with functionality for decomposing the
194
- # hierachical signals in the statements.
195
208
  class Case
209
+ ## Extends the Case class with functionality for decomposing the
210
+ # hierachical signals in the statements.
196
211
 
197
212
  # Decompose the hierarchical signals in the statements.
198
213
  def signal2subs!
@@ -207,9 +222,9 @@ module HDLRuby::Low
207
222
  end
208
223
 
209
224
 
210
- ## Extends the Expression class with functionality for decomposing the
211
- # hierachical signals in the statements.
212
225
  class Expression
226
+ ## Extends the Expression class with functionality for decomposing the
227
+ # hierachical signals in the statements.
213
228
 
214
229
  # Decompose the hierarchical signals in the statements.
215
230
  def signal2subs!
@@ -221,24 +236,49 @@ module HDLRuby::Low
221
236
  end
222
237
 
223
238
 
224
- ## Extends the RefName class with functionality for decomposing the
225
- # hierachical signals in the statements.
226
239
  class RefName
240
+ ## Extends the RefName class with functionality for decomposing the
241
+ # hierachical signals in the statements.
227
242
 
228
243
  # Flatten a reference to a list of reference to leaf signals
229
244
  # from signal +sig+ and add to result to +subrefs+
230
245
  def flatten_to(sig,subrefs)
231
246
  # 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
247
+ # Shall we decompose 2d vectors, and is the current signal
248
+ # for one of them?
249
+ if SystemT.decompose_vec2d? and sig.type.is_a?(TypeVector) and
250
+ sig.type.base.is_a?(TypeVector) then
251
+ # Is the reference used other than for a memory access?
252
+ unless self.parent.is_a?(RefIndex) then
253
+ # Yes, do the decomposition.
254
+ # Selects the direction.
255
+ rng = sig.type.range
256
+ if rng.first > rng.last then
257
+ itr = (rng.last..rng.first).each
258
+ else
259
+ itr = rng.reverse_each
260
+ end
261
+ # Iterate on each element.
262
+ itr.each do |i|
263
+ # Create a reference fo the sub.
264
+ subref = RefIndex.new(sig.type.base,self.clone,
265
+ Value.new(TypeUnsigned.new(:""),i))
266
+ # Add it.
267
+ subrefs << subref
268
+ end
269
+ end
270
+ else
271
+ # Work on the sub signals if any.
272
+ sig.each_signal do |sub|
273
+ # Create a reference for the sub.
274
+ subref = RefName.new(sub.type,self.clone,sub.name)
275
+ # Recurse on it.
276
+ subref.flatten_to(sub,subrefs)
277
+ # Was it a leaf?
278
+ unless sub.each_signal.any? then
279
+ # Yes, add its new ref to the list of subs.
280
+ subrefs << subref
281
+ end
242
282
  end
243
283
  end
244
284
  end