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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [conf.rb] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      conf.rb
4
#
5
#  Author:    Christian Hättich
6
#
7
#  Project:   System-On-Chip Maker
8
#
9
#  Target:    Linux / Windows / Mac
10
#
11
#  Language:  ruby
12
#
13
#
14
###############################################################
15
#
16
#
17
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
18
#
19
#   This program is free software: you can redistribute it and/or modify
20
#   it under the terms of the GNU General Public License as published by
21
#   the Free Software Foundation, either version 3 of the License, or
22
#   (at your option) any later version.
23
#
24
#   This program is distributed in the hope that it will be useful,
25
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
26
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
#   GNU General Public License for more details.
28
#
29
#   You should have received a copy of the GNU General Public License
30
#   along with this program.  If not, see .
31
#
32
#
33
###############################################################
34
#
35
#   Description:
36
#
37
#     This class holds all the configuration and is
38
#     realized as singleton.
39
#     The instance can be accessed via Conf::instance
40
#     The configuration is splitted into two parts:
41
#       @data     -> user-configurable
42
#       @data_ro  -> read-only
43
#
44
#
45
#
46
######
47
#
48
# TODO
49
#     - functionallity to modify @data
50
#
51
###############################################################
52
 
53
 
54
module SOCMaker
55
class Conf
56
  include YAML_EXT
57
  include ERR
58
 
59
  private_class_method :new
60
  def Conf.instance
61
      @@inst = new if @@inst == nil
62
      return @@inst
63
  end
64
 
65 9 feddischso
  def initialize( optional = {} )
66 3 feddischso
 
67
 
68 9 feddischso
      init_with( optional.merge( { 'data' => {
69 3 feddischso
        # the name of this application/tool
70
        :app_name         => 'SOC-Maker',
71
 
72
        # the name of the tool's commandline interface
73
        :app_cli_name     => 'SOC-Maker CLI',
74
 
75
        # array of core search paths
76
        :cores_search_path => [ './' ],
77
 
78
        # VHDL include directive
79
        :vhdl_include     => "library ieee;\nuse ieee.std_logic_1164.ALL;",
80
 
81
        # build directory, where the whole synthese and build process
82
        # happens
83
        :build_dir        =>  'build',
84
 
85
        # the folder inside build_dir, where all the vhdl source is placed
86
        :hdl_dir          =>  'hdl',
87
 
88
        # synthesis directory inside build_dir
89
        :syn_dir          =>  'syn',
90
 
91
        # simulation directory inside build_dir
92
        :sim_dir          =>  'sim'
93
 
94
        } } ) )
95
  end
96
  def encoder_with( coder )
97
    coder[ 'data' ] = @data
98
  end
99
  def init_with( coder )
100
 
101
    serr_if( coder[ 'data' ] == nil,
102
      "No configuration data provided",
103
      field: 'data' )
104
    @data = coder[ 'data' ]
105
 
106
    %w[ app_name vhdl_include
107
        build_dir hdl_dir
108
        syn_dir sim_dir ].each do |d|
109
      serr_if( @data[ d.to_sym ] == nil,
110
        "Data field '#{d}' is not provided",
111
        field: 'data' )
112
 
113
      verr_if( !@data[ d.to_sym ].is_a?( String ),
114
        "Data field '#{d}' is not of type String",
115
        field: 'data' )
116
 
117
      verr_if( @data[ d.to_sym ].size == 0,
118
        "Data field '#{d}' is not of type String",
119
        field: 'data' )
120
    end
121
 
122
 
123
    @data_ro = {
124
 
125 9 feddischso
      :yaml_classes     => [  SOCMaker::CoreDef,
126
                              SOCMaker::SOCDef,
127
                              SOCMaker::IfcSpc,
128
                              SOCMaker::LibInc,
129
                              SOCMaker::Conf,
130
                              SOCMaker::CoreInst ],
131 3 feddischso
 
132
      # Regular expression, which is evaluatted to detect values like
133
      #    eval function_name
134
      # The function_name is used for further processing
135
      :eval_regex       =>  /eval +([a-zA-Z_1-9]+)/,
136
 
137
      # Regular expression to check, if it is VHDL or verilog
138
      :hdl_type_regex   => /(\bvhdl\b)|(\bverilog\b)/,
139
 
140
      #
141
      # Regular expression for vhdl file detection
142
      #
143
      :vhdl_file_regex    =>  /\A\S+\.vhd\Z/,
144
 
145
      #
146
      # Regular expression for verilog file detection
147
      #
148
      :verilog_file_regex =>  /\A\S+\.v\Z/,
149
 
150
 
151
      #
152
      # Regular expression to match names starting with non-number
153
      #
154
      :length_regex     =>  /\A[^0-9]+.*\Z/,
155
 
156
      #
157
      # Regular expression to match a component's name (core-name or SOC-name)
158 10 feddischso
      # (Obsolete)
159 3 feddischso
      #
160
      :name_regex       =>  /^[a-zA-Z]+[a-zA-Z0-9_\-]*$/,
161
 
162
 
163
      :YPP_LUT          => {
164
                /\bSOCM_CONF\b/     =>  '--- !ruby/object:SOCMaker::Conf',
165
                /\bSOCM_CORE\b/     =>  '--- !ruby/object:SOCMaker::CoreDef',
166
                /\bSOCM_SOC\b/      =>  '--- !ruby/object:SOCMaker::SOCDef',
167
                /\bSOCM_IFC_SPC\b/  =>  '--- !ruby/object:SOCMaker::IfcSpc',
168
                /\bSOCM_INCLUDE\b/  =>  '--- !ruby/object:SOCMaker::LibInc',
169
                /\bSOCM_INST\b/     =>  '!ruby/object:SOCMaker::CoreInst',
170
                /\bSOCM_IFC\b/      =>  '!ruby/object:SOCMaker::IfcDef',
171
                /\bSOCM_PORT\b/     =>  '!ruby/object:SOCMaker::IfcPort',
172
                /\bSOCM_HDL_FILE\b/ =>  '!ruby/object:SOCMaker::HDLFile',
173
                /\bSOCM_PARAM\b/    =>  '!ruby/object:SOCMaker::Parameter',
174
                /\bSOCM_SPARAM\b/   =>  '!ruby/object:SOCMaker::SParameter',
175
                /\bSOCM_SENTRY\b/   =>  '!ruby/object:SOCMaker::SParameterEntry'
176
              },
177
      #
178
      # $1 provides the white spaces
179
      # $2 the name
180
      #
181
      :YPP_INV_REGEX      => /(\s)*-{0,3}\s*!ruby\/object:SOCMaker::([a-zA-Z]+)/,
182
 
183
      :YPP_INV_LUT        => {
184
                'Conf'            => 'SOCM_CONF',
185
                'CoreDef'         => 'SOCM_CORE',
186
                'SOCDef'          => 'SOCM_SOC',
187
                'CoreInst'        => 'SOCM_INST',
188
                'IfcSpc'          => 'SOCM_IFC_SPC',
189
                'IfcDef'          => 'SOCM_IFC',
190
                'IfcPort'         => 'SOCM_PORT',
191
                'HDLFile'         => 'SOCM_HDL_FILE',
192
                'Parameter'       => 'SOCM_PARAM',
193
                'SParameter'      => 'SOCM_SPARAM',
194
                'SParameterEntry' => 'SOCM_SENTRY',
195
                'LibInc'          => 'SOCM_INCLUDE'
196
              },
197
 
198
      # used to split yaml files
199
      #
200
      :YPP_SPLIT_REGEX    => /^\s*---\s*!ruby\/(object|object):SOCMaker/,
201
 
202
 
203
      :COMMENT_REGEX      => /([^#]*)(#.*)?/,
204
 
205
      :EMPTY_CMD_REGEX    => /(\s*)(.*)/,
206
 
207
      :LIC =>
208
"""
209
Copyright (C) 2014  Christian Haettich  - feddischson [ at ] opencores.org
210
 
211
This program is free software: you can redistribute it and/or modify
212
it under the terms of the GNU General Public License as published by
213
the Free Software Foundation, either version 3 of the License, or
214
(at your option) any later version.
215
 
216
This program is distributed in the hope that it will be useful,
217
but WITHOUT ANY WARRANTY; without even the implied warranty of
218
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
219
GNU General Public License for more details.
220
 
221
You should have received a copy of the GNU General Public License
222
along with this program.  If not, see .
223
"""
224
 
225
 
226
    }
227
  end
228
 
229
  def [](y)
230
    @data.merge( @data_ro )[y]
231
  end
232
 
233
  def []=(y, value)
234
    @data[y] = value
235
  end
236
  @@inst = nil
237
 
238
 
239
end
240
 
241
end
242
 
243
 
244
# 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.