Class: Rhdl::BinOp

Inherits:
Expression show all
Defined in:
lib/rhdl/bin_op.rb

Instance Method Summary collapse

Methods inherited from Expression

#!, #&

Constructor Details

#initialize(lhs, rhs, op) ⇒ BinOp

Returns a new instance of BinOp.



3
4
5
6
7
# File 'lib/rhdl/bin_op.rb', line 3

def initialize(lhs, rhs, op)
  @lhs = lhs
  @rhs = rhs
  @op = op
end

Instance Method Details

#fanout(check_context, statement) ⇒ Object



17
18
19
20
# File 'lib/rhdl/bin_op.rb', line 17

def fanout(check_context, statement)
  @lhs.fanout(check_context, statement)
  @rhs.fanout(check_context, statement)
end

#generateObject



13
14
15
# File 'lib/rhdl/bin_op.rb', line 13

def generate
  "(#{@lhs.generate} #{@op} #{@rhs.generate})"
end

#get_output_type(check_context) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rhdl/bin_op.rb', line 22

def get_output_type(check_context)
  ltype = @lhs.get_output_type(check_context)
  rtype = @rhs.get_output_type(check_context)
  if @op == "&"
  
    if ltype.to_s != "uint_1" ||
       rtype.to_s != "uint_1"
       raise "& does not support types #{ltype} and #{rtype}"
    end
  
    return ltype
  else
    raise "unknown operation '#{op}'"
  end
end

#varnamesObject



9
10
11
# File 'lib/rhdl/bin_op.rb', line 9

def varnames
  @lhs.varnames + @rhs.varnames
end