HDLRuby 3.1.0 → 3.3.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/HDLRuby.gemspec +1 -0
  3. data/README.html +2330 -2670
  4. data/README.md +400 -100
  5. data/ext/hruby_sim/hruby_rcsim_build.c +402 -3
  6. data/ext/hruby_sim/hruby_sim.h +2 -1
  7. data/ext/hruby_sim/hruby_sim_calc.c +34 -7
  8. data/ext/hruby_sim/hruby_sim_core.c +15 -5
  9. data/ext/hruby_sim/hruby_sim_tree_calc.c +112 -23
  10. data/lib/HDLRuby/hdr_samples/c_program/echo.c +33 -0
  11. data/lib/HDLRuby/hdr_samples/comparison_bench.rb +2 -2
  12. data/lib/HDLRuby/hdr_samples/counter_bench.rb +1 -1
  13. data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +8 -7
  14. data/lib/HDLRuby/hdr_samples/dff_properties.rb +2 -0
  15. data/lib/HDLRuby/hdr_samples/enum_as_param.rb +52 -0
  16. data/lib/HDLRuby/hdr_samples/linear_test.rb +2 -0
  17. data/lib/HDLRuby/hdr_samples/logic_bench.rb +6 -0
  18. data/lib/HDLRuby/hdr_samples/mei8.rb +6 -6
  19. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +6 -6
  20. data/lib/HDLRuby/hdr_samples/memory_test.rb +2 -0
  21. data/lib/HDLRuby/hdr_samples/named_sub.rb +9 -5
  22. data/lib/HDLRuby/hdr_samples/ram.rb +7 -6
  23. data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +2 -0
  24. data/lib/HDLRuby/hdr_samples/ruby_program/echo.rb +9 -0
  25. data/lib/HDLRuby/hdr_samples/ruby_program/stdrw.rb +6 -0
  26. data/lib/HDLRuby/hdr_samples/ruby_program/sw_cpu_terminal.rb +614 -0
  27. data/lib/HDLRuby/hdr_samples/ruby_program/sw_inc_mem.rb +32 -0
  28. data/lib/HDLRuby/hdr_samples/ruby_program/sw_log.rb +33 -0
  29. data/lib/HDLRuby/hdr_samples/struct.rb +15 -3
  30. data/lib/HDLRuby/hdr_samples/with_board.rb +63 -0
  31. data/lib/HDLRuby/hdr_samples/with_bram.rb +1 -1
  32. data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +1 -1
  33. data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +1 -1
  34. data/lib/HDLRuby/hdr_samples/with_channel.rb +2 -0
  35. data/lib/HDLRuby/hdr_samples/with_channel_other.rb +2 -0
  36. data/lib/HDLRuby/hdr_samples/with_class.rb +3 -1
  37. data/lib/HDLRuby/hdr_samples/with_clocks.rb +42 -0
  38. data/lib/HDLRuby/hdr_samples/with_connector.rb +2 -0
  39. data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -0
  40. data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +6 -0
  41. data/lib/HDLRuby/hdr_samples/with_fixpoint_adv.rb +73 -0
  42. data/lib/HDLRuby/hdr_samples/with_leftright.rb +1 -1
  43. data/lib/HDLRuby/hdr_samples/with_of.rb +1 -1
  44. data/lib/HDLRuby/hdr_samples/with_program_c.rb +28 -0
  45. data/lib/HDLRuby/hdr_samples/with_program_ruby.rb +28 -0
  46. data/lib/HDLRuby/hdr_samples/with_program_ruby_cpu.rb +234 -0
  47. data/lib/HDLRuby/hdr_samples/with_program_ruby_io.rb +23 -0
  48. data/lib/HDLRuby/hdr_samples/with_program_ruby_mem.rb +58 -0
  49. data/lib/HDLRuby/hdr_samples/with_program_ruby_threads.rb +56 -0
  50. data/lib/HDLRuby/hdr_samples/with_sequencer.rb +17 -0
  51. data/lib/HDLRuby/hdr_samples/with_sequencer_channel.rb +58 -0
  52. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +10 -0
  53. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +18 -4
  54. data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +2 -4
  55. data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +2 -1
  56. data/lib/HDLRuby/hdrcc.rb +72 -21
  57. data/lib/HDLRuby/hruby_error.rb +13 -0
  58. data/lib/HDLRuby/hruby_high.rb +125 -26
  59. data/lib/HDLRuby/hruby_low.rb +171 -3
  60. data/lib/HDLRuby/hruby_low2programs.rb +47 -0
  61. data/lib/HDLRuby/hruby_low_resolve.rb +3 -2
  62. data/lib/HDLRuby/hruby_low_without_namespace.rb +133 -5
  63. data/lib/HDLRuby/hruby_low_without_subsignals.rb +1 -1
  64. data/lib/HDLRuby/hruby_rcsim.rb +113 -6
  65. data/lib/HDLRuby/hruby_serializer.rb +2 -1
  66. data/lib/HDLRuby/hruby_verilog.rb +94 -20
  67. data/lib/HDLRuby/hruby_verilog_name.rb +3 -17
  68. data/lib/HDLRuby/std/clocks.rb +118 -50
  69. data/lib/HDLRuby/std/fixpoint.rb +2 -2
  70. data/lib/HDLRuby/std/function_generator.rb +1 -1
  71. data/lib/HDLRuby/std/linear.rb +7 -7
  72. data/lib/HDLRuby/std/sequencer.rb +263 -13
  73. data/lib/HDLRuby/std/sequencer_channel.rb +90 -0
  74. data/lib/HDLRuby/std/sequencer_func.rb +28 -15
  75. data/lib/HDLRuby/std/std.rb +6 -0
  76. data/lib/HDLRuby/ui/hruby_board.rb +1079 -0
  77. data/lib/HDLRuby/version.rb +1 -1
  78. data/lib/c/Rakefile +8 -0
  79. data/lib/c/cHDL.h +12 -0
  80. data/lib/c/extconf.rb +7 -0
  81. data/lib/rubyHDL.rb +33 -0
  82. data/tuto/gui_accum.png +0 -0
  83. data/tuto/gui_board.png +0 -0
  84. data/tuto/tutorial_sw.html +2263 -1890
  85. data/tuto/tutorial_sw.md +957 -62
  86. metadata +43 -5
  87. data/README.pdf +0 -0
  88. data/tuto/tutorial_sw.pdf +0 -0
@@ -880,9 +880,11 @@ module HDLRuby::High
880
880
  "Cannot convert a system without a name to HDLRuby::Low."
881
881
  end
882
882
  # Create the resulting low system type.
883
- # systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
884
- systemTL = HDLRuby::Low::SystemT.new(HDLRuby.uniq_name(name),
885
- self.scope.to_low)
883
+ # systemTL = HDLRuby::Low::SystemT.new(HDLRuby.uniq_name(name),
884
+ # self.scope.to_low)
885
+ systemTLN = HDLRuby.uniq_name(name)
886
+ systemTL = HDLRuby::Low::SystemT.new(systemTLN,
887
+ self.scope.to_low(systemTLN))
886
888
  # puts "New low from system #{self.name}: #{systemTL.name}"
887
889
  # # For debugging: set the source high object
888
890
  # systemTL.properties[:low2high] = self.hdr_id
@@ -1168,6 +1170,17 @@ module HDLRuby::High
1168
1170
  self.parent.inout(*names)
1169
1171
  end
1170
1172
 
1173
+ # Declares a program in language +lang+ with start function named +func+
1174
+ # and built through +ruby_block+.
1175
+ def program(lang, func, &ruby_block)
1176
+ # Create the program.
1177
+ prog = Program.new(lang, func, &ruby_block)
1178
+ # Adds the resulting program to the current scope.
1179
+ HDLRuby::High.top_user.add_program(prog)
1180
+ # Return the resulting program
1181
+ return prog
1182
+ end
1183
+
1171
1184
  # Declares a non-HDLRuby set of code chunks described by +content+ and
1172
1185
  # completed from +ruby_block+ execution result.
1173
1186
  # NOTE: content includes the events to activate the code on and
@@ -1512,6 +1525,8 @@ module HDLRuby::High
1512
1525
  scopeL.add_systemT(systemI_low.systemT)
1513
1526
  }
1514
1527
  end
1528
+ # Adds the programs.
1529
+ self.each_program { |prog| scopeL.add_program(prog.to_low) }
1515
1530
  # Adds the code chunks.
1516
1531
  self.each_code { |code| scopeL.add_code(code.to_low) }
1517
1532
  # Adds the connections.
@@ -1526,10 +1541,15 @@ module HDLRuby::High
1526
1541
  end
1527
1542
 
1528
1543
  # Converts the scope to HDLRuby::Low.
1529
- def to_low()
1544
+ # +name+ is the name of the system containing the new low scope in case
1545
+ # of top scope, should be used as name for it.
1546
+ # NOTE: by convention, the name of the top scope is the name of the
1547
+ # system.
1548
+ def to_low(low_name = nil)
1530
1549
  # Create the resulting low scope.
1531
1550
  # scopeL = HDLRuby::Low::Scope.new()
1532
- scopeL = HDLRuby::Low::Scope.new(self.name)
1551
+ low_name = self.name unless low_name
1552
+ scopeL = HDLRuby::Low::Scope.new(low_name)
1533
1553
  # # For debugging: set the source high object
1534
1554
  # scopeL.properties[:low2high] = self.hdr_id
1535
1555
  # self.properties[:high2low] = scopeL
@@ -1974,7 +1994,7 @@ module HDLRuby::High
1974
1994
  raise AnyError, "Generic type #{self.name} did not produce a valid type: #{gtype.class}"
1975
1995
  end
1976
1996
  # Create a new type definition from it.
1977
- gtype = TypeDef.new(self.name.to_s + "_#{args.join(":")}",
1997
+ gtype = TypeDef.new(self.name.to_s + "_#{args.join(':')}",
1978
1998
  gtype)
1979
1999
  # Adds the possible overloaded operators.
1980
2000
  self.each_overload do |op,ruby_block|
@@ -2168,6 +2188,7 @@ module HDLRuby::High
2168
2188
 
2169
2189
  # Methods for declaring systems
2170
2190
 
2191
+
2171
2192
  # Declares a high-level system type named +name+, with +includes+ mixins
2172
2193
  # system types and using +ruby_block+ for instantiating.
2173
2194
  def system(name = :"", *includes, &ruby_block)
@@ -2294,24 +2315,8 @@ module HDLRuby::High
2294
2315
  # Performs the connections.
2295
2316
  connects.each do |key,value|
2296
2317
  # Gets the signal corresponding to connect.
2297
- # signal = self.get_signal(key)
2298
- # unless signal then
2299
- # # Look into the included systems.
2300
- # self.systemT.scope.each_included do |included|
2301
- # signal = included.get_signal(key)
2302
- # break if signal
2303
- # end
2304
- # end
2305
2318
  signal = self.systemT.get_signal_with_included(key)
2306
2319
  # Check if it is an output.
2307
- # isout = self.get_output(key)
2308
- # unless isout then
2309
- # # Look into the inlucded systems.
2310
- # self.systemT.scope.each_included do |included|
2311
- # isout = included.get_output(key)
2312
- # break if isout
2313
- # end
2314
- # end
2315
2320
  isout = self.systemT.get_output_with_included(key)
2316
2321
  # Convert it to a reference.
2317
2322
  # puts "key=#{key} value=#{value} signal=#{signal}"
@@ -2441,7 +2446,6 @@ module HDLRuby::High
2441
2446
 
2442
2447
  # Gets the private namespace.
2443
2448
  def namespace
2444
- # self.systemT.scope.namespace
2445
2449
  self.systemT.namespace
2446
2450
  end
2447
2451
 
@@ -2492,6 +2496,68 @@ module HDLRuby::High
2492
2496
  end
2493
2497
  end
2494
2498
 
2499
+
2500
+
2501
+
2502
+ ##
2503
+ # Describes a program.
2504
+ class Program < HDLRuby::Low::Program
2505
+
2506
+ include Hmissing
2507
+
2508
+ attr_reader :namespace
2509
+
2510
+ # Create a program in language +lang+ with start function named +func+
2511
+ # and built through +ruby_block+.
2512
+ def initialize(lang, func, &ruby_block)
2513
+ # Create the program.
2514
+ super(lang,func)
2515
+ # Create the namespace for the program.
2516
+ @namespace = Namespace.new(self)
2517
+ # Build the program object.
2518
+ High.space_push(@namespace)
2519
+ High.top_user.instance_eval(&ruby_block)
2520
+ High.space_pop
2521
+ end
2522
+
2523
+ # Converts the if to HDLRuby::Low.
2524
+ def to_low
2525
+ # Create the resulting program.
2526
+ progL = HDLRuby::Low::Program.new(self.lang,self.function)
2527
+ # Add the wakening events.
2528
+ self.each_event { |ev| progL.add_event(ev.to_low) }
2529
+ # Add the code files.
2530
+ self.each_code { |ev| progL.add_code(code) }
2531
+ # Add the input signals references.
2532
+ self.each_input { |ref| progL.add_input(ref.to_low) }
2533
+ # Add the output signals references.
2534
+ self.each_output { |ref| progL.add_output(ref.to_low) }
2535
+ # Return the resulting program.
2536
+ return progL
2537
+ end
2538
+
2539
+ # Adds new activation ports.
2540
+ def actport(*evs)
2541
+ evs.each(&method(:add_actport))
2542
+ end
2543
+
2544
+ # Adds new code files.
2545
+ def code(*codes)
2546
+ codes.each(&method(:add_code))
2547
+ end
2548
+
2549
+ # Adds new input ports.
2550
+ def inport(ports = {})
2551
+ ports.each { |k,v| self.add_inport(k,v) }
2552
+ end
2553
+
2554
+ # Adds new output ports.
2555
+ def outport(ports = {})
2556
+ ports.each { |k,v| self.add_outport(k,v) }
2557
+ end
2558
+ end
2559
+
2560
+
2495
2561
  ##
2496
2562
  # Decribes a set of non-HDLRuby code chunks.
2497
2563
  class Code < HDLRuby::Low::Code
@@ -3336,6 +3402,24 @@ module HDLRuby::High
3336
3402
  include HExpression
3337
3403
  include HArrow
3338
3404
 
3405
+ # Update the initialize to handle struct types accesses if
3406
+ # it is not a RefObject, this latter being a proxy to a
3407
+ # real component.
3408
+ if klass != RefObject then
3409
+ original_initialize = instance_method(:initialize)
3410
+ define_method(:initialize) do |*args, &block|
3411
+ original_initialize.bind(self).call(*args,&block)
3412
+ # Now process it if it is a structured type.
3413
+ if self.type.struct? then
3414
+ self.type.each do |name,typ|
3415
+ self.define_singleton_method(name) do
3416
+ RefName.new(typ,self,name)
3417
+ end
3418
+ end
3419
+ end
3420
+ end
3421
+ end
3422
+
3339
3423
  # Converts to a new expression.
3340
3424
  def to_expr
3341
3425
  self.to_ref
@@ -3436,15 +3520,22 @@ module HDLRuby::High
3436
3520
  # Converts the name reference to a HDLRuby::Low::RefName.
3437
3521
  def to_low
3438
3522
  # puts "to_low with base=#{@base} @object=#{@object}"
3439
- # puts "@object.name=#{@object.name}"
3523
+ # puts "@object.name=#{@object.name} @object.parent=#{@object.parent.name}"
3440
3524
  if @base.is_a?(RefThis) &&
3441
3525
  (@object.parent != High.top_user) &&
3442
3526
  (@object.parent != High.cur_system) &&
3527
+ (@object.parent != High.cur_system.scope) &&
3443
3528
  (!@object.parent.name.empty?) then
3444
3529
  # Need to have a hierachical access.
3445
- # puts "Indirect access for #{self.object.name}: #{self.object.parent.name}(#{self.object.parent.class}) != #{High.cur_system.name}(#{High.top_user.class})"
3446
- refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
3530
+ if @object.respond_to?(:low_object) && @object.low_object then
3531
+ # There where already a low object, create the ref from it.
3532
+ # puts "absolute ref!"
3533
+ refNameL = @object.low_object.absolute_ref
3534
+ else
3535
+ # No create the indirect reference.
3536
+ refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
3447
3537
  @object.parent.to_ref.to_low,@object.name)
3538
+ end
3448
3539
  else
3449
3540
  # Direct access is enough.
3450
3541
  refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
@@ -3972,11 +4063,19 @@ module HDLRuby::High
3972
4063
  return [obj,self.to_expr]
3973
4064
  end
3974
4065
 
4066
+ # Get the low version off the object.
4067
+ # NOTE: only useful for Signals and SystemIs since they can be accessed
4068
+ # from outside the module they have been defined in.
4069
+ def low_object
4070
+ return @low_object
4071
+ end
4072
+
3975
4073
  # Converts the system to HDLRuby::Low and set its +name+.
3976
4074
  def to_low(name = self.name)
3977
4075
  # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
3978
4076
  valueL = self.value ? self.value.to_low : nil
3979
4077
  signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
4078
+ @low_object = signalIL
3980
4079
  # Recurse on the sub signals if any.
3981
4080
  self.each_signal do |sig|
3982
4081
  signalIL.add_signal(sig.to_low)
@@ -79,6 +79,24 @@ module HDLRuby::Low
79
79
  end
80
80
  return res
81
81
  end
82
+
83
+ # Get an absolute reference to the object.
84
+ def absolute_ref
85
+ # Get the full hierarchy up to the object.
86
+ path = self.hierarchy
87
+ # Create the reference.
88
+ # return path.reduce(RefThis.new) do |ref,node|
89
+ return path.reverse_each.reduce(RefThis.new) do |ref,node|
90
+ # puts "node=#{node}"
91
+ # puts "name=#{node.name}" if node.respond_to?(:name)
92
+ if node.respond_to?(:name) then
93
+ typ = node.respond_to?(:type) ? node.type : void
94
+ RefName.new(typ,ref,node.name)
95
+ else
96
+ ref
97
+ end
98
+ end
99
+ end
82
100
  end
83
101
 
84
102
 
@@ -98,7 +116,8 @@ module HDLRuby::Low
98
116
  attr_reader :scope
99
117
 
100
118
  # Creates a new system type named +name+ with +scope+.
101
- def initialize(name,scope)
119
+ # def initialize(name,scope)
120
+ def initialize(name,scope = nil)
102
121
  # Set the name as a symbol.
103
122
  @name = name.to_sym
104
123
 
@@ -109,6 +128,13 @@ module HDLRuby::Low
109
128
  @interface = [] # The interface signals in order of
110
129
  # declaration
111
130
 
131
+ # self.set_scope(scope) if scope
132
+ # end
133
+
134
+ # # Set the scope of the systemT to +scope+.
135
+ # # Note: cannot override an existing scope.
136
+ # def set_scope(scope)
137
+ # raise(AnyError,"Scope already present") if @scope
112
138
  # Check the scope
113
139
  unless scope.is_a?(Scope)
114
140
  raise AnyError,
@@ -313,7 +339,7 @@ module HDLRuby::Low
313
339
  # Returns an enumerator if no ruby block is given.
314
340
  def each_signal_all(&ruby_block)
315
341
  # No ruby block? Return an enumerator.
316
- return to_enum(:each_signal) unless ruby_block
342
+ return to_enum(:each_signal_all) unless ruby_block
317
343
  # A ruby block? Apply it on each signal instance.
318
344
  @inputs.each(&ruby_block)
319
345
  @outputs.each(&ruby_block)
@@ -526,6 +552,8 @@ module HDLRuby::Low
526
552
  @inners = HashName.new
527
553
  # Initialize the system instances list.
528
554
  @systemIs = HashName.new
555
+ # Initialize the programs list.
556
+ @programs = []
529
557
  # Initialize the non-HDLRuby code chunks list.
530
558
  @codes = []
531
559
  # Initialize the connections list.
@@ -804,7 +832,40 @@ module HDLRuby::Low
804
832
  # end
805
833
  # systemI
806
834
  # end
835
+
836
+
837
+ # Handling the programs.
838
+
839
+ # Adds program +prog+.
840
+ def add_program(prog)
841
+ # Check and add the program.
842
+ unless prog.is_a?(Program)
843
+ raise AnyError,
844
+ "Invalid class for a program: #{prog.class}"
845
+ end
846
+ # Set the parent of the program.
847
+ prog.parent = self
848
+ # Add the program.
849
+ @programs << prog
850
+ prog
851
+ end
852
+
853
+ # Iterates over the programs.
807
854
  #
855
+ # Returns an enumerator if no ruby block is given.
856
+ def each_program(&ruby_block)
857
+ # puts "each_program from scope=#{self}"
858
+ # No ruby block? Return an enumerator.
859
+ return to_enum(:each_program) unless ruby_block
860
+ # A ruby block? Apply it on each program.
861
+ @programs.each(&ruby_block)
862
+ end
863
+
864
+ # Tells if there is any program.
865
+ def has_program?
866
+ return !@programs.empty?
867
+ end
868
+
808
869
  # Handling the non-HDLRuby code chunks.
809
870
 
810
871
  # Adds code chunk +code+.
@@ -832,7 +893,7 @@ module HDLRuby::Low
832
893
  # puts "each_code from scope=#{self}"
833
894
  # No ruby block? Return an enumerator.
834
895
  return to_enum(:each_code) unless ruby_block
835
- # A ruby block? Apply it on each system instance.
896
+ # A ruby block? Apply it on each code.
836
897
  @codes.each(&ruby_block)
837
898
  end
838
899
 
@@ -2936,6 +2997,113 @@ module HDLRuby::Low
2936
2997
  end
2937
2998
 
2938
2999
 
3000
+ ##
3001
+ # Describes a program.
3002
+ class Program
3003
+
3004
+ include Hparent
3005
+
3006
+ attr_reader :language, :function
3007
+
3008
+ # Creates a new program in language +lang+ with start function
3009
+ # named +func+.
3010
+ def initialize(lang,func)
3011
+ # Sets the language.
3012
+ @language = lang.to_sym
3013
+ # Sets the start function.
3014
+ @function = func.to_s
3015
+ # Initializes the contents.
3016
+ @actports = [] # The activation ports.
3017
+ @codes = [] # The code files.
3018
+ @inports = {} # The input ports.
3019
+ @outports = {} # The output ports.
3020
+ end
3021
+
3022
+ # Add a new activation port.
3023
+ def add_actport(ev)
3024
+ unless ev.is_a?(Event) then
3025
+ raise AnyError, "Invalid class for an event: #{ev.class}"
3026
+ end
3027
+ @actports << ev
3028
+ end
3029
+
3030
+ # Add a new code file.
3031
+ def add_code(code)
3032
+ @codes << code.to_s
3033
+ end
3034
+
3035
+ # Add a new input port.
3036
+ def add_inport(name, sig)
3037
+ # Ensure name is a symbol.
3038
+ unless name.is_a?(Symbol) then
3039
+ name = name.to_s.to_sym
3040
+ end
3041
+ # Ensure sig is a signal.
3042
+ unless sig.is_a?(SignalI) then
3043
+ raise AnyError, "Invalid class for a signal: #{sig.class}"
3044
+ end
3045
+ # Add the new port.
3046
+ @inports[name] = sig
3047
+ end
3048
+
3049
+ # Add a new output port.
3050
+ def add_outport(name, sig)
3051
+ # Ensure name is a symbol.
3052
+ unless name.is_a?(Symbol) then
3053
+ name = name.to_s.to_sym
3054
+ end
3055
+ # Ensure sig is a signal.
3056
+ unless sig.is_a?(SignalI) then
3057
+ raise AnyError, "Invalid class for a signal: #{sig.class}"
3058
+ end
3059
+ # Add the new port.
3060
+ @outports[name] = sig
3061
+ end
3062
+
3063
+
3064
+ # Iterates over each activation event.
3065
+ #
3066
+ # Returns an enumerator if no ruby block is given.
3067
+ def each_actport(&ruby_block)
3068
+ # No block? Return an enumerator.
3069
+ return to_enum(:each_actport) unless ruby_block
3070
+ # A block is given, apply it.
3071
+ @actports.each(&ruby_block)
3072
+ end
3073
+
3074
+ # Iterates over each code file.
3075
+ #
3076
+ # Returns an enumerator if no ruby block is given.
3077
+ def each_code(&ruby_block)
3078
+ # No block? Return an enumerator.
3079
+ return to_enum(:each_code) unless ruby_block
3080
+ # A block is given, apply it.
3081
+ @codes.each(&ruby_block)
3082
+ end
3083
+
3084
+ # Iterate over each input port.
3085
+ #
3086
+ # Returns an enumerator if no ruby block is given.
3087
+ def each_inport(&ruby_block)
3088
+ # No block? Return an enumerator.
3089
+ return to_enum(:each_inport) unless ruby_block
3090
+ # A block is given, apply it.
3091
+ @inports.each(&ruby_block)
3092
+ end
3093
+
3094
+ # Iterate over each output port.
3095
+ #
3096
+ # Returns an enumerator if no ruby block is given.
3097
+ def each_outport(&ruby_block)
3098
+ # No block? Return an enumerator.
3099
+ return to_enum(:each_outport) unless ruby_block
3100
+ # A block is given, apply it.
3101
+ @outports.each(&ruby_block)
3102
+ end
3103
+
3104
+ end
3105
+
3106
+
2939
3107
  ##
2940
3108
  # Decribes a set of non-HDLRuby code chunks.
2941
3109
  class Code
@@ -0,0 +1,47 @@
1
+ require 'HDLRuby'
2
+ require 'HDLRuby/hruby_low_with_bool'
3
+ require 'HDLRuby/hruby_low_without_namespace'
4
+ require 'HDLRuby/hruby_low_with_var'
5
+
6
+
7
+ module HDLRuby::Low
8
+
9
+
10
+ ##
11
+ # Converts a HDLRuby::Low description to descriptions of software programs.
12
+ #
13
+ ########################################################################
14
+
15
+ ## Provides tools for extracting software from HDLRuby description.
16
+ module Low2Programs
17
+
18
+ class SystemT
19
+ ## Extends the SystemT class with extraction of software.
20
+
21
+ # Extract the information about the software in the system and put it
22
+ # into +target+ directory.
23
+ def extract_programs(target)
24
+ # Gather the programs descriptions.
25
+ programs = self.scope.each_scope_deep.map do |scope|
26
+ scope.each_program.to_a
27
+ end
28
+ programs.flatten!
29
+ # Sort the programs by language.
30
+ lang2prog = Hash.new([])
31
+ programs.each { |prog| lang2prog[prog.language] << prog }
32
+ # Copy the programs in the corresponding subdirectories.
33
+ lang2prog.each do |lang,progs|
34
+ dir = target + "/" + lang
35
+ Dir.mkdir(dir)
36
+ progs.each do |prog|
37
+ prog.each_code { |code| FileUtils.cp(code,dir) }
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+
44
+ class Scope
45
+ end
46
+
47
+ end
@@ -233,6 +233,7 @@ module HDLRuby::Low
233
233
  if self.ref.is_a?(RefName) then
234
234
  obj = self.ref.resolve
235
235
  # puts "obj=#{obj}"
236
+ return obj if obj.name == self.name
236
237
  # Look into the object for the name.
237
238
  return obj.get_by_name(self.name)
238
239
  else
@@ -242,9 +243,9 @@ module HDLRuby::Low
242
243
  while parent
243
244
  # puts "parent=#{parent}"
244
245
  if parent.respond_to?(:get_by_name) then
245
- # puts "get_by_name"
246
+ # puts "Going get_by_name with name=#{self.name}"
246
247
  found = parent.get_by_name(self.name)
247
- # puts "found" if found
248
+ # puts "found=#{found}" if found
248
249
  return found if found
249
250
  end
250
251
  parent = parent.parent