Class: HDLRuby::Low::SystemI
- Inherits:
-
Base::SystemI
- Object
- Base::SystemI
- HDLRuby::Low::SystemI
- Extended by:
- Forwardable
- Includes:
- Hparent, Low2Symbol
- Defined in:
- lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2sym.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_resolve.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_with_var.rb,
lib/HDLRuby/hruby_low_with_port.rb,
lib/HDLRuby/hruby_low_without_namespace.rb
Overview
Extends the SystemI class with functionality for moving the declarations to the upper namespace.
Direct Known Subclasses
Constant Summary
Constants included from Low2Symbol
Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the instance if any.
-
#systemT ⇒ Object
readonly
The instantiated system.
Attributes included from Hparent
Instance Method Summary collapse
-
#add_systemT(systemT) ⇒ Object
Adds a system configuration.
- #each_arrow_deep ⇒ Object
- #each_behavior ⇒ Object
- #each_behavior_deep ⇒ Object
- #each_block_deep ⇒ Object
- #each_connection ⇒ Object
- #each_connection_deep ⇒ Object
-
#each_deep(&ruby_block) ⇒ Object
Iterates over each object deeply.
- #each_inner ⇒ Object
- #each_inout ⇒ Object
- #each_input ⇒ Object
- #each_output ⇒ Object
- #each_sensitive_deep ⇒ Object
- #each_signal ⇒ Object
- #each_signal_deep ⇒ Object
- #each_statement_deep ⇒ Object
- #each_systemI ⇒ Object
-
#each_systemT(&ruby_block) ⇒ Object
Iterates over the system layers.
-
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
-
#get_by_name(name) ⇒ Object
Find an inner object by +name+.
- #get_inner ⇒ Object
- #get_inout ⇒ Object
- #get_input ⇒ Object
- #get_output ⇒ Object
- #get_signal ⇒ Object
- #get_systemI ⇒ Object
-
#hash ⇒ Object
Hash function.
-
#initialize(name, systemT) ⇒ SystemI
constructor
Creates a new system instance of system type +systemT+ named +name+.
-
#replace_names!(former, nname) ⇒ Object
Replaces recursively +former+ name by +nname+ until it is redeclared.
-
#set_name!(name) ⇒ Object
Sets the name.
-
#set_systemT(systemT) ⇒ Object
Sets the systemT.
-
#to_c(res, level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby code.
-
#to_ch(res) ⇒ Object
Generates the content of the h file.
-
#to_hdr(level = 0) ⇒ Object
Generates the text of the equivalent hdr text.
-
#to_high ⇒ Object
Creates a new high system instance.
-
#to_vhdl(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
- #with_port! ⇒ Object
-
#with_var! ⇒ Object
Converts to a variable-compatible system.
Methods included from Low2Symbol
Methods included from Hparent
Constructor Details
#initialize(name, systemT) ⇒ SystemI
Creates a new system instance of system type +systemT+ named +name+.
248 249 250 251 252 253 |
# File 'lib/HDLRuby/hruby_db.rb', line 248 def initialize(name, systemT) # Ensures systemT is from Low::SystemT systemT = SystemT.get(systemT) # Initialize the system instance structure. super(name,systemT) end |
Instance Attribute Details
#name ⇒ Object
The name of the instance if any.
2549 2550 2551 |
# File 'lib/HDLRuby/hruby_low.rb', line 2549 def name @name end |
#systemT ⇒ Object (readonly)
The instantiated system.
2552 2553 2554 |
# File 'lib/HDLRuby/hruby_low.rb', line 2552 def systemT @systemT end |
Instance Method Details
#add_systemT(systemT) ⇒ Object
Adds a system configuration.
2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 |
# File 'lib/HDLRuby/hruby_low.rb', line 2607 def add_systemT(systemT) # puts "add_systemT #{systemT.name} to systemI #{self.name}" # Check and add the systemT. if !systemT.is_a?(SystemT) then raise AnyError, "Invalid class for a system type: #{systemT.class}" end # Set the base configuration of the added system. systemT.wrapper = self.systemT # Add it. @systemTs << systemT end |
#each_arrow_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_behavior ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_behavior_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_block_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_connection ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_connection_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_deep(&ruby_block) ⇒ Object
Iterates over each object deeply.
Returns an enumerator if no ruby block is given.
2576 2577 2578 2579 2580 2581 2582 2583 2584 |
# File 'lib/HDLRuby/hruby_low.rb', line 2576 def each_deep(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_deep) unless ruby_block # A ruby block? First apply it to current. ruby_block.call(self) # Do not recurse on the systemTs since necesarily processed # before! end |
#each_inner ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_inout ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_input ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_output ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_sensitive_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_signal ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_signal_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_statement_deep ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_systemI ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#each_systemT(&ruby_block) ⇒ Object
Iterates over the system layers.
2620 2621 2622 2623 2624 2625 |
# File 'lib/HDLRuby/hruby_low.rb', line 2620 def each_systemT(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_systemT) unless ruby_block # A ruby block? Apply it on the system layers. @systemTs.each(&ruby_block) end |
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
2587 2588 2589 2590 2591 2592 |
# File 'lib/HDLRuby/hruby_low.rb', line 2587 def eql?(obj) return false unless obj.is_a?(SystemI) return false unless @name.eql?(obj.name) return false unless @systemT.eql?(obj.systemT) return true end |
#get_by_name(name) ⇒ Object
Find an inner object by +name+. NOTE: return nil if not found.
80 81 82 83 |
# File 'lib/HDLRuby/hruby_low_resolve.rb', line 80 def get_by_name(name) # Look into the eigen system. return self.systemT.get_by_name(name) end |
#get_inner ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#get_inout ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#get_input ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#get_output ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#get_signal ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#get_systemI ⇒ Object
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/HDLRuby/hruby_low.rb', line 2674 def_delegators :@systemT, :each_input, :each_output, :each_inout, :each_inner, :each_signal, :each_signal_deep, :get_input, :get_output, :get_inout, :get_inner, :get_signal, :get_interface, :each_systemI, :get_systemI, :each_connection, :each_connection_deep, :each_statement_deep, :each_arrow_deep, :each_behavior, :each_behavior_deep, :each_block_deep, :each_sensitive_deep |
#hash ⇒ Object
Hash function.
2595 2596 2597 |
# File 'lib/HDLRuby/hruby_low.rb', line 2595 def hash return [@name,@systemT].hash end |
#replace_names!(former, nname) ⇒ Object
Replaces recursively +former+ name by +nname+ until it is redeclared.
419 420 421 422 423 424 425 426 427 |
# File 'lib/HDLRuby/hruby_low_without_namespace.rb', line 419 def replace_names!(former,nname) # Replace owns name if required. if self.name == former then self.set_name!(nname) end # Not needed since treated through scope and systemT. # # Recurse on the system type. # self.systemT.replace_names!(former,nname) end |
#set_name!(name) ⇒ Object
Sets the name.
523 524 525 526 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 523 def set_name!(name) # Set the name as a symbol. @name = name.to_sym end |
#set_systemT(systemT) ⇒ Object
Sets the systemT.
529 530 531 532 533 534 535 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 529 def set_systemT(systemT) # Check and set the systemT. if !systemT.is_a?(SystemT) then raise AnyError, "Invalid class for a system type: #{systemT.class}" end @systemT = systemT end |
#to_c(res, level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object. def to_c(level = 0)
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 1020 def to_c(res,level = 0) # The resulting string. # res = "" # Declare the global variable holding the signal. res << "SystemI " << Low2C.obj_name(self) << ";\n\n" # The header of the signal generation. res << " " * level*3 res << "SystemI " << Low2C.make_name(self) << "() {\n" res << " " * (level+1)*3 res << "SystemI systemI = malloc(sizeof(SystemIS));\n" res << " " * (level+1)*3 res << "systemI->kind = SYSTEMI;\n"; # Sets the global variable of the system instance. res << "\n" res << " " * (level+1)*3 res << Low2C.obj_name(self) << " = systemI;\n" # Set the owner if any. if self.parent then res << " " * (level+1)*3 res << "systemI->owner = (Object)" res << Low2C.obj_name(self.parent) << ";\n" else res << "systemI->owner = NULL;\n" end # Set the name res << " " * (level+1)*3 res << "systemI->name = \"#{self.name}\";\n" # # Set the type. # res << " " * (level+1)*3 # res << "systemI->system = " << Low2C.obj_name(self.systemT) << ";\n" # Set the systems. num_sys = self.each_systemT.to_a.size res << " " * (level+1)*3 res << "systemI->num_systems = #{num_sys};\n" res << " " * (level+1)*3 res << "systemI->systems = calloc(sizeof(SystemT), #{num_sys});\n" self.each_systemT.with_index do |sysT,i| res << " " * (level+1)*3 res << "systemI->systems[#{i}] = #{Low2C.obj_name(sysT)};\n" end # Configure the instance to current systemT. res << (" " * (level*3)) << "configure(systemI,0);\n" # Generate the return of the signal. res << "\n" res << " " * (level+1)*3 res << "return systemI;\n" # Close the signal. res << " " * level*3 res << "};\n\n" return res end |
#to_ch(res) ⇒ Object
Generates the content of the h file. def to_ch
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 1082 def to_ch(res) # res = "" # Declare the global variable holding the signal. res << "extern SystemI " << Low2C.obj_name(self) << ";\n\n" # Generate the access to the function making the systemT. */ res << "extern SystemI " << Low2C.make_name(self) << "();\n\n" return res end |
#to_hdr(level = 0) ⇒ Object
Generates the text of the equivalent hdr text. +level+ is the hierachical level of the object.
315 316 317 318 |
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 315 def to_hdr(level = 0) return Low2HDR.hdr_call_name(self.systemT.name, ":" + Low2HDR.hdr_decl_name(self.name)) end |
#to_high ⇒ Object
Creates a new high system instance.
199 200 201 |
# File 'lib/HDLRuby/hruby_low2high.rb', line 199 def to_high return HDLRuby::High::SystemI.new(self.name,self.systemT.to_high) end |
#to_vhdl(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.
878 879 880 881 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 878 def to_vhdl(level = 0) # Should never be here. raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}" end |
#with_port! ⇒ Object
176 177 178 179 |
# File 'lib/HDLRuby/hruby_low_with_port.rb', line 176 def with_port! self.systemT.with_port! return self end |
#with_var! ⇒ Object
Converts to a variable-compatible system.
NOTE: the result is the same systemT.
33 34 35 36 |
# File 'lib/HDLRuby/hruby_low_with_var.rb', line 33 def with_var! self.systemT.with_var! return self end |