URL
https://opencores.org/ocsvn/soc_maker/soc_maker/trunk
Subversion Repositories soc_maker
Compare Revisions
- This comparison shows the changes necessary to convert path
/soc_maker/trunk/lib
- from Rev 6 to Rev 7
- ↔ Reverse comparison
Rev 6 → Rev 7
/soc_maker/ifc_def.rb
121,7 → 121,6
'Port is not of type SocMaker::IfcPort (use SOCM_PORT)', |
instance: @name + name.to_s, |
field: 'ports' ) |
port.verify |
|
end |
|
140,8 → 139,6
end |
|
|
def verify |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/parameter.rb
93,8 → 93,6
|
end |
|
def verify |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/hdl_coder.rb
59,6 → 59,13
|
class VerilogCoder < HDLCoder |
#TODO |
# |
# |
|
def filename( name ) |
return name + ".v" |
end |
|
end |
|
|
86,7 → 93,7
# |
# In addition, we add some VHDL comments (author, mail, license) |
# |
def add_core_declaration( core_name, core_spec ) |
def add_core_component( core_name, core_spec ) |
|
@decl_part << "--\n" |
@decl_part << "-- core author: #{core_spec.author} - #{core_spec.authormail}\n" |
97,9 → 104,12
@decl_part << "generic ( #{ generic_str });\n" if generic_str.size > 0 |
@decl_part << "port( \n" << entity_port_str( core_spec ) <<" );\n" |
@decl_part << "end component #{core_spec.toplevel};\n" |
entity_generic_str( core_spec ) |
#entity_generic_str( core_spec ) |
end |
|
def filename( name ) |
return name + ".vhd" |
end |
|
|
def entity_generic_str( core ) |
134,6 → 144,9
# |
port_string << port_name.to_s << " : " |
|
puts port_name.to_s + ": dir: " + port_dir.to_s + ", len: " + port_len.to_s |
|
|
# port direction |
if port_dir == 2 |
port_string << " inout " |
151,7 → 164,7
elsif ( port_len.is_a?( Fixnum ) && port_len == 1 ) |
port_string << " std_logic " |
else |
puts "FAILED " + port_len |
puts "FAILED " + port_len.to_s #TODO |
end |
|
# end of the line |
162,7 → 175,7
end |
|
|
def add_core_inst( inst_name, inst ) |
def add_core_instance( inst_name, inst ) |
|
@inst_part << inst_name << " : " << inst.defn.toplevel << "\n" |
generic_str = "" |
173,7 → 186,7
end |
@inst_part << "generic map( \n#{generic_str} )\n" if generic_str.size > 0 |
port_str = "" |
inst.ports do |port_name, length, dir, is_last| |
inst.ports do |port_name, dir, length, is_last| |
port_str << "#{port_name} => #{inst_name}_#{port_name}" |
port_str << "," unless is_last |
port_str << "\n" |
188,15 → 201,15
end |
|
|
|
|
|
|
|
def ifc_declaration( ifc_spec, ifc_name, length ) |
def add_ifc_connection( ifc_spec, ifc_name, length, src_inst, dst_inst, src_ifc, dst_ifc ) |
|
### |
# |
# declaration |
# |
# |
ifc_spec.ports.each do |port_name, port| |
|
@decl_part << "signal #{ifc_name}_#{port_name.to_s} : " |
if length[ port_name ] > 1 |
@decl_part << " std_logic_vector( #{length[ port_name ]}-1 downto 0 ) " |
207,10 → 220,12
@decl_part << ";\n" |
end |
|
end |
|
def ifc_assignment( ifc_spec, ifc_name, length, src_inst, dst_inst, src_ifc, dst_ifc ) |
|
### |
# |
# assignment |
# |
# |
ifc_spec.ports.each do |port_name, port_dir| |
if port_dir == 0 |
src_inst_sel = src_inst |
234,6 → 249,8
|
# combine all sources |
tmp = "#{port_tmp_name} <= " |
assigned = false |
|
# loop over instances |
src_inst_sel.each_with_index do |(inst_name, inst), i| |
( tmp_name, port) = inst.get_port( src_ifc_sel[ inst_name ], port_name ) |
241,35 → 258,40
tmp << "\"" + "0" * ( length[ port_name ] - port[ :len ] ) + "\" & " if port[ :len ] < length[ port_name ] |
tmp << "#{inst_name}_#{tmp_name}" |
tmp << " and \n" unless i == src_inst_sel.size-1 |
assigned = true |
end |
|
end |
tmp << ";\n" |
@asgn_part << tmp |
@asgn_part << tmp if assigned |
|
|
puts src_inst_sel.size |
puts tmp |
|
|
tmp = "" |
assigned = false |
# assign to destination |
tmp = "" |
dst_inst_sel.each_with_index do |(inst_name, inst), i| |
( tmp_name, port) = inst.get_port( dst_ifc_sel[ inst_name ], port_name ) |
if port != nil |
tmp << "#{inst_name}_#{tmp_name} <= #{port_tmp_name}" |
tmp << "( #{port[ :len ]}-1 downto 0 )" if port[ :len ] > 1 |
tmp << ";\n" |
if not inst == nil #TODO |
( tmp_name, port) = inst.get_port( dst_ifc_sel[ inst_name ], port_name ) |
if port != nil |
tmp << "#{inst_name}_#{tmp_name} <= #{port_tmp_name}" |
tmp << "( #{port[ :len ]}-1 downto 0 )" if port[ :len ] > 1 |
tmp << ";\n" |
assigned = true |
end |
end |
end |
@asgn_part << tmp |
@asgn_part << tmp if assigned |
end |
|
end |
|
|
|
end |
|
|
|
# TODO: add sig list as argument (or interface list) for entity description |
def get_entity( soc, entity_name ) |
def get_hdl_code( soc, entity_name ) |
add_toplevel_sig( soc, entity_name ) |
entity_str = SOCMaker::conf[ :LIC ].split(/\n/).map{ |s| "-- "+s }.join("\n") + "\n" |
entity_str << "-- Auto-Generated by #{SOCMaker::conf[ :app_name ]} \n" |
300,10 → 322,13
end |
|
def add_toplevel_sig( soc, entity_name ) |
soc.ports do |port_name, length, dir, is_last| |
@asgn_part << "#{port_name} <= #{entity_name}_#{port_name}" |
@asgn_part << "," unless is_last |
@asgn_part << "\n" |
soc.ports do |port_name, dir, length, is_last| |
if dir == 0 |
@asgn_part << "#{port_name} <= #{entity_name}_#{port_name}" |
else |
@asgn_part << "#{entity_name}_#{port_name} <= #{port_name} " |
end |
@asgn_part << ";\n" |
if length > 1 |
@decl_part << "signal #{entity_name}_#{port_name} : std_logic_vector( #{length}-1 downto 0 );\n" |
else |
/soc_maker/core_inst.rb
57,7 → 57,7
def initialize( type, params = {} ) |
init_with( 'type' => type, |
'params' => params ) |
verify |
|
end |
def encode_with( coder ) |
%w[ type params ]. |
79,8 → 79,10
end |
|
def ports |
puts "HELP" + @defn.name |
p @ports |
@ports.each_with_index do |(name, port_def), i| |
yield( name.to_s, port_def[ :len ], port_def[ :dir ], i==@ports.size-1 ) |
yield( name.to_s, port_def[ :dir ], port_def[ :len ], i==@ports.size-1 ) |
end |
end |
|
96,30 → 98,15
|
|
|
def get_len( ifc_name, port_spec_name, inst = nil ) |
|
if inst == nil |
tmp = @defn.interfaces[ ifc_name.to_sym ]. |
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }. |
keys.first.to_s |
|
return tmp.size == 0 ? 0 : @ports[ tmp.to_sym ][ :len ] |
else |
if inst == @name |
return get_len( ifc_name, port_spec_name ) |
else |
return @defn.get_len( ifc_name, port_spec_name, inst ) |
end |
end |
end |
|
|
|
|
def implements_port?( ifc_name, port_spec_name ) |
@defn.implements_port?( ifc_name, port_spec_name ) |
end |
|
# |
# Get a port, identified by the interface and port name |
# |
# +ifc_name+:: name of the interface |
# +port_spec_name+:: name of the port |
# |
def get_port( ifc_name, port_spec_name ) |
tmp = @defn.interfaces[ ifc_name.to_sym ]. |
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }. |
128,9 → 115,14
end |
|
|
# TODO do we need this? |
# def implements_port?( ifc_name, port_spec_name ) |
# @defn.implements_port?( ifc_name, port_spec_name ) |
# end |
|
def verify |
|
def consistency_check |
|
@defn = SOCMaker::lib.get_core( @type ) |
|
|
149,13 → 141,6
end |
|
|
|
|
|
|
|
|
|
# @_params ||= {} |
# if @params != nil |
# @params.each do |name, val| |
196,59 → 181,110
|
lerr_if( @defn == nil, 'Core not found in lib', |
field: 'cores' ) |
|
|
@defn.consistency_check |
|
|
end |
|
|
|
# |
# Returns the length of a port within an interface. |
# If no instance is given, we know that it is |
# a toplevel interface. |
# Otherwise we check for this and we do a recursive call. |
# If this port is within a interface of a core, we |
# pass the call to the core-definition of this instance, which |
# knows all cores. |
# |
# +ifc_name+:: name of the interface |
# +port_spec_name+:: name of the port |
# +inst+:: name of the instance (optional), default is nil |
# |
def get_port_len( ifc_name, port_spec_name, inst = nil ) |
if inst == nil |
tmp = @defn.interfaces[ ifc_name.to_sym ]. |
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }. |
keys.first.to_s |
return tmp.size == 0 ? 0 : @ports[ tmp.to_sym ][ :len ] |
else |
if inst == @defn.name.to_sym |
return get_port_len( ifc_name, port_spec_name ) |
else |
return @defn.get_port_len( ifc_name, port_spec_name, inst ) |
end |
end |
end |
|
|
# |
# Returns the core definition for an instance (identified by its name) |
# |
# +inst+:: name of the instance |
# |
def get_core_def( inst ) |
tmp = @defn.get_core_def( inst ) |
if tmp != nil |
if inst == @defn.name |
return @defn |
else |
tmp = @defn.get_core_def( inst ) |
perr_if( tmp == nil, "#Processing error: {inst} not found by get_core_def" ) |
return tmp |
elsif inst == @name |
return self |
else |
return nil |
end |
end |
|
|
# |
# Returns a core instance, identified by its name. |
# If it is not a sub-core, we return our self |
# |
# +inst+:: name of the instance |
# |
def get_core_inst( inst ) |
if @defn.cores[ inst ] != nil |
return @defn.cores[ inst ] |
else |
return self |
end |
end |
|
|
# |
# Generate toplevel hdl file for this instance. |
# This assumes, that this instance represents a SOC with |
# further instances. |
# |
# |
# +coder+:: A HDL coder, which is used to create the auto-generated HDL (optional). |
# If no coder is given, a VHDLCoder is used. |
# |
# |
def gen_toplevel( coder = VHDLCoder.new ) |
|
def gen_toplevel( coder = VHDLCoder.new() ) |
|
|
# |
# create filename |
# Get filename |
# |
file_name = @defn.name.dup |
if coder.is_a?( VHDLCoder ) |
file_name << ".vhd" |
elsif coder.is_a?( VerilogCoder ) |
file_name << ".v" |
else |
perr_if( true, |
"No valid coder" ) |
end |
file_name = coder.filename( @defn.name ) |
|
|
SOCMaker::logger.proc( "START of creating top-level '" + file_name + "'" ) |
|
SOCMaker::logger.proc( "verifying first ..." ) |
|
|
# TODO: this is a fix, that the parameters in core_inst.ports are updated. |
# A good approach for verifying, which checks the whole consistency, needs |
# to be done |
@defn.cores.each do |inst_name, inst| |
inst.verify |
end |
# SOCMaker::logger.proc( "verifying first ..." ) |
# |
# # TODO: this is a fix, that the parameters in core_inst.ports are updated. |
# # A good approach for verifying, which checks the whole consistency, needs |
# # to be done |
# @defn.cores.each do |inst_name, inst| |
# inst.verify |
# end |
|
|
# |
# Create a unique list of cores and |
# add every core to your implementation. |
# add for each core a component statement (vhdl only). |
# Even if there are multiple instances of a core, |
# we need to decalre it only once |
# |
257,19 → 293,14
spec = SOCMaker::lib.get_core( inst.type ) |
SOCMaker::lib.check_nil( spec, "Can't find #{ inst.type } in SOC library" ) |
|
coder.add_core_declaration( inst.type, spec ) |
coder.add_core_component( inst.type, spec ) |
end |
|
#core_instances = {} |
#@cores.each do |inst_name, _core_inst| |
# # the corresponding core from SOC lib |
# core_def = SOCMaker::lib.get_core( _core_inst[ :type ] ) |
# core_instances[ inst_name ] = SOCMaker::CoreInst.new( core_def, _core_inst[ :params ] ) |
#end |
|
|
# |
# Instanciate each core |
# |
@defn.cores.each do |inst_name, inst| |
coder.add_core_inst( inst_name.to_s, inst ) |
coder.add_core_instance( inst_name.to_s, inst ) |
end |
|
|
283,94 → 314,105
con_def[ :rule ], |
con_def[ :mapping ][0], |
con_def[ :mapping ][1], |
coder ) |
coder ) |
|
end |
|
|
# |
# Write content to the file |
# |
SOCMaker::logger.proc( "writing top-level" ) |
|
file_dir = File.join( SOCMaker::conf[ :build_dir ], |
SOCMaker::conf[ :hdl_dir ] ) |
::FileUtils.mkdir_p file_dir |
file_path = File.join( file_dir, file_name ) |
File.open( file_path, 'w' ) do |f| |
f.write( coder.get_entity( self, "test" ) ) |
File.open( File.join( file_dir, file_name ), 'w' ) do |f| |
f.write( coder.get_hdl_code( self, @defn.name ) ) |
end |
SOCMaker::logger.proc( "END of creating top-level" ) |
SOCMaker::logger.proc( "END of creating top-level hdl code for #{@defn.name}" ) |
|
end |
|
|
|
|
# |
# This function is called during the toplevel generation |
# for each connection. |
# |
# +name+:: The name of the connection |
# +rule+:: The combination rule (obsolete/unused) |
# +src+:: Source hash with instance name as key and interface name as value |
# +dst+:: Destination hash with instance name as key and interface name as value |
# +coder+:: The HDL coder which is used |
# |
def gen_toplevel_con( name, rule, src, dst, coder ) |
|
src_inst = {}; |
dst_inst = {}; |
|
# fetch somehow the spec |
# |
# Get the interface specification by using the 1st source entry |
# and searching for the core-definition. |
# |
ifc_spec = SOCMaker::lib.get_ifc( |
get_core_def( src.keys.first.to_s ).interfaces[ src.values.first ].name, |
get_core_def( src.keys.first.to_s ).interfaces[ src.values.first ].version ) |
|
#port_used = {}; |
|
|
# |
# Get the maximum required signal length |
# |
# For each signal in the interface specification, |
# we create a list. The list has an entry for each source |
# and destination signal, which defines the length. |
# |
# In the second step, the maximum in each list is extracted. |
# |
length_tmp = {}; |
|
|
ifc_spec.ports.keys.each do |_name| |
# TODO: bis dahin konnte angenommen werden, dass self auch eine Art instanz ist, |
# aber hier geht das nicht mehr, weil get_len nur für CoreInst definiert ist. |
# |
|
|
# create a length table |
#port_used[ _name ] = false |
#dst.each do |inst_name, ifc_name| |
# port_used[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name ) |
#end |
#src.each do |inst_name, ifc_name| |
# port_used[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name ) |
#end |
|
|
|
length_tmp[ _name ] = [] |
dst.each do |inst_name, ifc_name| |
length_tmp[ _name ] << get_len( ifc_name, _name, inst_name ) |
length_tmp[ _name ] << get_port_len( ifc_name, _name, inst_name ) |
end |
src.each do |inst_name, ifc_name| |
length_tmp[ _name ] << get_len( ifc_name, _name, inst_name ) |
length_tmp[ _name ] << get_port_len( ifc_name, _name, inst_name ) |
end |
|
end |
|
# getting the maximum length for each signal |
max_length = Hash[ length_tmp.map{ |key, arr| [ key, arr.max ] } ] |
|
|
p max_length |
coder.ifc_declaration( ifc_spec, name, max_length ) |
|
# |
# Prepare a hash for all sources and destinations, where |
# the instance name is the key and the core-instance is |
# the value. |
# |
src.keys.each do |inst_name| |
src_inst[ inst_name ] = @defn.cores[ inst_name ] |
src_inst[ inst_name ] = get_core_inst( inst_name ) |
end |
dst.keys.each do |inst_name| |
dst_inst[ inst_name ] = @defn.cores[ inst_name ] |
dst_inst[ inst_name ] = get_core_inst( inst_name ) |
end |
|
coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst ) |
# |
# create the declaraion and assignments |
# |
coder.add_ifc_connection( ifc_spec, name, max_length, src_inst, dst_inst, src, dst ) |
|
end |
|
|
|
|
|
|
|
# |
# Returns a string describing this instance |
# |
def to_s |
"type: #{type}\n" + |
"params: #{params}\n" |
end |
|
# |
# Equal operator |
# |
def ==(o) |
o.class == self.class && |
o.type == self.type && |
/soc_maker/err.rb
0,0 → 1,135
############################################################### |
# |
# File: err.rb |
# |
# Author: Christian Hättich |
# |
# Project: System-On-Chip Maker |
# |
# Target: Linux / Windows / Mac |
# |
# Language: ruby |
# |
# |
############################################################### |
# |
# |
# Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org |
# |
# This program is free software: you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation, either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
# |
# |
############################################################### |
# |
# Description: |
# Error definitions and functions, which are used via mixins. |
# |
# |
############################################################### |
|
|
module SOCMaker |
|
# |
# This sub-module contains some error-functionallity, |
# which is used in different classes via mixins. |
# |
# serr_if means raise Structure ERRor IF ... |
# verr_if means raise Value ERRor IF ... |
# lerr_if means raise Library ERRor IF ... |
# perr_if mean raise Processing ERRor IF |
module ERR |
class YAMLParseError < RuntimeError |
end |
|
class StructureError < RuntimeError |
attr :name |
attr :field |
def initialize( name, field, message ) |
super message |
@name = name |
@field = field |
# p message |
SOCMaker::logger.error( "StructureError raised: " + message + " (#{name},#{field})" ) |
end |
def to_s |
"->#{@name}:#{@field}" |
end |
end |
|
class LibError < RuntimeError |
attr :name |
def initialize( requested, message ) |
super message |
@name = requested |
SOCMaker::logger.error( "LibError raised: " + message + " (#{requested})" ) |
end |
def to_s |
"->#{@name}" |
end |
end |
|
class ProcessingError < RuntimeError |
def initialize( message ) |
super message |
SOCMaker::logger.error( "ProcessingError raised: " + message ) |
end |
end |
|
class ValueError < RuntimeError |
attr :name |
attr :field |
def initialize( name, field, message ) |
super message |
@name = name |
@field = field |
SOCMaker::logger.error( "ValueError raised: " + message + " (#{name},#{field})" ) |
end |
def to_s |
"->#{@name}:#{@field}" |
end |
end |
|
|
|
def serr_if( res, msg, o={} ) |
o = { instance: '??', field: '??' }.merge( o ) |
if !!( res ) |
raise StructureError.new( o[:instance], o[:field], msg ) |
end |
end |
|
def verr_if( res, msg, o={}) |
o = { instance: '??', field: '??' }.merge( o ) |
if !!( res ) |
raise ValueError.new( o[:instance], o[:field], msg ) |
end |
end |
|
def lerr_if( res, msg, o={}) |
o = { requested: '??' }.merge( o ) |
if !!( res ) |
raise LibError.new( o[:requested], msg ) |
end |
end |
|
def perr_if( res, msg ) |
if !!( res ) |
raise ProcessingError.new( msg ) |
end |
end |
|
end # module ERR |
|
end # module SOCMaker |
/soc_maker/lib_inc.rb
80,8 → 80,6
end |
end |
|
def verify |
end |
|
def ==(o) |
o.class == self.class && o.dirs == self.dirs |
/soc_maker/component.rb
189,7 → 189,7
instance: @name+":"+ifc_name.to_s ) |
|
serr_if( !ifc.is_a?( SOCMaker::IfcDef ), |
'Interface definition is not SOCMaker::IfcDef (use SOCM_IFC)', |
'Interface definition is not SOCMaker::IfcDef (please use SOCM_IFC)', |
instance: @name+":"+ifc_name.to_s ) |
end |
|
200,7 → 200,7
instance: @name+":"+name.to_s ) |
|
serr_if( !param.is_a?( SOCMaker::Parameter ), |
'Instance parameter not SOCMaker::Parameter (use SOCM_PARAM)', |
'Instance parameter not SOCMaker::Parameter (please use SOCM_PARAM)', |
instance: @name+":"+name.to_s ) |
end |
|
211,12 → 211,14
instance: @name+":"+name.to_s ) |
|
serr_if( !sparam.is_a?( SOCMaker::SParameter ), |
'Static parameter not SOCMaker::Parameter (use SOCM_SPARAM)', |
'Static parameter not SOCMaker::Parameter (please use SOCM_SPARAM)', |
instance: @name+":"+name.to_s ) |
end |
|
end |
|
|
def consistency_check |
|
end |
|
321,16 → 323,18
|
end |
|
def implements_port?( ifc_name, port_spec_name ) |
tmp = @interfaces[ ifc_name.to_sym ]. |
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }.keys |
|
perr_if( tmp.size > 1, |
"The port #{port_spec_name} of interface #{ifc_name} is implemented |
multiple times" ) |
|
# def implements_port?( ifc_name, port_spec_name ) |
# tmp = @interfaces[ ifc_name.to_sym ]. |
# ports.select{ |key,hash| hash.defn == port_spec_name.to_s }.keys |
|
# perr_if( tmp.size > 1, |
# "The port #{port_spec_name} of interface #{ifc_name} is implemented |
# multiple times" ) |
|
return tmp.size == 1 |
end |
# return tmp.size == 1 |
# end |
|
def param_ok?( param_name, param_value ) |
param = inst_parameters[ param_name.to_sym ] |
340,25 → 344,6
|
|
|
def verify( is_soc = false ) |
|
# check interfaces |
@interfaces.each do |ifc_name, ifc| |
ifc.verify |
end |
|
# check instance parameters |
@inst_parameters.each do |name, param | |
param.verify |
end |
|
# check instance parameters |
@static_parameters.each do |name, sparam | |
sparam.verify |
end |
|
end |
|
def ==(o) |
|
tmp = ( o.class == self.class ) |
/soc_maker/soc_def.rb
72,20 → 72,17
@cons = coder[ 'cons' ] || {} |
end |
|
def verify |
super( true ) |
|
@cores.each do |core_name, core_inst| |
core_inst.verify |
def consistency_check |
super |
@cores.values.each do |inst| |
inst.consistency_check |
end |
|
end |
|
|
|
|
|
|
# SOCMaker::logger.error( "instantiation #{inst_name} is already in use" ) |
def inst_in_use?( inst_name ) |
@cores[ inst_name.to_sym ] != nil or |
131,9 → 128,9
end |
|
|
def get_len( ifc_name, port_name, inst ) |
def get_port_len( ifc_name, port_name, inst ) |
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 |
return nil |
end |
149,40 → 146,57
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 ) |
|
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 ], |
[ inst2, ifc2_name ] ].each do |sub_arr| |
perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ), |
"Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " ) |
[ [ inst1, ifc1_name ], |
[ inst2, ifc2_name ] ].each do |sub_arr| |
perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ), |
"Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " ) |
end |
|
|
core_spec_1 = get_core_def( inst1 ) |
core_spec_2 = get_core_def( inst2 ) |
core_def_1 = get_core_def( inst1 ) |
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_spec_2, ifc2_name ] ].each do |sub_arr| |
[ [ core_def_1, ifc1_name ], |
[ core_def_2, ifc2_name ] ].each do |sub_arr| |
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 |
|
# check name and version of the ifcs which will be connected |
perr_if( core_spec_1.interfaces[ ifc1_name.to_sym ].name != |
core_spec_2.interfaces[ ifc2_name.to_sym ].name || |
core_spec_1.interfaces[ ifc1_name.to_sym ].version != |
core_spec_2.interfaces[ ifc2_name.to_sym ].version, |
perr_if( core_def_1.interfaces[ ifc1_name.to_sym ].name != |
core_def_2.interfaces[ ifc2_name.to_sym ].name || |
core_def_1.interfaces[ ifc1_name.to_sym ].version != |
core_def_2.interfaces[ ifc2_name.to_sym ].version, |
"Can't connect #{ |
core_spec_1.interfaces[ ifc1_name.to_sym ].name } - #{ |
core_spec_2.interfaces[ ifc2_name.to_sym ].name } : #{ |
core_spec_1.interfaces[ ifc1_name.to_sym ].version } - #{ |
core_spec_2.interfaces[ ifc2_name.to_sym ].version }" ) |
core_def_1.interfaces[ ifc1_name.to_sym ].name } - #{ |
core_def_2.interfaces[ ifc2_name.to_sym ].name } : #{ |
core_def_1.interfaces[ ifc1_name.to_sym ].version } - #{ |
core_def_2.interfaces[ ifc2_name.to_sym ].version }" ) |
|
|
@cons[ con_name.to_sym ] = { |
/soc_maker/sparameter.rb
111,11 → 111,6
|
end |
|
def verify |
@parameters.each do |name, param| |
param.verify |
end |
end |
|
|
def ==(o) |
150,9 → 145,6
verr_if( !@token.is_a?( String ), 'token is not a string' ) |
verr_if( @token.size == 0, 'token has zero size' ) |
end |
def verify |
super |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/ifc_port.rb
95,8 → 95,6
end |
|
|
def verify |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/core_def.rb
46,7 → 46,7
# This class adds two fields to SOCMaker::Component: |
# - hdlfiles : hash of SOCMaker::HDLFile (mandatory, |
# at least one file) |
|
# |
######## |
# |
# TODO |
193,8 → 193,11
return nil |
end |
|
def consistency_check |
|
end |
|
|
def param_ok?( param_name, param_value ) |
param = inst_parameters[ param_name.to_sym ] |
param = static_parameters[ param_name.to_sym ] if param == nil |
201,13 → 204,6
return false if param == nil |
end |
|
def verify( is_soc = false ) |
|
# check hdl-files |
@hdlfiles.each do |file_name, defn | |
defn.verify |
end |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/hdl_file.rb
119,8 → 119,6
end |
|
|
def verify |
end |
|
def ==(o) |
o.class == self.class && |
/soc_maker/ifc_spc.rb
91,8 → 91,6
end |
|
end |
def verify |
end |
|
|
end |
/soc_maker/lib.rb
46,6 → 46,7
|
module SOCMaker |
class Lib |
include ERR |
|
def initialize |
|
111,12 → 112,9
# from an infinite call |
# |
folder_sym = File.expand_path( dir ).to_sym |
if @path_lut.include?( folder_sym ) |
SOCMaker::logger.warn( "double-include: infinite resursive search?" ) |
raise SOCMaker::ERR::LibError.new( "", "double-include" ) |
else |
@path_lut << folder_sym |
end |
lerr_if( @path_lut.include?( folder_sym ), |
"double-include: infinite resursive search?" ) |
@path_lut << folder_sym |
|
# get all yaml files in the directory |
SOCMaker::logger.info "search for include in: " + dir |
/soc_maker.rb
43,8 → 43,6
# (see from_f, from_s) |
# - creating YAML files from objects |
# (see SOCMaker::YAML_EXT::write_yaml) |
# - error-types and functions |
# (see SOCMaker::ERR) |
# |
# |
# |
104,14 → 102,14
|
# ensure, that we load only our classes |
if SOCMaker::conf[ :yaml_classes ].include?( o.class ) |
o.verify |
#o.verify |
objs << o |
else |
SOCMaker::logger.warn( "Tried to load something, which does not belong to #{SOCMaker::conf[ :app_name ]}" ) |
end |
rescue ArgumentError, Psych::SyntaxError #=> e |
#p e |
rescue ArgumentError, Psych::SyntaxError => e |
SOCMaker::logger.error( 'YAML loading failed, invalid YAML syntax?' ) |
SOCMaker::logger.error( ">>> #{e.to_s} <<<" ) |
raise ERR::YAMLParseError |
else |
end |
162,100 → 160,10
end |
|
|
# |
# This sub-module contains some error-functionallity, |
# which is used in different classes via mixins. |
# |
# serr_if means raise Structure ERRor IF ... |
# verr_if means raise Value ERRor IF ... |
# lerr_if means raise Library ERRor IF ... |
# perr_if mean raise Processing ERRor IF |
module ERR |
class YAMLParseError < RuntimeError |
end |
|
class StructureError < RuntimeError |
attr :name |
attr :field |
def initialize( name, field, message ) |
super message |
@name = name |
@field = field |
# p message |
SOCMaker::logger.error( "StructureError raised: " + message + " (#{name},#{field})" ) |
end |
def to_s |
"->#{@name}:#{@field}" |
end |
end |
|
class LibError < RuntimeError |
attr :name |
def initialize( requested, message ) |
super message |
@name = requested |
SOCMaker::logger.error( "LibError raised: " + message + " (#{requested})" ) |
end |
def to_s |
"->#{@name}" |
end |
end |
|
class ProcessingError < RuntimeError |
def initialize( message ) |
super message |
SOCMaker::logger.error( "ProcessingError raised: " + message ) |
end |
end |
|
class ValueError < RuntimeError |
attr :name |
attr :field |
def initialize( name, field, message ) |
super message |
@name = name |
@field = field |
SOCMaker::logger.error( "ValueError raised: " + message + " (#{name},#{field})" ) |
end |
def to_s |
"->#{@name}:#{@field}" |
end |
end |
|
|
|
def serr_if( res, msg, o={} ) |
o = { instance: '??', field: '??' }.merge( o ) |
if !!( res ) |
raise StructureError.new( o[:instance], o[:field], msg ) |
end |
end |
|
def verr_if( res, msg, o={}) |
o = { instance: '??', field: '??' }.merge( o ) |
if !!( res ) |
raise ValueError.new( o[:instance], o[:field], msg ) |
end |
end |
|
def lerr_if( res, msg, o={}) |
o = { requested: '??' }.merge( o ) |
if !!( res ) |
raise LibError.new( o[:requested], msg ) |
end |
end |
|
def perr_if( res, msg ) |
if !!( res ) |
raise ProcessingError.new( msg ) |
end |
end |
|
end # module ERR |
|
|
|
|
# :stopdoc: |
LIBPATH = ::File.expand_path('..', __FILE__) + ::File::SEPARATOR |
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR |
299,8 → 207,8
def self.require_all_libs |
file = ::File.basename(__FILE__, '.*') |
dir = ::File.dirname(__FILE__) |
%w[ ypp lib_inc |
component |
%w[ err ypp |
lib_inc component |
core_def core_inst |
hdl_file ifc_def |
ifc_port ifc_spc |