module SOCMaker

File: conf.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/>.

File: core_def.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/>.

File: core_inst.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/>.

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/>.

File: hdl_coder.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/>.

File: hdl_file.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:

File: ifc_def.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:

File: ifc_port.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/>.

File: if_spec.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/>.

File: spc_lib.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/>.

File: lib_inc.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/>.

File: parameter.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/>.

File: soc_def.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/>.

File: sparameter.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:

File: ypp.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/>.

Constants

VERSION

The SoC-Maker Version

Attributes

conf[RW]

The global configuration

lib[RW]

The global library

logger[RW]

The global logging instance

Public Class Methods

check_static_setup( static ) click to toggle source

Ensure, that there are no multiple defined static parameters for a core/soc.

static

Input hash with the structure { soc_id : { core_id1: { .… }, core_id2: { .… } } }

return

Output hash with the structure { core_id1: { .…}, core_id2: { .… } }

# File lib/soc_maker.rb, line 225
def check_static_setup( static )
  static_tmp = {}
  static.each do |core_id, static_setup|
    static_setup.each do |core_id2, value |
      if static_tmp.has_key?( core_id2 )
        raise ConsistenceError.new( "Invalid static setup: #{core_id2} is defined multiple times" ) 
      end
      static_tmp[ core_id2 ] = value
    end
  end
  return static_tmp
end
deploy_soc( soc, coder = VHDLCoder.new ) click to toggle source

Deployes a System-on-Chip:

  • get all core-ids

  • get all static parameters

  • call deploy for each core which causes to copy and generate all HDL files

soc

the System-on-Chip, which is deployed

coder

the choosen HDL coder

# File lib/soc_maker.rb, line 202
def deploy_soc( soc, coder = VHDLCoder.new )

  SOCMaker::logger.info "Deploying SOC #{soc.name}"
  soc.consistence_check
  ids = soc.all_core_id
  static = soc.all_static_parameters
  static = check_static_setup( static )

  SOCMaker::logger.info "Core Occurrence"
  SOCMaker::CoreDef.core_cnt( ids ).each do |k,v|
    SOCMaker::logger.info "#{k}\t#{v}"
  end
  ids.uniq.each{ |core| lib.get_core( core ).deploy( coder: coder, static: static ) }

end
from_f( path ) click to toggle source

Method to load a yaml-based object(s) from one or multiple files. The files are read and concatenated. Path argument can be an array of paths or a file (wildcards are allowed) loading from a YAML file

# File lib/soc_maker.rb, line 169
def from_f( path )

  path = Dir[ path ].sort if path.is_a?( String )

  SOCMaker::logger.warn( "No file(s) found to load" ) if path.size == 0

  yaml_str = ""
  path.each do |file|
    SOCMaker::logger.info "reading:" + file
    yaml_str << File.read( file )
  end
  o = from_s( yaml_str )
  o.src_dir = File.dirname( path.first )
  return o
end
from_s( s ) { |o| ... } click to toggle source

Funtion to load a object from a YAML string. This includes the YPP, which replaces our custom object tags with yaml object information. Afterwards, the method YAML::load is used to create the object.

In addition, it is possible to provide multiple objects in one string: YPP takes care and splits them into single object strings.

s

the object(s) as yaml string (before processing with YPP)

# File lib/soc_maker.rb, line 133
def from_s( s )

  objs = []
  SOCMaker::YPP.to_yaml( s ) do |yaml_obj_str|

    begin
      YAML::load( yaml_obj_str )
      o = YAML::load( yaml_obj_str )

      # ensure, that we load only our classes
      if SOCMaker::conf[ :yaml_classes ].include?( o.class )
        #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
      SOCMaker::logger.error( 'YAML loading failed, invalid YAML syntax?' )
      SOCMaker::logger.error( ">>> #{e.to_s} <<<" )
      raise ERR::YAMLParseError
    else
    end
  end

  if block_given?
    objs.each{ |o| yield(o) }
  end
  return ( objs.size >1 ? objs : objs[0] )
end
libpath( *args ) { || ... } click to toggle source

Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join.

# File lib/soc_maker.rb, line 272
def self.libpath( *args )
  rv =  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
  if block_given?
    begin
      $LOAD_PATH.unshift LIBPATH
      rv = yield
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end
load( options={} ) click to toggle source

Global initialization method: this loads the config and refreshes the core library. Typically, this is the first method which is called during initialization.

options
  • skip_refresh=true/false: can be used to skip refreshing the core library

  • logger_out=<any file stream>: default is STDOUT, can be used to put the log into a file

# File lib/soc_maker.rb, line 107
def load( options={} )
  options = { skip_refresh: false, logger_out: STDOUT }.merge( options )
  @conf   = Conf.instance
  @logger = Logger.new(options[ :logger_out ] )
  @lib    = Lib.new()
  @logger.progname = @conf[ :app_name ]
  @lib.refresh( options[ :libpath ] ) unless options[ :skip_refresh ]
end
path( *args ) { || ... } click to toggle source

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.

# File lib/soc_maker.rb, line 289
def self.path( *args )
  rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
  if block_given?
    begin
      $LOAD_PATH.unshift PATH
      rv = yield
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end
require_all_libs() click to toggle source

load all file for soc_maker

# File lib/soc_maker.rb, line 305
def self.require_all_libs
  file  = ::File.basename(__FILE__, '.*')
  dir = ::File.dirname(__FILE__)
  %w[ err         ypp         
      lib_inc     version
      core_def    core_inst 
      hdl_file    ifc_def
      ifc_port    ifc_spc
      soc_def     parameter 
      sparameter  hdl_coder
      lib cli conf 
      hdl_parser ].each { |rb| require ::File.expand_path(
                ::File.join( dir, file, rb ) )  }
end
to_yaml_s( o ) click to toggle source

This method takes an object, converts it to a YAML string and also applies the YPP to replace the YAML object-tags.

# File lib/soc_maker.rb, line 189
def to_yaml_s( o )
  YPP.from_yaml( o.to_yaml )
end