Class: Rhdl::Component

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

Instance Method Summary collapse

Constructor Details

#initialize(name, topdsl, theproc) ⇒ Component

Returns a new instance of Component.



3
4
5
6
7
8
9
10
11
12
# File 'lib/rhdl/component.rb', line 3

def initialize(name, topdsl, theproc)
  @name = name
  @topdsl = topdsl
  @proc = theproc
  @component_dsl = nil
  @inputs = []
  @outputs = []
  @wires = []
  @comb_block_dsl = []
end

Instance Method Details

#check!(component_dsl) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rhdl/component.rb', line 66

def check!(component_dsl)
  cc = CheckContext.new
  component_dsl.inputs.each do |k,v|
    cc.add_input_variable(k, v)
  end
  
  component_dsl.outputs.each do |k,v|
    cc.add_output_variable(k, v)
  end
  
  component_dsl.wires.each do |k,v|
    cc.add_wire_variable(k, v)
  end
  
  
  component_dsl.comb_block_dsl.statements.each do |s|
    s.check!(cc)
  end

  cc.fanout_check!
end

#comb_block_dslObject



32
33
34
35
36
# File 'lib/rhdl/component.rb', line 32

def comb_block_dsl
  implement!
  
  @comb_block_dsl
end

#implement!Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rhdl/component.rb', line 38

def implement!
  return unless @component_dsl.nil?
  
  component_dsl = ComponentDsl.new(@topdsl)
  component_dsl.instance_eval(&@proc)
  
  @inputs = []
  component_dsl.inputs.each do |k,v|
    @inputs << v
  end
  
  @outputs = []
  component_dsl.outputs.each do |k,v|
    @outputs << v
  end
  
  @wires = []
  component_dsl.wires.each do |k,v|
    @wires << v
  end
  
  @comb_block_dsl = component_dsl.comb_block_dsl
  
  check!(component_dsl)
  
  @component_dsl = component_dsl
end

#inputsObject



14
15
16
17
18
# File 'lib/rhdl/component.rb', line 14

def inputs
  implement!
  
  @inputs
end

#outputsObject



20
21
22
23
24
# File 'lib/rhdl/component.rb', line 20

def outputs
  implement!
  
  @outputs
end

#wiresObject



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

def wires
  implement!
  
  @wires
end