HDLRuby 3.8.1 → 3.9.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.
@@ -133,7 +133,7 @@ module HDLRuby::Low
133
133
  # Generate the inners declaration.
134
134
  self.each_inner do |inner|
135
135
  res << " " * (level*3)
136
- res << inner.type.to_high(level)
136
+ res << inner.type.to_hdr(level)
137
137
  res << ".inner :" << Low2HDR.hdr_decl_name(inner.name) << "\n"
138
138
  end
139
139
  # Generate the instances.
@@ -331,7 +331,7 @@ module HDLRuby::Low
331
331
  # +level+ is the hierachical level of the object.
332
332
  def to_hdr(level = 0)
333
333
  # Should never be here.
334
- raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
334
+ raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
335
335
  end
336
336
  end
337
337
 
@@ -449,7 +449,7 @@ module HDLRuby::Low
449
449
  # The resulting string.
450
450
  res = " " * (level*3)
451
451
  # Generate the wait.
452
- res << "wait " << self.delay.to_hdr(level) << "\n"
452
+ res << "!" << self.delay.to_hdr(level) << "\n"
453
453
  # Return the resulting string.
454
454
  return res
455
455
  end
@@ -465,7 +465,8 @@ module HDLRuby::Low
465
465
  # The resulting string.
466
466
  res = " " * (level*3)
467
467
  # Generate the header.
468
- res << "repeat " << self.delay.to_hdr(level) << " do\n"
468
+ # res << "repeat " << self.delay.to_hdr(level) << " do\n"
469
+ res << "repeat " << self.number.to_hdr(level) << " do\n"
469
470
  # Generate the statement to repeat.
470
471
  res << self.statement.to_hdr(level+1)
471
472
  # Close the repeat.
@@ -554,7 +555,7 @@ module HDLRuby::Low
554
555
  # +level+ is the hierachical level of the object.
555
556
  def to_hdr(level = 0)
556
557
  # Should never be here.
557
- raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
558
+ raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
558
559
  end
559
560
  end
560
561
 
@@ -566,7 +567,7 @@ module HDLRuby::Low
566
567
  # +level+ is the hierachical level of the object.
567
568
  def to_hdr(level = 0)
568
569
  if self.content.is_a?(HDLRuby::BitString) then
569
- return "_#{self.content}"
570
+ return "_b#{self.content}"
570
571
  else
571
572
  return self.content.to_s
572
573
  end
@@ -593,7 +594,7 @@ module HDLRuby::Low
593
594
  # +level+ is the hierachical level of the object.
594
595
  def to_hdr(level = 0)
595
596
  # Should never be here.
596
- raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
597
+ raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
597
598
  end
598
599
  end
599
600
 
@@ -672,7 +673,7 @@ module HDLRuby::Low
672
673
  # +level+ is the hierachical level of the object.
673
674
  def to_hdr(level = 0)
674
675
  # Should never be here.
675
- raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
676
+ raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
676
677
  end
677
678
  end
678
679
 
@@ -1100,7 +1100,7 @@ module HDLRuby::Low
1100
1100
  res << "begin\n"
1101
1101
  # Adds the wait.
1102
1102
  res << " " * ((level+1)*3)
1103
- res << "wait for " << self.delay.to_vhdl(level) << ";\n"
1103
+ res << "wait for " << self.number.to_vhdl(level) << ";\n"
1104
1104
  # Generate the remaining of the body.
1105
1105
  res << self.statement.to_vhdl(vars,level+1)
1106
1106
  # Close the process.
@@ -331,14 +331,35 @@ module HDLRuby::High::Std
331
331
  if ruby_block then
332
332
  # Case when a block is given.
333
333
  res = args[0]
334
- self.heach do |e|
335
- res = res ? ruby_block.call(res,e) : e
334
+ # HDLRuby special: the argument can also be the type.
335
+ if res.respond_to?(:to_type) then
336
+ typ = res.to_type
337
+ res = nil
338
+ self.heach do |e|
339
+ res = res ? ruby_block.call(res,e.as(typ)) : e.as(typ)
340
+ end
341
+ else
342
+ self.heach do |e|
343
+ res = res ? ruby_block.call(res,e) : e
344
+ end
336
345
  end
337
346
  else
338
347
  # Case when a symbol is given.
339
- sym, res = args[0], args[1]
340
- self.heach do |e|
341
- res = res ? res.send(sym,e) : e
348
+ res, sym = args[0], args[1]
349
+ if res.is_a?(::Symbol) then
350
+ sym = res
351
+ res = nil
352
+ end
353
+ if res.respond_to?(:to_type) then
354
+ typ = res.to_type
355
+ res = nil
356
+ self.heach do |e|
357
+ res = res ? res.send(sym,e.as(typ)) : e.as(typ)
358
+ end
359
+ else
360
+ self.heach do |e|
361
+ res = res ? res.send(sym,e) : e
362
+ end
342
363
  end
343
364
  end
344
365
  return res
@@ -947,7 +947,12 @@ module HDLRuby::High::Std
947
947
  enum = self.seach
948
948
  # Define the computation type: from the initial value if any,
949
949
  # otherwise from the enum.
950
- typ = init ? init.to_expr.type : enum.type
950
+ if init.respond_to?(:to_type) then
951
+ typ = init.to_type
952
+ init = nil
953
+ else
954
+ typ = init ? init.to_expr.type : enum.type
955
+ end
951
956
  # Generate the result signal.
952
957
  res = nil
953
958
  HDLRuby::High.cur_system.open do
@@ -2155,7 +2160,9 @@ module HDLRuby::High::Std
2155
2160
 
2156
2161
  # HW times iteration.
2157
2162
  def stimes(&ruby_block)
2158
- # return (0..self-1).seach(&ruby_block)
2163
+ # Ensures there is a ruby block. This allows to use empty while
2164
+ # statement.
2165
+ ruby_block = proc { } unless ruby_block
2159
2166
  return AnyRange.new(0,self-1).seach(&ruby_block)
2160
2167
  end
2161
2168
 
@@ -2320,6 +2327,9 @@ module HDLRuby::High::Std
2320
2327
 
2321
2328
  # HW times iteration.
2322
2329
  def stimes(&ruby_block)
2330
+ # Ensures there is a ruby block. This allows to use empty while
2331
+ # statement.
2332
+ ruby_block = proc { } unless ruby_block
2323
2333
  return (0..self-1).seach(&ruby_block)
2324
2334
  end
2325
2335