class BlifUtils::Netlist::Latch

Attributes

ctrlSig[R]
ctrlType[R]
initValue[R]
input[RW]
output[RW]

Public Class Methods

new(input, output, initValue, ctrlType = :re, ctrlSig = nil) click to toggle source
# File lib/blifutils/netlist.rb, line 153
def initialize (input, output, initValue, ctrlType = :re, ctrlSig = nil)
        @input = input
        @output = output
        @initValue = initValue
        @ctrlType = ctrlType
        @ctrlSig = ctrlSig
end

Public Instance Methods

inputs() click to toggle source
# File lib/blifutils/netlist.rb, line 183
def inputs
        return [@input]
end
name() click to toggle source
# File lib/blifutils/netlist.rb, line 188
def name
        return @output.name
end
set_clock(net_or_name) click to toggle source
# File lib/blifutils/netlist.rb, line 204
def set_clock (net_or_name)
        @ctrlSig = net_or_name
end
set_initial_value(value) click to toggle source
# File lib/blifutils/netlist.rb, line 209
def set_initial_value (value)
        raise "Initial value must be an integer in the range 0..3" unless (value.kind_of?(Integer) and value >= 0 and value <= 3)
        @initValue = value
end
set_type(type) click to toggle source
# File lib/blifutils/netlist.rb, line 198
def set_type (type)
        raise "Type must be one of [nil, :fe, :re, :ah, :al, :as]" unless [nil, :fe, :re, :ah, :al, :as].include?(type)
        @ctrlType = type
end
to_blif() click to toggle source
# File lib/blifutils/netlist.rb, line 162
def to_blif
        res  = ".latch #{@input.name} #{@output.name}"
        if @ctrlType
                res += " #{@ctrlType} "
                if @ctrlSig.nil?
                        res += "NIL"
                elsif @ctrlSig.kind_of?(BlifUtils::Netlist::Net)
                        res += @ctrlSig.name
                else
                        res += @ctrlSig
                end
        end
        if @initValue
                res += " #{@initValue} "
        end
        res += "\n"

        return res
end
to_s() click to toggle source
# File lib/blifutils/netlist.rb, line 193
def to_s
        return "Latch \"#{@output.name}\""
end