class VerilogGen::Pin

Model of a pin connected to a port

Attributes

direction[R]
lhs[R]
name[R]
port[R]
rhs[R]
type[R]

Public Class Methods

new(port) click to toggle source

A pin connects to a port. @note By default the pin name, type and width is the same as port.

# File lib/verilog_gen/pin.rb, line 9
def initialize(port)
  @port = port
  @name = port.name
  @type = port.type
  @lhs = port.lhs 
  @rhs = port.rhs 
  @direction = port.direction
end

Public Instance Methods

connect(pin_name, params = {}) click to toggle source

Update a pin attributes. @param [String] name of the pin @param [Hash] params properties of pin @option params [String] :name of the pin @option params [String] :type of the pin @option params [Fixnum] :lhs left hand width of the pin @option params [Fixnum] :rhs right hand width of the pin @option params [String] :direction of the pin

# File lib/verilog_gen/pin.rb, line 26
def connect(pin_name, params = {})
  @name = pin_name
  params.each do |key, value|
    raise ArgumentError, "Unknown attribute '#{key}' specified for pin" \
          unless instance_variables.include?("@#{key}".to_sym)
    instance_variable_set("@#{key}", value)
  end
end
width() click to toggle source
# File lib/verilog_gen/pin.rb, line 35
def width
  (@lhs - @rhs + 1).abs
 end