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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [ifc_spc.rb] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      if_spec.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
#
40
###############################################################
41
module SOCMaker
42
class IfcSpc
43
  include ERR
44
  include YAML_EXT
45
 
46
  attr_accessor :name
47
  attr_accessor :version
48
  attr_accessor :ports
49
 
50
  def initialize( name, version, options = {} )
51
    init_with( { 'name' => name,
52
                 'version' => version }.merge( options ) )
53
  end
54
  def encode_with( coder )
55
    %w[ name version ports ].
56
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
57
  end
58
  def init_with( coder )
59
 
60
    verr_if( coder[ 'name' ] == nil,
61
      "Name is not defined",
62
      field: "name" )
63
    @name = coder[ 'name' ]
64
    verr_if( !@name.is_a?( String ),
65
        "Name is not defined as string",
66
        field: "name" )
67
    verr_if( @name.size == 0,
68
        "Name has zero length",
69
        field: "name" )
70
 
71
 
72
    verr_if( coder[ 'version' ] == nil,
73
      "Version is not defined",
74
      field: "version" )
75
    @version = coder[ 'version' ]
76
    verr_if( !@version.is_a?( String ),
77
        "Version is not defined as string",
78
      instance: @name,
79
      field:    "version" )
80
    verr_if( @version.size == 0,
81
        "Version has zero length",
82
        field: "name" )
83
 
84
    @ports = coder[ 'ports' ] || {}
85
    @ports.each do |pname, port_dir|
86
      verr_if( !port_dir.is_a?( Fixnum ) ||
87
               ( port_dir != 0 && port_dir != 1 ),
88
        "Port direction value is neither 0 nor 1",
89
        instance: @name,
90
        field:    "ports" )
91
    end
92
 
93
  end
94
  def verify
95
  end
96
 
97
 
98
end
99
end
100
 
101
 
102
# 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.