Line 70... |
Line 70... |
@cores = coder[ 'cores' ] || {}
|
@cores = coder[ 'cores' ] || {}
|
@static = coder[ 'static' ] || {}
|
@static = coder[ 'static' ] || {}
|
@cons = coder[ 'cons' ] || {}
|
@cons = coder[ 'cons' ] || {}
|
end
|
end
|
|
|
def verify
|
|
super( true )
|
|
|
|
@cores.each do |core_name, core_inst|
|
def consistency_check
|
core_inst.verify
|
super
|
|
@cores.values.each do |inst|
|
|
inst.consistency_check
|
end
|
end
|
|
|
end
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
# SOCMaker::logger.error( "instantiation #{inst_name} is already in use" )
|
# SOCMaker::logger.error( "instantiation #{inst_name} is already in use" )
|
def inst_in_use?( inst_name )
|
def inst_in_use?( inst_name )
|
@cores[ inst_name.to_sym ] != nil or
|
@cores[ inst_name.to_sym ] != nil or
|
@cons[ inst_name.to_sym ] != nil
|
@cons[ inst_name.to_sym ] != nil
|
end
|
end
|
Line 129... |
Line 126... |
return false
|
return false
|
|
|
end
|
end
|
|
|
|
|
def get_len( ifc_name, port_name, inst )
|
def get_port_len( ifc_name, port_name, inst )
|
if @cores[ inst.to_sym ] != nil
|
if @cores[ inst.to_sym ] != nil
|
return @cores[ inst ].get_len( ifc_name, port_name )
|
return @cores[ inst ].get_port_len( ifc_name, port_name )
|
else
|
else
|
return nil
|
return nil
|
end
|
end
|
end
|
end
|
|
|
Line 149... |
Line 146... |
end
|
end
|
end
|
end
|
|
|
|
|
|
|
|
|
|
def add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
|
|
perr_if( @cons[ con_name.to_sym ] == nil, "Connection instance #{con_name} not found" )
|
|
@cons[ con_name.to_sym ][:mapping][0][ inst1.to_sym ] = ifc1_name.to_sym
|
|
@cons[ con_name.to_sym ][:mapping][1][ inst2.to_sym ] = ifc2_name.to_sym
|
|
end
|
|
|
|
|
|
|
def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
|
def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
|
|
|
return nil if inst_in_use?( con_name )
|
if @cores[ con_name.to_sym ] != nil
|
|
return nil
|
|
elsif @cons[ con_name.to_sym ] != nil
|
|
return add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
|
|
end
|
|
|
|
|
[ [ inst1, ifc1_name ],
|
[ [ inst1, ifc1_name ],
|
[ inst2, ifc2_name ] ].each do |sub_arr|
|
[ inst2, ifc2_name ] ].each do |sub_arr|
|
perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ),
|
perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ),
|
"Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " )
|
"Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " )
|
end
|
end
|
|
|
|
|
core_spec_1 = get_core_def( inst1 )
|
core_def_1 = get_core_def( inst1 )
|
core_spec_2 = get_core_def( inst2 )
|
core_def_2 = get_core_def( inst2 )
|
|
|
|
perr_if( !core_def_1, "Can't find core #{inst1}" )
|
|
perr_if( !core_def_2, "Can't find core #{inst2}" )
|
|
|
|
|
[ [ core_spec_1, ifc1_name ],
|
[ [ core_def_1, ifc1_name ],
|
[ core_spec_2, ifc2_name ] ].each do |sub_arr|
|
[ core_def_2, ifc2_name ] ].each do |sub_arr|
|
perr_if( sub_arr[ 0 ].interfaces[ sub_arr[ 1 ].to_sym ] == nil,
|
perr_if( sub_arr[ 0 ].interfaces[ sub_arr[ 1 ].to_sym ] == nil,
|
"Interface '#{sub_arr[ 1 ]}' dosn't exist in core '#{sub_arr[0].name}' " )
|
"Interface '#{sub_arr[ 1 ]}' dosn't exist in core '#{sub_arr[0].name}' \n" +
|
|
"The following interfaces do exist: '#{sub_arr[0].interfaces.keys}'" )
|
end
|
end
|
|
|
# check name and version of the ifcs which will be connected
|
# check name and version of the ifcs which will be connected
|
perr_if( core_spec_1.interfaces[ ifc1_name.to_sym ].name !=
|
perr_if( core_def_1.interfaces[ ifc1_name.to_sym ].name !=
|
core_spec_2.interfaces[ ifc2_name.to_sym ].name ||
|
core_def_2.interfaces[ ifc2_name.to_sym ].name ||
|
core_spec_1.interfaces[ ifc1_name.to_sym ].version !=
|
core_def_1.interfaces[ ifc1_name.to_sym ].version !=
|
core_spec_2.interfaces[ ifc2_name.to_sym ].version,
|
core_def_2.interfaces[ ifc2_name.to_sym ].version,
|
"Can't connect #{
|
"Can't connect #{
|
core_spec_1.interfaces[ ifc1_name.to_sym ].name } - #{
|
core_def_1.interfaces[ ifc1_name.to_sym ].name } - #{
|
core_spec_2.interfaces[ ifc2_name.to_sym ].name } : #{
|
core_def_2.interfaces[ ifc2_name.to_sym ].name } : #{
|
core_spec_1.interfaces[ ifc1_name.to_sym ].version } - #{
|
core_def_1.interfaces[ ifc1_name.to_sym ].version } - #{
|
core_spec_2.interfaces[ ifc2_name.to_sym ].version }" )
|
core_def_2.interfaces[ ifc2_name.to_sym ].version }" )
|
|
|
|
|
@cons[ con_name.to_sym ] = {
|
@cons[ con_name.to_sym ] = {
|
:rule => "or",
|
:rule => "or",
|
:mapping => [ { inst1.to_sym => ifc1_name.to_sym },
|
:mapping => [ { inst1.to_sym => ifc1_name.to_sym },
|