Class: RubyRTL::Sig

Inherits:
Ast
  • Object
show all
Defined in:
lib/ruby_rtl/ast.rb,
lib/ruby_rtl/dsl.rb

Overview

further defined in dsl.rb attributes :

  • type

  • subscript_of

Direct Known Subclasses

Indexed, Port

Instance Attribute Summary collapse

Attributes inherited from Ast

#comments

Instance Method Summary collapse

Methods inherited from Ast

#accept

Constructor Details

#initialize(name, type = :bit) ⇒ Sig

Returns a new instance of Sig.



57
58
59
60
# File 'lib/ruby_rtl/dsl.rb', line 57

def initialize name,type=:bit
  @name=name
  @type=build_type(type)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



52
53
54
# File 'lib/ruby_rtl/dsl.rb', line 52

def name
  @name
end

#subscript_ofObject

Returns the value of attribute subscript_of.



54
55
56
# File 'lib/ruby_rtl/dsl.rb', line 54

def subscript_of
  @subscript_of
end

#subsignalsObject

Returns the value of attribute subsignals.



55
56
57
# File 'lib/ruby_rtl/dsl.rb', line 55

def subsignals
  @subsignals
end

#typeObject

Returns the value of attribute type.



53
54
55
# File 'lib/ruby_rtl/dsl.rb', line 53

def type
  @type
end

Instance Method Details

#!=(other) ⇒ Object



138
139
140
141
# File 'lib/ruby_rtl/dsl.rb', line 138

def !=(other)
  other=treat_int(other)
  Binary.new(self,"!=",other)
end

#!@Object

unary expressions



144
145
146
# File 'lib/ruby_rtl/dsl.rb', line 144

def !@
  Unary.new("!",self)
end

#&(other) ⇒ Object



82
83
84
85
# File 'lib/ruby_rtl/dsl.rb', line 82

def &(other)
  other=treat_int(other)
  Binary.new(self,"&",other)
end

#*(other) ⇒ Object



128
129
130
131
# File 'lib/ruby_rtl/dsl.rb', line 128

def *(other)
  other=treat_int(other)
  Binary.new(self,"*",other)
end

#+(other) ⇒ Object

arith



118
119
120
121
# File 'lib/ruby_rtl/dsl.rb', line 118

def +(other)
  other=treat_int(other)
  Binary.new(self,"+",other)
end

#-(other) ⇒ Object



123
124
125
126
# File 'lib/ruby_rtl/dsl.rb', line 123

def -(other)
  other=treat_int(other)
  Binary.new(self,"-",other)
end

#-@Object



148
149
150
# File 'lib/ruby_rtl/dsl.rb', line 148

def -@
  Unary.new("-",self)
end

#/(other) ⇒ Object



133
134
135
136
# File 'lib/ruby_rtl/dsl.rb', line 133

def /(other)
  other=treat_int(other)
  Binary.new(self,"/",other)
end

#<(other) ⇒ Object

comparison



93
94
95
96
# File 'lib/ruby_rtl/dsl.rb', line 93

def <(other)
  other=treat_int(other)
  Binary.new(self,"<",other)
end

#<=(other) ⇒ Object



98
99
100
101
# File 'lib/ruby_rtl/dsl.rb', line 98

def <=(other)
  other=treat_int(other)
  Binary.new(self,"<=",other)
end

#==(other) ⇒ Object



113
114
115
116
# File 'lib/ruby_rtl/dsl.rb', line 113

def ==(other)
  other=treat_int(other)
  Binary.new(self,"==",other)
end

#>(other) ⇒ Object



103
104
105
106
# File 'lib/ruby_rtl/dsl.rb', line 103

def >(other)
  other=treat_int(other)
  Binary.new(self,"<",other)
end

#>=(other) ⇒ Object



108
109
110
111
# File 'lib/ruby_rtl/dsl.rb', line 108

def >=(other)
  other=treat_int(other)
  Binary.new(self,"<=",other)
end

#[](index) ⇒ Object



152
153
154
155
156
# File 'lib/ruby_rtl/dsl.rb', line 152

def [](index)
  @indexed||={}
  index=treat_int(index)
  @indexed[index.to_s]||=Indexed.new(self,index,@type.type)
end

#^(other) ⇒ Object



87
88
89
90
# File 'lib/ruby_rtl/dsl.rb', line 87

def ^(other)
  other=treat_int(other)
  Binary.new(self,"^",other)
end

#coerce(other) ⇒ Object



158
159
160
# File 'lib/ruby_rtl/dsl.rb', line 158

def coerce(other)
  [IntLit.new(other), self]
end

#treat_int(other) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ruby_rtl/dsl.rb', line 62

def treat_int(other)
  case other
  when Integer
    if other >=0
      #return UIntLit.new(other)
      return RUIntLit.new(other)
    else
      #return IntLit.new(other)
      return RIntLit.new(other)
    end
  else
    return other
  end
end

#|(other) ⇒ Object



77
78
79
80
# File 'lib/ruby_rtl/dsl.rb', line 77

def |(other)
  other=treat_int(other)
  Binary.new(self,"|",other)
end