OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [conf.rb] - Diff between revs 9 and 10

Only display areas with differences | Details | Blame | View Log

Rev 9 Rev 10
###############################################################
###############################################################
#
#
#  File:      conf.rb
#  File:      conf.rb
#
#
#  Author:    Christian Hättich
#  Author:    Christian Hättich
#
#
#  Project:   System-On-Chip Maker
#  Project:   System-On-Chip Maker
#
#
#  Target:    Linux / Windows / Mac
#  Target:    Linux / Windows / Mac
#
#
#  Language:  ruby
#  Language:  ruby
#
#
#
#
###############################################################
###############################################################
#
#
#
#
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#
#
#   This program is free software: you can redistribute it and/or modify
#   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
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   (at your option) any later version.
#
#
#   This program is distributed in the hope that it will be useful,
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   GNU General Public License for more details.
#
#
#   You should have received a copy of the GNU General Public License
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see .
#   along with this program.  If not, see .
#
#
#
#
###############################################################
###############################################################
#
#
#   Description:
#   Description:
#
#
#     This class holds all the configuration and is
#     This class holds all the configuration and is
#     realized as singleton.
#     realized as singleton.
#     The instance can be accessed via Conf::instance
#     The instance can be accessed via Conf::instance
#     The configuration is splitted into two parts:
#     The configuration is splitted into two parts:
#       @data     -> user-configurable
#       @data     -> user-configurable
#       @data_ro  -> read-only
#       @data_ro  -> read-only
#
#
#
#
#
#
######
######
#
#
# TODO
# TODO
#     - functionallity to modify @data
#     - functionallity to modify @data
#
#
###############################################################
###############################################################
module SOCMaker
module SOCMaker
class Conf
class Conf
  include YAML_EXT
  include YAML_EXT
  include ERR
  include ERR
  private_class_method :new
  private_class_method :new
  def Conf.instance
  def Conf.instance
      @@inst = new if @@inst == nil
      @@inst = new if @@inst == nil
      return @@inst
      return @@inst
  end
  end
  def initialize( optional = {} )
  def initialize( optional = {} )
      init_with( optional.merge( { 'data' => {
      init_with( optional.merge( { 'data' => {
        # the name of this application/tool
        # the name of this application/tool
        :app_name         => 'SOC-Maker',
        :app_name         => 'SOC-Maker',
        # the name of the tool's commandline interface
        # the name of the tool's commandline interface
        :app_cli_name     => 'SOC-Maker CLI',
        :app_cli_name     => 'SOC-Maker CLI',
        # array of core search paths
        # array of core search paths
        :cores_search_path => [ './' ],
        :cores_search_path => [ './' ],
        # VHDL include directive
        # VHDL include directive
        :vhdl_include     => "library ieee;\nuse ieee.std_logic_1164.ALL;",
        :vhdl_include     => "library ieee;\nuse ieee.std_logic_1164.ALL;",
        # build directory, where the whole synthese and build process
        # build directory, where the whole synthese and build process
        # happens
        # happens
        :build_dir        =>  'build',
        :build_dir        =>  'build',
        # the folder inside build_dir, where all the vhdl source is placed
        # the folder inside build_dir, where all the vhdl source is placed
        :hdl_dir          =>  'hdl',
        :hdl_dir          =>  'hdl',
        # synthesis directory inside build_dir
        # synthesis directory inside build_dir
        :syn_dir          =>  'syn',
        :syn_dir          =>  'syn',
        # simulation directory inside build_dir
        # simulation directory inside build_dir
        :sim_dir          =>  'sim'
        :sim_dir          =>  'sim'
        } } ) )
        } } ) )
  end
  end
  def encoder_with( coder )
  def encoder_with( coder )
    coder[ 'data' ] = @data
    coder[ 'data' ] = @data
  end
  end
  def init_with( coder )
  def init_with( coder )
    serr_if( coder[ 'data' ] == nil,
    serr_if( coder[ 'data' ] == nil,
      "No configuration data provided",
      "No configuration data provided",
      field: 'data' )
      field: 'data' )
    @data = coder[ 'data' ]
    @data = coder[ 'data' ]
    %w[ app_name vhdl_include
    %w[ app_name vhdl_include
        build_dir hdl_dir
        build_dir hdl_dir
        syn_dir sim_dir ].each do |d|
        syn_dir sim_dir ].each do |d|
      serr_if( @data[ d.to_sym ] == nil,
      serr_if( @data[ d.to_sym ] == nil,
        "Data field '#{d}' is not provided",
        "Data field '#{d}' is not provided",
        field: 'data' )
        field: 'data' )
      verr_if( !@data[ d.to_sym ].is_a?( String ),
      verr_if( !@data[ d.to_sym ].is_a?( String ),
        "Data field '#{d}' is not of type String",
        "Data field '#{d}' is not of type String",
        field: 'data' )
        field: 'data' )
      verr_if( @data[ d.to_sym ].size == 0,
      verr_if( @data[ d.to_sym ].size == 0,
        "Data field '#{d}' is not of type String",
        "Data field '#{d}' is not of type String",
        field: 'data' )
        field: 'data' )
    end
    end
    @data_ro = {
    @data_ro = {
      :yaml_classes     => [  SOCMaker::CoreDef,
      :yaml_classes     => [  SOCMaker::CoreDef,
                              SOCMaker::SOCDef,
                              SOCMaker::SOCDef,
                              SOCMaker::IfcSpc,
                              SOCMaker::IfcSpc,
                              SOCMaker::LibInc,
                              SOCMaker::LibInc,
                              SOCMaker::Conf,
                              SOCMaker::Conf,
                              SOCMaker::CoreInst ],
                              SOCMaker::CoreInst ],
      # Regular expression, which is evaluatted to detect values like
      # Regular expression, which is evaluatted to detect values like
      #    eval function_name
      #    eval function_name
      # The function_name is used for further processing
      # The function_name is used for further processing
      :eval_regex       =>  /eval +([a-zA-Z_1-9]+)/,
      :eval_regex       =>  /eval +([a-zA-Z_1-9]+)/,
      # Regular expression to check, if it is VHDL or verilog
      # Regular expression to check, if it is VHDL or verilog
      :hdl_type_regex   => /(\bvhdl\b)|(\bverilog\b)/,
      :hdl_type_regex   => /(\bvhdl\b)|(\bverilog\b)/,
      #
      #
      # Regular expression for vhdl file detection
      # Regular expression for vhdl file detection
      #
      #
      :vhdl_file_regex    =>  /\A\S+\.vhd\Z/,
      :vhdl_file_regex    =>  /\A\S+\.vhd\Z/,
      #
      #
      # Regular expression for verilog file detection
      # Regular expression for verilog file detection
      #
      #
      :verilog_file_regex =>  /\A\S+\.v\Z/,
      :verilog_file_regex =>  /\A\S+\.v\Z/,
      #
      #
      # Regular expression to match names starting with non-number
      # Regular expression to match names starting with non-number
      #
      #
      :length_regex     =>  /\A[^0-9]+.*\Z/,
      :length_regex     =>  /\A[^0-9]+.*\Z/,
      #
      #
      # Regular expression to match a component's name (core-name or SOC-name)
      # Regular expression to match a component's name (core-name or SOC-name)
 
      # (Obsolete)
      #
      #
      :name_regex       =>  /^[a-zA-Z]+[a-zA-Z0-9_\-]*$/,
      :name_regex       =>  /^[a-zA-Z]+[a-zA-Z0-9_\-]*$/,
      :YPP_LUT          => {
      :YPP_LUT          => {
                /\bSOCM_CONF\b/     =>  '--- !ruby/object:SOCMaker::Conf',
                /\bSOCM_CONF\b/     =>  '--- !ruby/object:SOCMaker::Conf',
                /\bSOCM_CORE\b/     =>  '--- !ruby/object:SOCMaker::CoreDef',
                /\bSOCM_CORE\b/     =>  '--- !ruby/object:SOCMaker::CoreDef',
                /\bSOCM_SOC\b/      =>  '--- !ruby/object:SOCMaker::SOCDef',
                /\bSOCM_SOC\b/      =>  '--- !ruby/object:SOCMaker::SOCDef',
                /\bSOCM_IFC_SPC\b/  =>  '--- !ruby/object:SOCMaker::IfcSpc',
                /\bSOCM_IFC_SPC\b/  =>  '--- !ruby/object:SOCMaker::IfcSpc',
                /\bSOCM_INCLUDE\b/  =>  '--- !ruby/object:SOCMaker::LibInc',
                /\bSOCM_INCLUDE\b/  =>  '--- !ruby/object:SOCMaker::LibInc',
                /\bSOCM_INST\b/     =>  '!ruby/object:SOCMaker::CoreInst',
                /\bSOCM_INST\b/     =>  '!ruby/object:SOCMaker::CoreInst',
                /\bSOCM_IFC\b/      =>  '!ruby/object:SOCMaker::IfcDef',
                /\bSOCM_IFC\b/      =>  '!ruby/object:SOCMaker::IfcDef',
                /\bSOCM_PORT\b/     =>  '!ruby/object:SOCMaker::IfcPort',
                /\bSOCM_PORT\b/     =>  '!ruby/object:SOCMaker::IfcPort',
                /\bSOCM_HDL_FILE\b/ =>  '!ruby/object:SOCMaker::HDLFile',
                /\bSOCM_HDL_FILE\b/ =>  '!ruby/object:SOCMaker::HDLFile',
                /\bSOCM_PARAM\b/    =>  '!ruby/object:SOCMaker::Parameter',
                /\bSOCM_PARAM\b/    =>  '!ruby/object:SOCMaker::Parameter',
                /\bSOCM_SPARAM\b/   =>  '!ruby/object:SOCMaker::SParameter',
                /\bSOCM_SPARAM\b/   =>  '!ruby/object:SOCMaker::SParameter',
                /\bSOCM_SENTRY\b/   =>  '!ruby/object:SOCMaker::SParameterEntry'
                /\bSOCM_SENTRY\b/   =>  '!ruby/object:SOCMaker::SParameterEntry'
              },
              },
      #
      #
      # $1 provides the white spaces
      # $1 provides the white spaces
      # $2 the name
      # $2 the name
      #
      #
      :YPP_INV_REGEX      => /(\s)*-{0,3}\s*!ruby\/object:SOCMaker::([a-zA-Z]+)/,
      :YPP_INV_REGEX      => /(\s)*-{0,3}\s*!ruby\/object:SOCMaker::([a-zA-Z]+)/,
      :YPP_INV_LUT        => {
      :YPP_INV_LUT        => {
                'Conf'            => 'SOCM_CONF',
                'Conf'            => 'SOCM_CONF',
                'CoreDef'         => 'SOCM_CORE',
                'CoreDef'         => 'SOCM_CORE',
                'SOCDef'          => 'SOCM_SOC',
                'SOCDef'          => 'SOCM_SOC',
                'CoreInst'        => 'SOCM_INST',
                'CoreInst'        => 'SOCM_INST',
                'IfcSpc'          => 'SOCM_IFC_SPC',
                'IfcSpc'          => 'SOCM_IFC_SPC',
                'IfcDef'          => 'SOCM_IFC',
                'IfcDef'          => 'SOCM_IFC',
                'IfcPort'         => 'SOCM_PORT',
                'IfcPort'         => 'SOCM_PORT',
                'HDLFile'         => 'SOCM_HDL_FILE',
                'HDLFile'         => 'SOCM_HDL_FILE',
                'Parameter'       => 'SOCM_PARAM',
                'Parameter'       => 'SOCM_PARAM',
                'SParameter'      => 'SOCM_SPARAM',
                'SParameter'      => 'SOCM_SPARAM',
                'SParameterEntry' => 'SOCM_SENTRY',
                'SParameterEntry' => 'SOCM_SENTRY',
                'LibInc'          => 'SOCM_INCLUDE'
                'LibInc'          => 'SOCM_INCLUDE'
              },
              },
      # used to split yaml files
      # used to split yaml files
      #
      #
      :YPP_SPLIT_REGEX    => /^\s*---\s*!ruby\/(object|object):SOCMaker/,
      :YPP_SPLIT_REGEX    => /^\s*---\s*!ruby\/(object|object):SOCMaker/,
      :COMMENT_REGEX      => /([^#]*)(#.*)?/,
      :COMMENT_REGEX      => /([^#]*)(#.*)?/,
      :EMPTY_CMD_REGEX    => /(\s*)(.*)/,
      :EMPTY_CMD_REGEX    => /(\s*)(.*)/,
      :LIC =>
      :LIC =>
"""
"""
Copyright (C) 2014  Christian Haettich  - feddischson [ at ] opencores.org
Copyright (C) 2014  Christian Haettich  - feddischson [ at ] opencores.org
This program is free software: you can redistribute it and/or modify
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program.  If not, see .
along with this program.  If not, see .
"""
"""
    }
    }
  end
  end
  def [](y)
  def [](y)
    @data.merge( @data_ro )[y]
    @data.merge( @data_ro )[y]
  end
  end
  def []=(y, value)
  def []=(y, value)
    @data[y] = value
    @data[y] = value
  end
  end
  @@inst = nil
  @@inst = nil
end
end
end
end
# vim: noai:ts=2:sw=2
# vim: noai:ts=2:sw=2
 
 

powered by: WebSVN 2.1.0

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