HDLRuby 2.11.12 → 3.1.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 (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
@@ -40,9 +40,9 @@ module HDLRuby::High
40
40
  return idstr
41
41
  end
42
42
 
43
- ##
44
- # Enhance the system type class with VCD support.
43
+
45
44
  class SystemT
45
+ # Enhance the system type class with VCD support.
46
46
 
47
47
  ## Initializes the displayer for generating a vcd on +vcdout+
48
48
  def show_init(vcdout)
@@ -161,9 +161,9 @@ module HDLRuby::High
161
161
  end
162
162
 
163
163
 
164
- ##
165
- # Enhance the scope class with VCD support.
166
164
  class Scope
165
+ # Enhance the scope class with VCD support.
166
+
167
167
  ## Shows the hierarchy of the variables.
168
168
  def show_hierarchy(vcdout)
169
169
  # puts "show_hierarchy for scope=#{self}"
@@ -252,9 +252,10 @@ module HDLRuby::High
252
252
  end
253
253
  end
254
254
 
255
- ##
256
- # Enhance the signals class with VCD support.
255
+
257
256
  module SimSignal
257
+ # Enhance the signals class with VCD support.
258
+
258
259
  ## Shows the hierarchy of the variables.
259
260
  def show_hierarchy(vcdout)
260
261
  # puts "show_hierarcy for signal=#{self.name}"
@@ -300,9 +301,10 @@ module HDLRuby::High
300
301
  end
301
302
  end
302
303
 
303
- ##
304
- # Enhance the Transmit class with VCD support.
304
+
305
305
  class Transmit
306
+ # Enhance the Transmit class with VCD support.
307
+
306
308
  ## Shows the hierarchy of the variables.
307
309
  def show_hierarchy(vcdout)
308
310
  # By default: nothing to do.
@@ -319,9 +321,10 @@ module HDLRuby::High
319
321
  end
320
322
  end
321
323
 
322
- ##
323
- # Enhance the TimeRepeat class with VCD support.
324
+
324
325
  class TimeRepeat
326
+ # Enhance the TimeRepeat class with VCD support.
327
+
325
328
  ## Shows the hierarchy of the variables.
326
329
  def show_hierarchy(vcdout)
327
330
  # Recurse on the statement.
@@ -339,9 +342,10 @@ module HDLRuby::High
339
342
  end
340
343
  end
341
344
 
342
- ##
343
- # Enhance the TimeWait class with VCD support.
345
+
344
346
  class TimeWait
347
+ # Enhance the TimeWait class with VCD support.
348
+
345
349
  ## Shows the hierarchy of the variables.
346
350
  def show_hierarchy(vcdout)
347
351
  # By default: nothing to do.
@@ -358,9 +362,10 @@ module HDLRuby::High
358
362
  end
359
363
  end
360
364
 
361
- ##
362
- # Enhance the Print class with VCD support.
365
+
363
366
  class Print
367
+ # Enhance the Print class with VCD support.
368
+
364
369
  ## Shows the hierarchy of the variables.
365
370
  def show_hierarchy(vcdout)
366
371
  # By default: nothing to do.
@@ -378,7 +383,7 @@ module HDLRuby::High
378
383
  end
379
384
 
380
385
 
381
- ## Module adding show_hierarchyto block objects.
386
+ ## Module adding show_hierarchy to block objects.
382
387
  module BlockHierarchy
383
388
  ## Shows the hierarchy of the variables.
384
389
  def show_hierarchy(vcdout)
@@ -445,23 +450,20 @@ module HDLRuby::High
445
450
  end
446
451
 
447
452
 
448
- ##
449
- # Enhance the block class with VCD support.
450
453
  class Block
454
+ # Enhance the block class with VCD support.
451
455
  include HDLRuby::High::BlockHierarchy
452
456
  end
453
457
 
454
458
 
455
- ##
456
- # Enhance the block class with VCD support.
457
459
  class TimeBlock
460
+ # Enhance the block class with VCD support.
458
461
  include HDLRuby::High::BlockHierarchy
459
462
  end
460
463
 
461
464
 
462
- ##
463
- # Enhance the if class with VCD support.
464
465
  class If
466
+ # Enhance the if class with VCD support.
465
467
  ## Shows the hierarchy of the variables.
466
468
  def show_hierarchy(vcdout)
467
469
  # Recurse on the yes.
@@ -502,9 +504,9 @@ module HDLRuby::High
502
504
  end
503
505
 
504
506
 
505
- ##
506
- # Enhance the Case class with VCD support.
507
507
  class Case
508
+ # Enhance the Case class with VCD support.
509
+
508
510
  ## Shows the hierarchy of the variables.
509
511
  def show_hierarchy(vcdout)
510
512
  # Recurse on each when.
@@ -538,9 +540,10 @@ module HDLRuby::High
538
540
  end
539
541
  end
540
542
 
541
- ##
542
- # Enhance the TimeRepeat class with VCD support.
543
+
543
544
  class TimeRepeat
545
+ # Enhance the TimeRepeat class with VCD support.
546
+
544
547
  ## Shows the hierarchy of the variables.
545
548
  def show_hierarchy(vcdout)
546
549
  # Recurse on the statement.
@@ -42,13 +42,13 @@ module HDLRuby
42
42
  elsif type.float? then
43
43
  return type
44
44
  elsif self.signed? then
45
- return self
45
+ if type.signed? then
46
+ return self.width >= type.width ? self : type
47
+ else
48
+ return self
49
+ end
46
50
  elsif type.signed? then
47
51
  return type
48
- elsif self.unsigned? then
49
- return self
50
- elsif type.unsigned? then
51
- return type
52
52
  elsif self.width >= type.width then
53
53
  return self
54
54
  else
@@ -56,7 +56,7 @@ module HDLRuby
56
56
  else
57
57
  # Generate the resulting content.
58
58
  res_content = self.content.send(op,val.content)
59
- # puts "op=#{op} self.content=#{self.content} (#{self.content.to_i}) val.content=#{val.content} (#{val.content.to_i}) res_content=#{res_content} (#{res_content.class})" if op == :^
59
+ # puts "op=#{op} self.content=#{self.content} (#{self.content.to_i}) val.content=#{val.content} (#{val.content.to_i}) res_content=#{res_content} (#{res_content.class})"
60
60
  end
61
61
  res_type = self.type.resolve(val.type)
62
62
  # # Adjust the result content size.
@@ -148,9 +148,11 @@ module HDLRuby
148
148
  if self.content.is_a?(BitString) then
149
149
  res_content = self.content[index*width..(index+1)*width-1]
150
150
  else
151
+ # puts "self.content=#{self.content} index=#{index}"
151
152
  sh = index*width
152
153
  mask = (-1 << sh) & ~(-1 << (index+1)*width)
153
154
  res_content = (self.content & mask) >> sh
155
+ # puts "res_content=#{res_content}"
154
156
  end
155
157
  # Return the resulting value.
156
158
  return self.class.new(res_type,res_content)
@@ -240,7 +242,7 @@ module HDLRuby
240
242
  # Generate the resulting type.
241
243
  res_type = self.type
242
244
  # Generate the resulting content.
243
- # puts "op=#{op} content=#{content.to_s}"
245
+ # puts "op=#{op} content=#{content.to_s} width=#{res_type.width}"
244
246
  res_content = self.content.send(op)
245
247
  # puts "res_content=#{res_content}"
246
248
  # Return the resulting value.
@@ -251,6 +253,7 @@ module HDLRuby
251
253
  # Cast to +type+.
252
254
  # NOTE: nodir tells if the direction is to be ignored.
253
255
  def cast(type,nodir = false)
256
+ # puts "cast with content=#{self.content} type.signed=#{type.signed?} type.width=#{type.width}"
254
257
  # Handle the direction.
255
258
  if !nodir && type.direction != self.type.direction then
256
259
  if self.content.is_a?(Numeric) then
@@ -279,16 +282,18 @@ module HDLRuby
279
282
  res_content.positive!
280
283
  end
281
284
  end
282
- # # truncs to the right size if necessary.
283
- # if res_content.is_a?(BitString) then
284
- # res_content.trunc!(type.width)
285
- # else
286
- # res_content = self.trunc(res_content,type.width)
287
- # end
285
+ if type.signed? && res_content.is_a?(Numeric) && res_content >= (1 << (type.width-1)) then
286
+ res_content = (-1 << type.width) + res_content
287
+ end
288
288
  # Generate the resulting value.
289
+ # puts "res_content=#{res_content}"
289
290
  return self.class.new(type,res_content)
290
291
  end
291
292
 
293
+ def as(typ)
294
+ return self.cast(typ)
295
+ end
296
+
292
297
  # Concat the content of +vals+.
293
298
  def self.concat(*vals)
294
299
  # Compute the resulting type.
@@ -405,6 +410,12 @@ module HDLRuby
405
410
  end
406
411
  end
407
412
 
413
+ # Tell if the value is high impedance.
414
+ def impedence?
415
+ return false unless @content.is_a?(BitString)
416
+ return @content.raw_content.include?(2)
417
+ end
418
+
408
419
  ## Converts the value to a string of the right size.
409
420
  def to_vstr
410
421
  if self.content.is_a?(Numeric) then