Class: VerilogParser::Module

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-vpi/verilog_parser.rb

Defined Under Namespace

Classes: Port

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aDecl, aBody) ⇒ Module

Returns a new instance of Module.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ruby-vpi/verilog_parser.rb', line 29

def initialize aDecl, aBody
  @decl = aDecl.strip
  @body = aBody

  @decl =~ %r{module\s+(\w+)\s*(?:\#\(.*?\))?\s*(?:\((.*?)\))?\s*;}m
  @name, portDecls = $1, $2.to_s

  @ports        = portDecls.split(',').map {|decl| Port.new decl, self}
  @input_ports  = @ports.select {|p| p.input?}
  @output_ports = @ports.select {|p| p.output?}

  @clock_port   = @ports.find {|p| p.name =~ /clock|clo?c?k/i}
  @reset_port   = @ports.find {|p| p.name =~ /reset|re?se?t/i}
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def body
  @body
end

#clock_portObject (readonly)

Returns the value of attribute clock_port.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def clock_port
  @clock_port
end

#declObject (readonly)

Returns the value of attribute decl.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def decl
  @decl
end

#input_portsObject (readonly)

Returns the value of attribute input_ports.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def input_ports
  @input_ports
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def name
  @name
end

#output_portsObject (readonly)

Returns the value of attribute output_ports.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def output_ports
  @output_ports
end

#portsObject (readonly)

Returns the value of attribute ports.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def ports
  @ports
end

#reset_portObject (readonly)

Returns the value of attribute reset_port.



25
26
27
# File 'lib/ruby-vpi/verilog_parser.rb', line 25

def reset_port
  @reset_port
end