Line 76... |
Line 76... |
serr_if( !@params.is_a?( Hash ), 'Parameters are not given as hash',
|
serr_if( !@params.is_a?( Hash ), 'Parameters are not given as hash',
|
field: 'params' )
|
field: 'params' )
|
|
|
end
|
end
|
|
|
def ports
|
def ports( *args )
|
puts "HELP" + @defn.name
|
if args.size == 0
|
p @ports
|
|
@ports.each_with_index do |(name, port_def), i|
|
@ports.each_with_index do |(name, port_def), i|
|
yield( name.to_s, port_def[ :dir ], port_def[ :len ], i==@ports.size-1 )
|
yield( name.to_s, port_def[ :dir ], port_def[ :len ], port_def[ :default ], i==@ports.size-1 )
|
|
end
|
|
elsif args.size == 1
|
|
@ifcs[ args.first.to_sym ].each do |name, port_def, i|
|
|
yield( name.to_s, port_def[ :dir ], port_def[ :len ], port_def[ :default ], i==@ports.size-1 )
|
|
end
|
end
|
end
|
end
|
end
|
|
|
|
|
def generics
|
def generics
|
Line 114... |
Line 118... |
return [ tmp, @ports[ tmp.to_sym ] ]
|
return [ tmp, @ports[ tmp.to_sym ] ]
|
end
|
end
|
|
|
|
|
# TODO do we need this?
|
# TODO do we need this?
|
|
#
|
|
#
|
# def implements_port?( ifc_name, port_spec_name )
|
# def implements_port?( ifc_name, port_spec_name )
|
# @defn.implements_port?( ifc_name, port_spec_name )
|
# @defn.implements_port?( ifc_name, port_spec_name )
|
# end
|
# end
|
|
|
|
|
Line 160... |
Line 166... |
# @_params[ name ] = { value: val, type: param_type }
|
# @_params[ name ] = { value: val, type: param_type }
|
# end
|
# end
|
# end
|
# end
|
# end
|
# end
|
|
|
|
|
|
#
|
|
# TODO merge these two loops and create one hash
|
|
###
|
|
#
|
|
# create our own ports hash
|
|
#
|
@ports ||= {}
|
@ports ||= {}
|
@defn.ports do |port_name, port_dir, port_len, is_last |
|
@defn.ports do |port_name, port_dir, port_len, default, is_last |
|
|
if port_len.is_a?( String )
|
|
param_match = SOCMaker::conf[ :length_regex ].match( port_len )
|
|
|
|
if param_match and @params[ port_len.to_sym ] != nil
|
|
tmp =@params[ port_len.to_sym ]
|
|
tmp = tmp.to_i if tmp.is_a?( String )
|
|
@ports[ port_name.to_sym ] = { len: tmp, dir: port_dir, default: default }
|
|
else
|
|
SOCMaker::logger.error( "Failed to evaluate #{port_len} for port #{port_name}" )
|
|
end
|
|
else
|
|
@ports[ port_name.to_sym ] = { len: port_len, dir: port_dir, default: default }
|
|
end
|
|
end
|
|
|
|
|
|
@ifcs ||= {}
|
|
@defn.interfaces.keys.each do |ifc_name|
|
|
@ifcs[ ifc_name ] = {}
|
|
@defn.ports( ifc_name ) do |port_name, port_dir, port_len, default, is_last |
|
|
|
if port_len.is_a?( String )
|
if port_len.is_a?( String )
|
param_match = SOCMaker::conf[ :length_regex ].match( port_len )
|
param_match = SOCMaker::conf[ :length_regex ].match( port_len )
|
|
|
if param_match and @params[ port_len.to_sym ] != nil
|
if param_match and @params[ port_len.to_sym ] != nil
|
tmp =@params[ port_len.to_sym ]
|
tmp =@params[ port_len.to_sym ]
|
tmp = tmp.to_i if tmp.is_a?( String )
|
tmp = tmp.to_i if tmp.is_a?( String )
|
@ports[ port_name.to_sym ] = { len: tmp, dir: port_dir }
|
@ifcs[ ifc_name ][ port_name.to_sym ] = { len: tmp, dir: port_dir, default: default }
|
else
|
else
|
SOCMaker::logger.error( "Failed to evaluate #{port_len} for port #{port_name}" )
|
SOCMaker::logger.error( "Failed to evaluate #{port_len} for port #{port_name}" )
|
end
|
end
|
else
|
else
|
@ports[ port_name.to_sym ] = { len: port_len, dir: port_dir }
|
@ifcs[ ifc_name ][ port_name.to_sym ] = { len: port_len, dir: port_dir, default: default }
|
|
end
|
|
#
|
|
#puts "#{port_def_ref}, #{port_name}, #{port_dir}, #{port_default}"
|
end
|
end
|
end
|
end
|
|
|
lerr_if( @defn == nil, 'Core not found in lib',
|
# lerr_if( @defn == nil, 'Core not found in lib',
|
field: 'cores' )
|
# field: 'cores' )
|
|
|
|
|
@defn.consistency_check
|
@defn.consistency_check
|
|
|
|
|
Line 269... |
Line 306... |
file_name = coder.filename( @defn.name )
|
file_name = coder.filename( @defn.name )
|
|
|
SOCMaker::logger.proc( "START of creating top-level '" + file_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
|
|
|
|
|
|
#
|
#
|
# Create a unique list of cores and
|
# Create a unique list of cores and
|
# add for each core a component statement (vhdl only).
|
# add for each core a component statement (vhdl only).
|
# Even if there are multiple instances of a core,
|
# Even if there are multiple instances of a core,
|
# we need to decalre it only once
|
# we need to decalre it only once
|
Line 316... |
Line 342... |
con_def[ :mapping ][1],
|
con_def[ :mapping ][1],
|
coder )
|
coder )
|
|
|
end
|
end
|
|
|
|
assign_unused_to_default( coder )
|
|
|
|
|
#
|
#
|
# Write content to the file
|
# Write content to the file
|
#
|
#
|
SOCMaker::logger.proc( "writing top-level" )
|
SOCMaker::logger.proc( "writing top-level" )
|
Line 335... |
Line 363... |
|
|
|
|
|
|
|
|
#
|
#
|
|
# Assign default values for unused interfaces.
|
|
# This is just a helper function and is used by gen_toplevel
|
|
#
|
|
# +coder+:: A HDL coder, which is used to create the auto-generated HDL.
|
|
#
|
|
def assign_unused_to_default( coder )
|
|
|
|
|
|
|
|
# iterate over all instances
|
|
# and check all interfaces
|
|
@defn.cores.each do |inst_name, inst|
|
|
|
|
inst.defn.interfaces.each do |ifc_name, ifc|
|
|
|
|
#
|
|
# Get the interface specification by using the 1st source entry
|
|
# and searching for the core-definition.
|
|
#
|
|
ifc_spec = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
|
|
|
|
if !@defn.ifc_in_use?( inst_name, ifc_name )
|
|
|
|
default_tmp = {};
|
|
ifc_spec.ports.each do |_name,_port|
|
|
default_tmp[ _name ] = _port[ :default ]
|
|
end
|
|
|
|
coder.add_ifc_default_assignment( inst, inst_name, ifc_name, default_tmp )
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
#
|
# This function is called during the toplevel generation
|
# This function is called during the toplevel generation
|
# for each connection.
|
# for each connection.
|
#
|
#
|
# +name+:: The name of the connection
|
# +name+:: The name of the connection
|
# +rule+:: The combination rule (obsolete/unused)
|
# +rule+:: The combination rule (obsolete/unused)
|
Line 417... |
Line 482... |
o.class == self.class &&
|
o.class == self.class &&
|
o.type == self.type &&
|
o.type == self.type &&
|
o.params == self.params
|
o.params == self.params
|
end
|
end
|
|
|
|
# TODO
|
|
# private: assign_unused_to_default, :gen_toplevel_con
|
|
|
end # CoreInst
|
end # CoreInst
|
end # SOCMaker
|
end # SOCMaker
|
|
|
|
|