OpenCores
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/soc_maker
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

/core_inst.rb
95,18 → 95,27
end
 
 
def get_len( ifc_name, port_spec_name )
 
# get the port name, which we are using
def get_len( ifc_name, port_spec_name, inst = nil )
 
tmp = @defn.interfaces[ ifc_name.to_sym ].
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }.
keys.first.to_s
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 ]
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
191,6 → 200,172
end
 
 
 
def get_core_def( inst )
tmp = @defn.get_core_def( inst )
if tmp != nil
return tmp
elsif inst == @name
return self
else
return nil
end
end
 
 
 
 
 
def gen_toplevel( coder = VHDLCoder.new() )
 
 
#
# create 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
 
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
# add every core to your implementation.
# Even if there are multiple instances of a core,
# we need to decalre it only once
#
@defn.cores.values.uniq{|x| x.type }.each do |inst; spec|
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 )
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
 
 
@defn.cores.each do |inst_name, inst|
coder.add_core_inst( inst_name.to_s, inst )
end
 
 
# Iterate over all connections:
# - create signal instances
# - add assignments
#
@defn.cons.each do |con_name, con_def|
gen_toplevel_con( con_name.to_s,
con_def[ :rule ],
con_def[ :mapping ][0],
con_def[ :mapping ][1],
coder )
end
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" ) )
end
SOCMaker::logger.proc( "END of creating top-level" )
 
end
 
 
def gen_toplevel_con( name, rule, src, dst, coder )
 
src_inst = {};
dst_inst = {};
 
# fetch somehow the spec
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 = {};
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 )
end
src.each do |inst_name, ifc_name|
length_tmp[ _name ] << get_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 )
 
src.keys.each do |inst_name|
src_inst[ inst_name ] = @defn.cores[ inst_name ]
end
dst.keys.each do |inst_name|
dst_inst[ inst_name ] = @defn.cores[ inst_name ]
end
 
coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
 
end
 
 
 
 
 
 
 
def to_s
"type: #{type}\n" +
"params: #{params}\n"
/component.rb
222,10 → 222,8
 
 
def get_files
puts "PATH: "
p File.join( @dir )
unless self.vccmd.nil? or @vccmd.size == 0
puts"cd #{@dir} && #{@vccmd}"
#puts"cd #{@dir} && #{@vccmd}"
system( "cd #{@dir} && #{vccmd} " )
end
end
/soc_def.rb
131,6 → 131,13
end
 
 
def get_len( ifc_name, port_name, inst )
if @cores[ inst.to_sym ] != nil
return @cores[ inst ].get_len( ifc_name, port_name )
else
return nil
end
end
 
def get_core_def( inst )
if @cores[ inst.to_sym ] != nil
138,8 → 145,7
elsif inst == @name
return self
else
perr_if( true,
"Instance '#{inst}' does not exist in SOC '#{self.name}'" )
return nil
end
end
 
249,126 → 255,6
end
 
 
 
def gen_toplevel( coder = VHDLCoder.new() )
 
file_name = @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
 
SOCMaker::logger.proc( "START of creating top-level '" + file_name + "'" )
 
 
#
# Create a unique list of cores and
# add every core to your implementation.
# Even if there are multiple instances of a core,
# we need to decalre it only once
#
@cores.values.uniq{|x| x.type }.each do |inst; spec|
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 )
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
 
 
@cores.each do |inst_name, inst|
coder.add_core_inst( inst_name.to_s, inst )
end
 
 
# Iterate over all connections:
# - create signal instances
# - add assignments
#
@cons.each do |con_name, con_def|
gen_toplevel_con( con_name.to_s,
con_def[ :rule ],
con_def[ :mapping ][0],
con_def[ :mapping ][1],
coder )
end
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" ) )
end
SOCMaker::logger.proc( "END of creating top-level" )
 
end
 
 
def gen_toplevel_con( name, rule, src, dst, coder )
 
src_inst = {};
dst_inst = {};
 
# fetch somehow the spec
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_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_tmp[ _name ] = false
dst.each do |inst_name, ifc_name|
port_used_tmp[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name )
end
src.each do |inst_name, ifc_name|
port_used_tmp[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name )
end
end
 
# getting the maximum length for each signal
# max_length = Hash[ length_tmp.map{ |key, arr| [ key, arr.max ] } ]
 
# coder.ifc_declaration( ifc_spec, name, max_length )
 
 
 
src.keys.each do |inst_name|
src_inst[ inst_name ] = @cores[ inst_name ]
end
dst.keys.each do |inst_name|
dst_inst[ inst_name ] = @cores[ inst_name ]
end
 
 
 
# coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
 
end
 
def copy_files
SOCMaker::logger.proc( "START of copying all HDL files" )
445,6 → 331,7
end
 
 
 
def ==(o)
o.class == self.class &&
o.cores == self.cores &&
/core_def.rb
101,15 → 101,9
end
 
 
# def get_files
# unless self.vccmd.nil? or self.vccmd.size == 0
# system( self.vccmd )
# end
# end
 
 
 
 
def generics
@inst_parameters.each_with_index do |(name, val), i|
yield( name.to_s, val.type, val.default, i == @inst_parameters.size-1 )
193,8 → 187,14
end
 
 
# this is a core_def and doesn't have
# sub-cores
def get_core_def( inst )
return nil
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
/cli.rb
106,6 → 106,8
puts "three arguments are required:\nusage:\n#{NEW_USAGE}"
else
@soc = SOCMaker::SOCDef.new( args[0], args[1], args[2] )
SOCMaker::lib.add_core( @soc )
@soc_inst = SOCMaker::CoreInst.new( "#{args[0]}#{args[1]}" )
#puts FMSG if @soc.load_soc( args[ 0 ] ) == nil
end
end
126,6 → 128,8
else
puts "loading #{args[0]}"
@soc = SOCMaker::from_f( args[0] )
SOCMaker::lib.add_core( @soc )
@soc_inst = SOCMaker::CoreInst.new( "#{@soc.name}#{@soc.version}" )
#puts FMSG if @soc.load_soc( args[ 0 ] ) == nil
end
end
261,7 → 265,6
if args.size > 1
puts "zero or one argument is required:\nusage:\n#{SAVE_USAGE}"
else
puts "in do_save"
p args
puts FMSG if @soc.save_yaml( args ) == nil
end
279,7 → 282,7
if args.size != 0
puts "no arguments are required:\nusage:\n#{GENERATE_USAGE}"
else
@soc.gen_toplevel
@soc_inst.gen_toplevel
@soc.copy_files
end
end
359,7 → 362,8
 
 
 
@soc = nil
@soc = nil
@soc_inst = nil
 
def initialize

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.