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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [core_def.rb] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      core_def.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
########
38
#
39
# TODO
40
#
41
#
42
###############################################################
43
 
44
 
45
module SOCMaker
46 9 feddischso
 
47
 
48
#########
49
#
50
# This class represents a core definition.
51
# It is one of the central classes and holds data,
52
# which is used to describe and instanciate this core.
53
# In general, instances of this class desribe a core,
54
# it's interface and parameters as well as the files,
55
# which are required for synthesis/simulation.
56
#
57
# In addition to this core, there exist SOCMaker::CoreInst,
58
# which represents a concret instanciation of a definition.
59
#
60 3 feddischso
class CoreDef  < Component
61
  include ERR
62
  include YAML_EXT
63
 
64
  attr_accessor :hdlfiles
65 9 feddischso
 
66
 
67
  def initialize( name, version, hdl_files, toplevel, optional = {} )
68 3 feddischso
    init_with( { 'name'      => name,
69
                 'version'   => version,
70
                 'hdlfiles'  => hdl_files,
71 9 feddischso
                 'toplevel'  => toplevel }.merge( optional ) )
72 3 feddischso
  end
73
  def encode_with( coder )
74
    super coder
75
    coder[ 'hdlfiles' ] = @hdlfiles
76
  end
77
  def init_with( coder )
78
    super( coder )
79
 
80 8 feddischso
    @hdlfiles = coder[ 'hdlfiles' ] || {}
81 3 feddischso
    serr_if( !@hdlfiles.is_a?( Hash ),
82
      'HDL file def. != Hash',
83
      instance: @name,
84
      field:    'hdlfiles' )
85
 
86
    @hdlfiles.each do |file_name, defn |
87
      serr_if( defn == nil,
88
            'HDL file not defined',
89
            instance:   @name+":"+file_name.to_s )
90
 
91
      serr_if( !defn.is_a?( SOCMaker::HDLFile ),
92
            'HDL file not SOCMaker::HDLFile (use SOCM_HDL_FILE)',
93
            instance: @name+":"+file_name.to_s )
94
    end
95
 
96
  end
97
 
98
 
99
 
100
 
101
 
102
  def generics
103
    @inst_parameters.each_with_index do |(name, val), i|
104
      yield( name.to_s, val.type, val.default, i == @inst_parameters.size-1 )
105
    end
106
  end
107
 
108
 
109
 
110 6 feddischso
  # this is a core_def and doesn't have
111
  # sub-cores
112
  def get_core_def( inst )
113
    return nil
114
  end
115 3 feddischso
 
116 7 feddischso
  def consistency_check
117 8 feddischso
    super
118 7 feddischso
  end
119 6 feddischso
 
120 7 feddischso
 
121 3 feddischso
  def param_ok?( param_name, param_value )
122
    param = inst_parameters[ param_name.to_sym ]
123
    param = static_parameters[ param_name.to_sym ] if param == nil
124
    return false if param == nil
125
  end
126
 
127
 
128
  def ==(o)
129
    o.class         == self.class       &&
130
    o.hdlfiles      == self.hdlfiles    &&
131
    super( o )
132
  end
133
 
134
 
135
end # class CoreDef
136
end # module SOCMaker
137
 
138
 
139
# 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.