HDLRuby 2.4.21 → 2.4.28

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28c1956d124429de349aede3dce3644cca530400479dedb09bedc3326a1fdb76
4
- data.tar.gz: cd76438901da8bff407b7db4abef07399192c19f0349af0c9e0e545a1a22cf1d
3
+ metadata.gz: ad6c03f726ed838a4d5456f41c4b0f295e4ca7d10ca8585ee8f8c011f7f2fd23
4
+ data.tar.gz: a59727e177be4d5ff3eb740d210fad37bd4ba9ea6296a8cfed84495a7122411d
5
5
  SHA512:
6
- metadata.gz: 89ccd495fa050a3f552ea73e52f726a08f56f5a937691209622a4d008a62905134d3a4765265ee07ff4c8aca59bc097221d4f75fc9da445ba3115fe6aee293ea
7
- data.tar.gz: 47150e816409de410e41f8aa5a22e7bcc514ac88d2798d0282cb1efa5f660ec0e20d35015f807c43e7823ef4ae406125aba45bcd28b2acaf740991528549c413
6
+ metadata.gz: dc19bcb5b44267c6506a9a1b3547d516b565a2a3ea997bf2ab5cada119caafb0fee09220c7da2e92321562ed2588dc5b6c58c6c697d3230daa8942c00fb731f6
7
+ data.tar.gz: c6849492302732600fe232d73f6984c4fe1a94e4d818349d5400fb15979eecc6b2b32d71a81b50f09713c5143236e13f330f763ea98beeda4a939d77b8d2fba9
@@ -1,12 +1,14 @@
1
1
 
2
+ signed[7..0].typedef(:typ)
3
+
2
4
  # Describes an 8-bit data 4-bit address ROM.
3
5
  system :rom4_8 do
4
6
  [2..0].input :addr
5
7
  [7..0].output :data0,:data1,:data2
6
8
 
7
9
  bit[7..0][0..7].constant content0: [0,1,2,3,4,5,6,7]
8
- bit[7..0][-8].constant content1: [0,1,2,3,4,5,6,7]
9
- bit[7..0][-8].constant content2: (8).times.to_a
10
+ signed[7..0][-8].constant content1: [0,1,2,3,4,5,6,7]
11
+ typ[-8].constant content2: (8).times.to_a
10
12
 
11
13
  data0 <= content0[addr]
12
14
  data1 <= content1[addr]
@@ -0,0 +1,59 @@
1
+ # require "../hruby_low2c.rb"
2
+
3
+
4
+
5
+ # A system for testing the execution of par block in seq block.
6
+ system :seqpar_bench do
7
+
8
+ inner :rst, :clk
9
+ signed[8].inner :a, :b, :c, :d
10
+ signed[8].inner :out
11
+
12
+ seq(clk.posedge) do
13
+ hif(rst) do
14
+ a <= 0
15
+ b <= 0
16
+ c <= 0
17
+ d <= 0
18
+ end
19
+ helse do
20
+ a <= a + 1
21
+ b <= a + 2
22
+ par do
23
+ c <= b + 3
24
+ d <= c + 4
25
+ end
26
+ a <= d + 5
27
+ end
28
+ end
29
+
30
+ out <= a
31
+
32
+ timed do
33
+ clk <= 0
34
+ rst <= 0
35
+ !20.ns
36
+ clk <= 1
37
+ !20.ns
38
+ clk <= 0
39
+ rst <= 1
40
+ !20.ns
41
+ clk <= 1
42
+ !20.ns
43
+ clk <= 0
44
+ rst <= 0
45
+ !20.ns
46
+ clk <= 1
47
+ !20.ns
48
+ clk <= 0
49
+ !20.ns
50
+ clk <= 1
51
+ !20.ns
52
+ clk <= 0
53
+ !20.ns
54
+ clk <= 1
55
+ !20.ns
56
+ clk <= 0
57
+ !20.ns
58
+ end
59
+ end
@@ -61,5 +61,6 @@ system :fix_test do
61
61
  !10.ns
62
62
  c <= a * b
63
63
  !10.ns
64
+ c <= (a+b) * b
64
65
  end
65
66
  end
@@ -19,6 +19,8 @@ require 'HDLRuby/hruby_low_with_port'
19
19
  require 'HDLRuby/hruby_low_with_var'
20
20
  require 'HDLRuby/hruby_low_without_concat'
21
21
  require 'HDLRuby/hruby_low_without_connection'
22
+ require 'HDLRuby/hruby_low_casts_without_expression'
23
+ require 'hruby_low_without_parinseq'
22
24
  require 'HDLRuby/hruby_low_cleanup'
23
25
 
24
26
  require 'HDLRuby/hruby_verilog.rb'
@@ -577,10 +579,12 @@ elsif $options[:verilog] then
577
579
  # top_system = $top_system
578
580
  # Make description compatible with verilog generation.
579
581
  $top_system.each_systemT_deep do |systemT|
582
+ systemT.casts_without_expression!
580
583
  systemT.to_upper_space!
581
584
  systemT.to_global_systemTs!
582
585
  # systemT.break_types!
583
586
  # systemT.expand_types!
587
+ systemT.par_in_seq2seq!
584
588
  systemT.initial_concat_to_timed!
585
589
  systemT.with_port!
586
590
  end
@@ -1183,6 +1183,11 @@ module HDLRuby::Low
1183
1183
  return false
1184
1184
  end
1185
1185
 
1186
+ # Tells if the type of of vector kind.
1187
+ def vector?
1188
+ return false
1189
+ end
1190
+
1186
1191
  # Gets the bitwidth of the type, by default 0.
1187
1192
  # Bit, signed, unsigned and Float base have a width of 1.
1188
1193
  def width
@@ -1410,7 +1415,7 @@ module HDLRuby::Low
1410
1415
 
1411
1416
  # Sets the delegations
1412
1417
  self.extend Forwardable
1413
- [ :signed?, :unsigned?, :fixed?, :float?, :leaf?,
1418
+ [ :signed?, :unsigned?, :fixed?, :float?, :leaf?, :vector?,
1414
1419
  :width, :range?, :range, :base?, :base, :types?,
1415
1420
  :get_all_types, :get_type, :each, :each_type,
1416
1421
  :regular?,
@@ -1466,6 +1471,11 @@ module HDLRuby::Low
1466
1471
  # The base type of the vector
1467
1472
  attr_reader :base
1468
1473
 
1474
+ # Tells if the type of of vector kind.
1475
+ def vector?
1476
+ return true
1477
+ end
1478
+
1469
1479
  # Tells if the type has a base.
1470
1480
  def base?
1471
1481
  return true
@@ -0,0 +1,326 @@
1
+ require 'HDLRuby'
2
+ require 'HDLRuby/hruby_tools'
3
+ require 'HDLRuby/hruby_low_mutable'
4
+ require 'HDLRuby/hruby_low_with_bool'
5
+
6
+
7
+ module HDLRuby::Low
8
+
9
+
10
+ ##
11
+ # Replace expressions in cast operators with variables.
12
+ # Use for generating Verilog code generation since bit extension cannot
13
+ # be performed on expression but only on signals.
14
+ #
15
+ ########################################################################
16
+
17
+
18
+ ## Extends the SystemT class with functionality for extracting
19
+ # expressions from cast.
20
+ class SystemT
21
+
22
+ # Extracts the expressions from the casts.
23
+ def casts_without_expression!
24
+ self.scope.casts_without_expression!
25
+ return self
26
+ end
27
+
28
+ end
29
+
30
+
31
+ ## Extends the Scope class with functionality for extracting
32
+ # expressions from cast.
33
+ class Scope
34
+
35
+ # Extracts the expressions from the casts.
36
+ def casts_without_expression!
37
+ # Recurse on the sub scopes.
38
+ self.each_scope(&:casts_without_expression!)
39
+
40
+ # Apply on the connections.
41
+ self.each_connection(&:casts_without_expression!)
42
+
43
+ # Apply on the behaviors.
44
+ self.each_behavior do |behavior|
45
+ behavior.block.casts_without_expression!
46
+ end
47
+ return self
48
+ end
49
+ end
50
+
51
+
52
+ ## Extends the Transmit class with functionality for extracting
53
+ # expressions from cast.
54
+ class Transmit
55
+
56
+ # Extracts the expressions from the casts.
57
+ def casts_without_expression!
58
+ # Apply on the left value.
59
+ self.set_left!(self.left.casts_without_expression)
60
+ # Apply on the right value.
61
+ self.set_right!(self.right.casts_without_expression)
62
+ return self
63
+ end
64
+ end
65
+
66
+ ## Extends the If class with functionality for extracting
67
+ # expressions from cast.
68
+ class If
69
+
70
+ # Extracts the expressions from the casts.
71
+ def casts_without_expression!
72
+ # Apply on the condition.
73
+ self.set_condition!(self.condition.casts_without_expression)
74
+ # Apply on the yes.
75
+ self.yes.casts_without_expression!
76
+ # Apply on the noifs.
77
+ @noifs.map! do |cond,stmnt|
78
+ [cond.casts_without_expression,stmnt.casts_without_expression!]
79
+ end
80
+ # Apply on the no if any.
81
+ self.no.casts_without_expression! if self.no
82
+ return self
83
+ end
84
+ end
85
+
86
+ ## Extends the When class with functionality for extracting
87
+ # expressions from cast.
88
+ class When
89
+
90
+ # Extracts the expressions from the casts.
91
+ def casts_without_expression!
92
+ # Apply on the match.
93
+ self.set_match!(self.match.casts_without_expression)
94
+ # Apply on the statement.
95
+ self.statement.casts_without_expression!
96
+ return self
97
+ end
98
+ end
99
+
100
+
101
+ ## Extends the Case class with functionality for extracting
102
+ # expressions from cast.
103
+ class Case
104
+
105
+ # Extracts the expressions from the casts.
106
+ def casts_without_expression!
107
+ # No need to apply on the value!
108
+ # Apply on the value.
109
+ self.set_value!(self.value.casts_without_expression)
110
+ # Apply on the whens.
111
+ self.each_when(&:casts_without_expression!)
112
+ # Apply on the default if any.
113
+ self.default.casts_without_expression! if self.default
114
+ return self
115
+ end
116
+ end
117
+
118
+
119
+ ## Extends the TimeWait class with functionality for extracting
120
+ # expressions from cast.
121
+ class TimeWait
122
+ # Extracts the expressions from the casts.
123
+ def casts_without_expression!
124
+ # Nothing to do.
125
+ return self
126
+ end
127
+ end
128
+
129
+ ## Extends the TimeRepeat class with functionality for extracting
130
+ # expressions from cast.
131
+ class TimeRepeat
132
+ # Extracts the expressions from the casts.
133
+ def casts_without_expression!
134
+ # Simply recurse on the stamtement.
135
+ self.statement.casts_without_expression!
136
+ return self
137
+ end
138
+ end
139
+
140
+
141
+ ## Extends the Block class with functionality for extracting
142
+ # expressions from cast.
143
+ class Block
144
+
145
+ # Extracts the expressions from the casts.
146
+ def casts_without_expression!
147
+ # Apply on each statement.
148
+ self.each_statement(&:casts_without_expression!)
149
+ return self
150
+ end
151
+ end
152
+
153
+
154
+ ## Extends the Value class with functionality for extracting
155
+ # expressions from cast.
156
+ class Value
157
+ # Extracts the expressions from the casts.
158
+ def casts_without_expression
159
+ # Simple clones.
160
+ return self.clone
161
+ end
162
+ end
163
+
164
+
165
+ ## Extends the Cast class with functionality for extracting
166
+ # expressions from cast.
167
+ class Cast
168
+ # Extracts the expressions from the casts.
169
+ def casts_without_expression
170
+ # Recurse on the child.
171
+ nchild = self.child.casts_without_expression
172
+ # Process the cast.
173
+ unless (nchild.is_a?(Ref)) then
174
+ # Need to extract the child.
175
+ # Create signal holding the child.
176
+ stmnt = self.statement
177
+ if (stmnt.is_a?(Connection)) then
178
+ # Specific case of connections: need to build
179
+ # a new block.
180
+ scop = stmnt.parent
181
+ scop.delete_connection!(stmnt)
182
+ stmnt = Transmit.new(stmnt.left.clone, stmnt.right.clone)
183
+ blk = Block.new(:seq)
184
+ scop.add_behavior(Behavior.new(blk))
185
+ blk.add_statement(stmnt)
186
+ else
187
+ blk = stmnt.block
188
+ end
189
+ name = HDLRuby.uniq_name
190
+ typ = nchild.type
191
+ sig = blk.add_inner(SignalI.new(name,typ))
192
+ # Add a statement assigning the child to the new signal.
193
+ nref = RefName.new(typ,RefThis.new,name)
194
+ nstmnt = Transmit.new(nref,nchild)
195
+ idx = blk.each_statement.find_index(stmnt)
196
+ blk.insert_statement!(idx,nstmnt)
197
+ # Replace the child by a reference to the created
198
+ # signal.
199
+ nchild = nref.clone
200
+ end
201
+ return Cast.new(self.type,nchild)
202
+ end
203
+ end
204
+
205
+ ## Extends the Unary class with functionality for extracting
206
+ # expressions from cast.
207
+ class Unary
208
+
209
+ # Extracts the expressions from the casts.
210
+ def casts_without_expression
211
+ # Recurse on the sub node.
212
+ return Unary.new(self.type,self.operator,
213
+ self.child.casts_without_expression)
214
+ return self
215
+ end
216
+ end
217
+
218
+
219
+ ## Extends the Binary class with functionality for extracting
220
+ # expressions from cast.
221
+ class Binary
222
+
223
+ # Extracts the expressions from the casts.
224
+ def casts_without_expression
225
+ # Recurse on the sub nodes.
226
+ return Binary.new(self.type,self.operator,
227
+ self.left.casts_without_expression,
228
+ self.right.casts_without_expression)
229
+ end
230
+ end
231
+
232
+
233
+
234
+ ## Extends the Select class with functionality for extracting
235
+ # expressions from cast.
236
+ class Select
237
+
238
+ # Extracts the expressions from the casts.
239
+ def casts_without_expression
240
+ # Recurse on the sub node.
241
+ return Select.new(self.type,"?",
242
+ self.select.casts_without_expression,
243
+ *self.each_choice.map do |choice|
244
+ choice.casts_without_expression
245
+ end )
246
+ return self
247
+ end
248
+ end
249
+
250
+
251
+ ## Extends the Concat class with functionality for converting booleans
252
+ # in assignments to select operators.
253
+ class Concat
254
+ # Extracts the expressions from the casts.
255
+ def casts_without_expression
256
+ # Recurse on the sub expressions.
257
+ return Concat.new(self.type,self.each_expression.map do |expr|
258
+ expr.casts_without_expression
259
+ end )
260
+ end
261
+ end
262
+
263
+
264
+ ## Extends the RefConcat class with functionality for converting booleans
265
+ # in assignments to select operators.
266
+ class RefConcat
267
+ # Extracts the expressions from the casts.
268
+ def casts_without_expression
269
+ # Recurse on the sub references.
270
+ return RefConcat.new(self.type,self.each_expression.map do |expr|
271
+ expr.casts_without_expression
272
+ end )
273
+ end
274
+ end
275
+
276
+
277
+ ## Extends the RefIndex class with functionality for converting booleans
278
+ # in assignments to select operators.
279
+ class RefIndex
280
+ # Extracts the expressions from the casts.
281
+ def casts_without_expression
282
+ # Recurse on the sub references.
283
+ return RefIndex.new(self.type,
284
+ self.ref.casts_without_expression,
285
+ self.index.casts_without_expression)
286
+ end
287
+ end
288
+
289
+
290
+ ## Extends the RefRange class with functionality for converting booleans
291
+ # in assignments to select operators.
292
+ class RefRange
293
+ # Extracts the expressions from the casts.
294
+ def casts_without_expression
295
+ # Recurse on the sub references.
296
+ return RefRange.new(self.type,
297
+ self.ref.casts_without_expression,
298
+ self.range.first.casts_without_expression ..
299
+ self.range.last.casts_without_expression)
300
+ end
301
+ end
302
+
303
+
304
+ ## Extends the RefName class with functionality for converting booleans
305
+ # in assignments to select operators.
306
+ class RefName
307
+ # Extracts the expressions from the casts.
308
+ def casts_without_expression
309
+ # Recurse on the sub references.
310
+ return RefName.new(self.type,
311
+ self.ref.casts_without_expression,
312
+ self.name)
313
+ end
314
+ end
315
+
316
+
317
+ ## Extends the RefThis class with functionality for converting booleans
318
+ # in assignments to select operators.
319
+ class RefThis
320
+ # Extracts the expressions from the casts.
321
+ def casts_without_expression
322
+ # Simply clone.
323
+ return self.clone
324
+ end
325
+ end
326
+ end