Sha256: 4ca4d4149365c693dc2839ab3b3c9640f9e4831736bcad41091fc5e5b9742772

Contents?: true

Size: 948 Bytes

Versions: 3

Compression:

Stored size: 948 Bytes

Contents

module OrigenVerilog
  class TopLevel
    include Origen::TopLevel

    attr_reader :name

    def initialize(options = {})
      @name = options[:ast].to_a[0]

      options[:ast].pins(digital: true).each { |n| _add_pin_(n, :digital) }
      options[:ast].pins(analog: true).each { |n| _add_pin_(n, :analog) }
    end

    private

    def _add_pin_(node, type)
      node = node.evaluate  # Resolve any functions in the ranges
      if node.type == :input_declaration
        direction = :input
      elsif node.type == :ouput_declaration
        direction = :output
      else
        direction = :io
      end
      if r = node.find(:range)
        size = r.to_a[0] - r.to_a[1] + 1
        offset = r.to_a[1]
      else
        size = 1
        offset = nil
      end
      n = node.to_a.dup
      while n.last.is_a?(String)
        add_pin n.pop.to_sym, direction: direction, size: size, offset: offset, type: type
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
origen_verilog-0.6.2 lib/origen_verilog/top_level.rb
origen_verilog-0.6.1 lib/origen_verilog/top_level.rb
origen_verilog-0.6.0 lib/origen_verilog/top_level.rb