Class: HDLRuby::High::SignalI

Inherits:
Low::SignalI show all
Includes:
HRef
Defined in:
lib/HDLRuby/hruby_high.rb

Overview

Describes a high-level signal.

Constant Summary collapse

High =
HDLRuby::High
DIRS =

The valid bounding directions.

[ :no, :input, :output, :inout, :inner ]

Constants included from Low::Low2Symbol

Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes inherited from Low::SignalI

#name, #type, #value

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods included from HRef

#each, included, #to_event

Methods inherited from Low::SignalI

#clone, #eql?, #explicit_types!, #hash, #replace_names!, #set_name!, #set_type!, #set_value!, #to_c, #to_c_signal, #to_ch, #to_high, #to_verilog, #to_vhdl, #width

Methods included from Low::Low2Symbol

#to_sym

Constructor Details

#initialize(name, type, dir, value = nil) ⇒ SignalI

Creates a new signal named +name+ typed as +type+ with +dir+ as bounding direction and possible +value+.

NOTE: +dir+ can be :input, :output, :inout or :inner



2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
# File 'lib/HDLRuby/hruby_high.rb', line 2866

def initialize(name,type,dir,value =  nil)
    # Check the value.
    value = value.to_expr if value
    # Initialize the type structure.
    super(name,type,value)

    unless name.empty? then
        # Named signal, set the hdl-like access to the signal.
        obj = self # For using the right self within the proc
        High.space_reg(name) { obj }
    end

    # Hierarchical type allows access to sub references, so generate
    # the corresponding methods.
    if type.struct? then
        type.each_name do |name|
            self.define_singleton_method(name) do
                RefObject.new(self.to_ref,
                            SignalI.new(name,type.get_type(name),dir))
            end
        end
    end

    # Check and set the bound.
    self.dir = dir

    # Set the read and write authorisations.
    @can_read = 1.to_expr
    @can_write = 1.to_expr
end

Instance Attribute Details

#can_readObject

Tells if the signal can be read.



2857
2858
2859
# File 'lib/HDLRuby/hruby_high.rb', line 2857

def can_read
  @can_read
end

#can_writeObject

Tells if the signal can be written.



2860
2861
2862
# File 'lib/HDLRuby/hruby_high.rb', line 2860

def can_write
  @can_write
end

#dirObject

The bounding direction.



2854
2855
2856
# File 'lib/HDLRuby/hruby_high.rb', line 2854

def dir
  @dir
end

Instance Method Details

#coerce(obj) ⇒ Object

Coerce by converting signal to an expression.



2941
2942
2943
# File 'lib/HDLRuby/hruby_high.rb', line 2941

def coerce(obj)
    return [obj,self.to_expr]
end

#edgeObject

Creates an edge event from the signal.



2926
2927
2928
# File 'lib/HDLRuby/hruby_high.rb', line 2926

def edge
    return Event.new(:edge,self.to_ref)
end

#negedgeObject

Creates a negative edge event from the signal.



2921
2922
2923
# File 'lib/HDLRuby/hruby_high.rb', line 2921

def negedge
    return Event.new(:negedge,self.to_ref)
end

#posedgeObject

Creates a positive edge event from the signal.



2916
2917
2918
# File 'lib/HDLRuby/hruby_high.rb', line 2916

def posedge
    return Event.new(:posedge,self.to_ref)
end

#to_exprObject

Converts to a new expression.



2936
2937
2938
# File 'lib/HDLRuby/hruby_high.rb', line 2936

def to_expr
    return self.to_ref
end

#to_low(name = self.name) ⇒ Object

Converts the system to HDLRuby::Low and set its +name+.



2946
2947
2948
# File 'lib/HDLRuby/hruby_high.rb', line 2946

def to_low(name = self.name)
    return HDLRuby::Low::SignalI.new(name,self.type.to_low)
end

#to_refObject

Converts to a new reference.



2931
2932
2933
# File 'lib/HDLRuby/hruby_high.rb', line 2931

def to_ref
    return RefObject.new(this,self)
end