Class: HDLRuby::Low::SystemI

Inherits:
Base::SystemI
  • Object
show all
Extended by:
Forwardable
Includes:
Hdecorator, Hparent, Low2Symbol
Defined in:
lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.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

High::SystemI

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes included from Hdecorator

#hdr_id

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods included from Low2Symbol

#to_sym

Methods included from Hdecorator

decorate_parent_id, dump, each, each_with_property, get, included, load, #properties

Methods included from Hparent

#scope

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

#nameObject

The name of the instance if any.



2463
2464
2465
# File 'lib/HDLRuby/hruby_low.rb', line 2463

def name
  @name
end

#systemTObject (readonly)

The instantiated system.



2466
2467
2468
# File 'lib/HDLRuby/hruby_low.rb', line 2466

def systemT
  @systemT
end

Instance Method Details

#add_systemT(systemT) ⇒ Object

Adds a system layer.



2521
2522
2523
2524
2525
2526
2527
2528
# File 'lib/HDLRuby/hruby_low.rb', line 2521

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
    @systemTs << systemT
end

#each_arrow_deepObject

See Also:

  • SystemT#each_arrow_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_behaviorObject

See Also:

  • SystemT#each_behavior


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject

See Also:

  • SystemT#each_behavior_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject

See Also:

  • SystemT#each_block_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_connectionObject

See Also:

  • SystemT#each_connection


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject

See Also:

  • SystemT#each_connection_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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.



2490
2491
2492
2493
2494
2495
2496
2497
2498
# File 'lib/HDLRuby/hruby_low.rb', line 2490

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_innerObject

See Also:

  • SystemT#each_inner


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_inoutObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_inputObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_outputObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject

See Also:

  • SystemT#each_sensitive_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_signalObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_deepObject

See Also:

  • SystemT#each_statement_deep


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_systemIObject

See Also:

  • SystemT#each_systemI


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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.



2531
2532
2533
2534
2535
2536
# File 'lib/HDLRuby/hruby_low.rb', line 2531

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.

Returns:

  • (Boolean)


2501
2502
2503
2504
2505
2506
# File 'lib/HDLRuby/hruby_low.rb', line 2501

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.



64
65
66
67
# File 'lib/HDLRuby/hruby_low_resolve.rb', line 64

def get_by_name(name)
    # Look into the eigen system.
    return self.systemT.get_by_name(name)
end

#get_innerObject

See Also:

  • SystemT#get_inner


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_inoutObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_inputObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_outputObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_signalObject



2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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_systemIObject

See Also:

  • SystemT#get_systemI


2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'lib/HDLRuby/hruby_low.rb', line 2585

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

#hashObject

Hash function.



2509
2510
2511
# File 'lib/HDLRuby/hruby_low.rb', line 2509

def hash
    return [@name,@systemT].hash
end

#replace_names!(former, nname) ⇒ Object

Replaces recursively +former+ name by +nname+ until it is redeclared.



414
415
416
417
418
419
420
421
# File 'lib/HDLRuby/hruby_low_without_namespace.rb', line 414

def replace_names!(former,nname)
    # Replace owns name if required.
    if self.name == former then
        self.set_name!(nname)
    end
    # Recurse on the system type.
    self.systemT.replace_names!(former,nname)
end

#set_name!(name) ⇒ Object

Sets the name.



511
512
513
514
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 511

def set_name!(name)
    # Set the name as a symbol.
    @name = name.to_sym
end

#set_systemT(systemT) ⇒ Object

Sets the systemT.



517
518
519
520
521
522
523
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 517

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(level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
# File 'lib/HDLRuby/hruby_low2c.rb', line 858

def to_c(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)" + 
               "#{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"

    # 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_chObject

Generates the content of the h file.



906
907
908
909
910
911
912
913
914
915
# File 'lib/HDLRuby/hruby_low2c.rb', line 906

def to_ch
    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_high(level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.



315
316
317
318
# File 'lib/HDLRuby/hruby_low2high.rb', line 315

def to_high(level = 0)
    return Low2High.high_call_name(self.systemT.name,
           ":" + Low2High.high_decl_name(self.name))
end

#to_vhdl(level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.

Raises:



868
869
870
871
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 868

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



161
162
163
164
# File 'lib/HDLRuby/hruby_low_with_port.rb', line 161

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