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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [ifc_port.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:      ifc_port.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
#     A small classes, used to group information
39
#     and to verify, auto-correct and auto-complete
40
#     this information:
41
#     The class represents an interface port within
42
#     SOCMaker::IfcDef (see ifc_def.rb).
43
#     It is used to make a relation between the naming
44
#     of IfcDef and IfcSpc.
45
#     The two data fiels are
46
#        - defn (mandatory: must be the name of the port, defined in IfcSpc)
47
#        - len (optional, default is 1)
48
#
49
###############
50
#
51
# TODO
52
#     - Add test-code
53
#     - Rename defn to something more meaningful
54
#
55
###############################################################
56
 
57
module SOCMaker
58
class IfcPort
59
  include ERR
60
  attr_accessor :defn
61
  attr_accessor :len
62
 
63
 
64
  def initialize( defn, len = 1 )
65
    init_with( 'defn' => defn,
66
               'len'  => len )
67
  end
68
  def encode_with( coder )
69
    %w[ defn len ].
70
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
71
  end
72
  def init_with( coder )
73
 
74
    serr_if( coder[ 'defn' ] == nil,
75
      'no relation to interface-definition is given for an interface port (nil)',
76
      field: "defn" )
77
    @defn = coder[ 'defn' ]
78
 
79
    verr_if( !@defn.is_a?( String ),
80
      'Relation to interface definition is not of type string',
81
      instance: @defn.to_s,
82
      field:    "defn")
83
 
84
    verr_if( @defn.size == 0,
85
      'Relation to interface definition has zero length',
86
      instance: @defn.to_s,
87
      field:    "defn")
88
 
89
    @len = coder[ 'len' ] || 1
90
 
91
    verr_if( !( @len.is_a?( Fixnum ) || @len.is_a?( String ) ),
92
      'Length is not a fixnum',
93
      instance: @defn.to_s,
94
      field:    "defn")
95
  end
96
 
97
 
98
  def verify
99
  end
100
 
101
  def ==(o)
102
    o.class  == self.class   &&
103
    o.defn   == self.defn    &&
104
    o.len    == self.len
105
  end
106
 
107
 
108
end
109
end

powered by: WebSVN 2.1.0

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