Class: Rhdl::ComponentDsl

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topdsl) ⇒ ComponentDsl

Returns a new instance of ComponentDsl.



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

def initialize(topdsl)
  @topdsl = topdsl
  @inputs = {}
  @outputs = {}
  @wires = {}
  @comb_block_dsl = nil
end

Instance Attribute Details

#comb_block_dslObject (readonly)

Returns the value of attribute comb_block_dsl.



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

def comb_block_dsl
  @comb_block_dsl
end

#inputsObject (readonly)

Returns the value of attribute inputs.



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

def inputs
  @inputs
end

#outputsObject (readonly)

Returns the value of attribute outputs.



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

def outputs
  @outputs
end

#wiresObject (readonly)

Returns the value of attribute wires.



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

def wires
  @wires
end

Instance Method Details

#comb(&block) ⇒ Object



25
26
27
28
29
30
# File 'lib/rhdl/component_dsl.rb', line 25

def comb(&block)
  raise "Combinational block already defined" if !@comb_block_dsl.nil?
  
  @comb_block_dsl = BlockDsl.new
  @comb_block_dsl.instance_eval(&block)
end

#input(name, bits: 1, type: "uint") ⇒ Object



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

def input(name, bits: 1, type: "uint")
  @inputs[name] = NodeStatement.new('input', name, bits: bits, type: type)
end

#output(name, bits: 1, type: "uint") ⇒ Object



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

def output(name, bits: 1, type: "uint")
  @outputs[name] = NodeStatement.new('output', name, bits: bits, type: type)
end

#wire(name, bits: 1, type: "uint") ⇒ Object



21
22
23
# File 'lib/rhdl/component_dsl.rb', line 21

def wire(name, bits: 1, type: "uint")
  @wires[name] = NodeStatement.new('wire', name, bits: bits, type: type)
end