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 3 to Rev 5
    Reverse comparison

Rev 3 → Rev 5

/.conf.rb.swo File deleted \ No newline at end of file
/.core_inst.rb.swp File deleted \ No newline at end of file
/.hdl_file.rb.swp File deleted \ No newline at end of file
/.component.rb.swp File deleted \ No newline at end of file
/.ypp.rb.swp File deleted \ No newline at end of file
/ifc_def.rb
103,7 → 103,7
 
# ports
serr_if( coder[ 'ports' ] == nil,
"No ports are given for interface defiinition",
"No ports are given for interface definition",
field: 'ports' )
@ports = coder[ 'ports' ]
serr_if( !@ports.is_a?( Hash ) ||
/hdl_coder.rb
87,7 → 87,7
# In addition, we add some VHDL comments (author, mail, license)
#
def add_core_declaration( core_name, core_spec )
 
@decl_part << "--\n"
@decl_part << "-- core author: #{core_spec.author} - #{core_spec.authormail}\n"
@decl_part << "-- license: #{core_spec.license}\n"
189,6 → 189,9
 
 
 
 
 
 
def ifc_declaration( ifc_spec, ifc_name, length )
 
221,32 → 224,42
dst_ifc_sel = src_ifc
end
 
port_tmp_name = "#{ifc_name}_#{port_name.to_s}"
 
# length == 0 means, that no
# signal is assigned to this connection
if length[ port_name ] > 0
 
# combine all sources
tmp = "#{port_tmp_name} <= "
# 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 )
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
end
tmp << ";\n"
@asgn_part << tmp
port_tmp_name = "#{ifc_name}_#{port_name.to_s}"
 
# 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 )
tmp << "#{inst_name}_#{tmp_name} <= #{port_tmp_name}"
tmp << "( #{port[ :len ]}-1 downto 0 )" if port[ :len ] > 1
 
# combine all sources
tmp = "#{port_tmp_name} <= "
# 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 )
if port != nil
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
end
end
tmp << ";\n"
@asgn_part << tmp
 
# 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"
end
end
@asgn_part << tmp
end
@asgn_part << tmp
 
 
end
 
257,7 → 270,8
 
# TODO: add sig list as argument (or interface list) for entity description
def get_entity( soc, entity_name )
entity_str = SOCMaker::conf[ :LIC ].split(/\n/).map{ |s| "-- "+s }.join("\n")
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"
entity_str << "-- Date: #{Time.now}\n"
entity_str << SOCMaker::conf[ :vhdl_include ] + "\n"
285,10 → 299,21
return entity_str
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"
if length > 1
@decl_part << "signal #{entity_name}_#{port_name} : std_logic_vector( #{length}-1 downto 0 );\n"
else
@decl_part << "signal #{entity_name}_#{port_name} : std_logic;\n"
end
end
end
 
 
 
 
def asgn_str( ifc_spec, con, ifc_name, core1, core1_name, core2, core2_name )
port_string = ""
 
/core_inst.rb
78,11 → 78,6
 
end
 
#
# TODO: extract the HDL ports
#
# HDLParam = Struct.new( :value, :type )
# HDLPort = Struct.new( :len, :dir )
def ports
@ports.each_with_index do |(name, port_def), i|
yield( name.to_s, port_def[ :len ], port_def[ :dir ], i==@ports.size-1 )
102,14 → 97,20
 
def get_len( ifc_name, port_spec_name )
 
# get the port name, which we are using
 
# get the port name, which we are using
tmp = @defn.interfaces[ ifc_name.to_sym ].
ports.select{ |key,hash| hash.defn == port_spec_name.to_s }.
keys.first.to_s
return @ports[ tmp.to_sym ][ :len ]
 
return tmp.size == 0 ? 0 : @ports[ tmp.to_sym ][ :len ]
end
 
 
def implements_port?( ifc_name, port_spec_name )
@defn.implements_port?( ifc_name, port_spec_name )
end
 
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 }.
190,8 → 191,11
end
 
 
def to_s
"type: #{type}\n" +
"params: #{params}\n"
end
 
 
def ==(o)
o.class == self.class &&
o.type == self.type &&
/soc_def.rb
82,15 → 82,6
end
 
 
def get_and_ensure_dst_dir!( core_name )
dst_dir = File.expand_path(
File.join(
SOCMaker::conf[ :build_dir ],
SOCMaker::conf[ :hdl_dir ],
core_name ) )
FileUtils.mkdir_p dst_dir
return dst_dir
end
 
 
 
140,6 → 131,20
end
 
 
 
def get_core_def( inst )
if @cores[ inst.to_sym ] != nil
return @cores[ inst.to_sym ].defn
elsif inst == @name
return self
else
perr_if( true,
"Instance '#{inst}' does not exist in SOC '#{self.name}'" )
end
end
 
 
 
def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
 
return nil if inst_in_use?( con_name )
151,15 → 156,11
"Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " )
end
 
[ inst1, inst2 ].each do |inst|
perr_if( @cores[ inst.to_sym ] == nil,
"Instance '#{inst}' does not exist in SOC '#{self.name}'" )
end
 
# get the core-specs
core_spec_1 = SOCMaker::lib.get_core( @cores[ inst1.to_sym ].type )
core_spec_2 = SOCMaker::lib.get_core( @cores[ inst2.to_sym ].type )
core_spec_1 = get_core_def( inst1 )
core_spec_2 = get_core_def( inst2 )
 
 
[ [ core_spec_1, ifc1_name ],
[ core_spec_2, ifc2_name ] ].each do |sub_arr|
perr_if( sub_arr[ 0 ].interfaces[ sub_arr[ 1 ].to_sym ] == nil,
182,7 → 183,7
:rule => "or",
:mapping => [ { inst1.to_sym => ifc1_name.to_sym },
{ inst2.to_sym => ifc2_name.to_sym } ] }
return false
end
 
def set_param( instance, param, value )
251,7 → 252,7
 
def gen_toplevel( coder = VHDLCoder.new() )
 
file_name = @name
file_name = @name.dup
if coder.is_a?( VHDLCoder )
file_name << ".vhd"
328,28 → 329,30
 
# fetch somehow the spec
ifc_spec = SOCMaker::lib.get_ifc(
@cores[ src.keys.first ].defn.interfaces[ src.values.first ].name,
@cores[ src.keys.first ].defn.interfaces[ src.values.first ].version )
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 )
length_tmp = {};
 
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
length_tmp[ _name ] = []
port_used_tmp[ _name ] = false
dst.each do |inst_name, ifc_name|
length_tmp[ _name ] << @cores[ inst_name ].get_len( ifc_name, _name )
port_used_tmp[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name )
end
src.each do |inst_name, ifc_name|
length_tmp[ _name ] << @cores[ inst_name ].get_len( ifc_name, _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 ] } ]
# max_length = Hash[ length_tmp.map{ |key, arr| [ key, arr.max ] } ]
 
coder.ifc_declaration( ifc_spec, name, max_length )
# coder.ifc_declaration( ifc_spec, name, max_length )
 
 
 
362,7 → 365,7
 
 
 
coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
# coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
 
end
 
384,8 → 387,9
# copy each file into destination dir
core_def.hdlfiles.each do |file, val|
file_path = File.join( core_def.dir, val.path )
dst_path = File.join( dst_dir, file.to_s )
dst_path = File.join( dst_dir, val.path )
SOCMaker::logger.proc( "copy #{file_path} to #{ dst_path} " )
FileUtils.mkdir_p(File.dirname(dst_path))
FileUtils.cp( file_path, dst_path )
end
 
450,6 → 454,25
end
 
 
def to_s
 
tmp = "_________ SOC #{@name}: _______\n" +
super +
"\n__connections__\n"
 
@cons.each do |_con_name, con_def|
tmp += "#{_con_name}: #{con_def}\n"
end
 
tmp += "\n__cores__\n"
@cores.each do |inst_name, inst|
tmp += "#{inst_name}:\n#{inst}\n"
end
tmp += "'''''''''''''''''''''''''''''''''''\n"
return tmp
end
 
 
end # class SOCSpec
end # module SOCMaker
 
/component.rb
222,8 → 222,11
 
 
def get_files
unless self.vccmd.nil? or self.vccmd == 0
system( self.vccmd )
puts "PATH: "
p File.join( @dir )
unless self.vccmd.nil? or @vccmd.size == 0
puts"cd #{@dir} && #{@vccmd}"
system( "cd #{@dir} && #{vccmd} " )
end
end
 
236,6 → 239,15
end
end
 
def get_and_ensure_dst_dir!( core_name )
dst_dir = File.expand_path(
File.join(
SOCMaker::conf[ :build_dir ],
SOCMaker::conf[ :hdl_dir ],
core_name ) )
FileUtils.mkdir_p dst_dir
return dst_dir
end
 
#
# Iterates over interface list.
311,9 → 323,17
 
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" )
return tmp.size == 1
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
355,6 → 375,23
return true
end
 
def to_s
"version: #{@version}\n" +
"toplevel: #{@toplevel}\n" +
"description: #{@description}\n" +
"date: #{@date}\n" +
"license: #{@license}\n" +
"licensefile: #{@licensefile}\n" +
"author: #{@author}\n" +
"authormail: #{@authormail}\n" +
"vccmd: #{@vccmd}\n" +
"interfaces: #{@interfaces}\n" +
"functions: #{@functions}\n" +
"inst_parameters: #{@inst_parameters}\n" +
"static_parameters: #{@static_parameters}\n"
end
 
 
end # class CoreDef
end # module SOCMaker
/core_def.rb
101,11 → 101,11
end
 
 
def get_files
unless self.vccmd.nil? or self.vccmd == 0
system( self.vccmd )
end
end
# def get_files
# unless self.vccmd.nil? or self.vccmd.size == 0
# system( self.vccmd )
# end
# end
 
 
 
/lib.rb
247,6 → 247,15
return ifc_list
end
 
 
#
# TODO add test code
#
def cores
@cores_lib.each do |nameversion,core|
yield( nameversion.to_s, core )
end
end
 
end #class Lib
/cli.rb
285,6 → 285,20
end
 
 
 
PRINT_USAGE =
" > print # prints SOC information
 
"
def do_print( args )
if args.size != 0
puts "no arguments are required:\nusage:\n#{PRINT_USAGE}"
else
puts @soc
end
end
 
 
#
# Quit
#
322,6 → 336,23
@commands.each { |c| eval "puts #{c.upcase}_USAGE" }
end
 
 
SET_USAGE =
" > set # not implemented yet
 
"
def do_set( args )
puts "NOT IMPLEMENTED, YET"
end
 
GET_USAGE =
" > get # not implemented yet
 
"
def do_get( args )
puts "NOT IMPLEMENTED, YET"
end
 
# end command implementations
#
#################################
331,12 → 362,6
@soc = nil
 
def initialize
##
# Setup readline
#
@cmd_list = %w[ list generate open exit
help quit add parameter save
connect sparameter delete ].sort
# appreviation map
@appr_map = { 'n' => "new",
350,6 → 375,7
'p' => "parameter",
'd' => "delete",
'c' => "connect",
'i' => "print",
'x' => "exit"
}
356,9 → 382,9
# all available commands
@commands = %w[ new open list add parameter sparameter
delete connect save help quit exit
generate ]
generate print set get ]
 
comp = proc { |s| (@cmd_list + Dir.entries( Dir.pwd )).grep( /^#{Regexp.escape(s)}/ ) }
comp = proc { |s| (@commands + Dir.entries( Dir.pwd )).grep( /^#{Regexp.escape(s)}/ ) }
Readline.completion_append_character = " "
Readline.completion_proc = comp
 

powered by: WebSVN 2.1.0

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