Class: Rhdl::NodeStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/rhdl/node_statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptype, name, bits:, type:) ⇒ NodeStatement

Returns a new instance of NodeStatement.



5
6
7
8
9
10
# File 'lib/rhdl/node_statement.rb', line 5

def initialize(ptype ,name, bits:, type:)
  @ptype = ptype
  @name = name
  @bits = bits
  @type = type
end

Instance Attribute Details

#bitsObject (readonly)

Returns the value of attribute bits.



3
4
5
# File 'lib/rhdl/node_statement.rb', line 3

def bits
  @bits
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rhdl/node_statement.rb', line 3

def name
  @name
end

#ptypeObject (readonly)

Returns the value of attribute ptype.



3
4
5
# File 'lib/rhdl/node_statement.rb', line 3

def ptype
  @ptype
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/rhdl/node_statement.rb', line 3

def type
  @type
end

Instance Method Details

#bittermObject



29
30
31
32
33
34
35
# File 'lib/rhdl/node_statement.rb', line 29

def bitterm
  if bits == 1
    nil
  else
    "[#{bits-1}:0]"
  end
end

#generate_termsObject



20
21
22
23
24
25
26
# File 'lib/rhdl/node_statement.rb', line 20

def generate_terms
  {
    keyword: theptype,
    bitterm: bitterm,
    name:    name
  }
end

#theptypeObject



12
13
14
15
16
17
18
# File 'lib/rhdl/node_statement.rb', line 12

def theptype
  if @ptype == 'input'
    "input wire"
  else
    "output reg"
  end
end