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, #each_deep, #eql?, #explicit_types!, #hash, #immutable?, #replace_names!, #set_name!, #set_type!, #set_value!, #to_c, #to_c_signal, #to_ch, #to_hdr, #to_high, #to_verilog, #to_vhdl, #width

Methods included from Low::Low2Symbol

#to_sym

Methods included from Low::Hparent

#hierarchy, #scope

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



3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
# File 'lib/HDLRuby/hruby_high.rb', line 3417

def initialize(name,type,dir,value =  nil)
    # Check the value.
    value = value.to_expr.match_type(type) 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.



3408
3409
3410
# File 'lib/HDLRuby/hruby_high.rb', line 3408

def can_read
  @can_read
end

#can_writeObject

Tells if the signal can be written.



3411
3412
3413
# File 'lib/HDLRuby/hruby_high.rb', line 3411

def can_write
  @can_write
end

#dirObject

The bounding direction.



3405
3406
3407
# File 'lib/HDLRuby/hruby_high.rb', line 3405

def dir
  @dir
end

Instance Method Details

#coerce(obj) ⇒ Object

Coerce by converting signal to an expression.



3492
3493
3494
# File 'lib/HDLRuby/hruby_high.rb', line 3492

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

#edgeObject

Creates an edge event from the signal.



3477
3478
3479
# File 'lib/HDLRuby/hruby_high.rb', line 3477

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

#negedgeObject

Creates a negative edge event from the signal.



3472
3473
3474
# File 'lib/HDLRuby/hruby_high.rb', line 3472

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

#posedgeObject

Creates a positive edge event from the signal.



3467
3468
3469
# File 'lib/HDLRuby/hruby_high.rb', line 3467

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

#to_exprObject

Converts to a new expression.



3487
3488
3489
# File 'lib/HDLRuby/hruby_high.rb', line 3487

def to_expr
    return self.to_ref
end

#to_low(name = self.name) ⇒ Object

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



3497
3498
3499
3500
3501
3502
3503
3504
# File 'lib/HDLRuby/hruby_high.rb', line 3497

def to_low(name = self.name)
    # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
    signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
    # # For debugging: set the source high object 
    # signalIL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = signalIL
    return signalIL
end

#to_refObject

Converts to a new reference.



3482
3483
3484
# File 'lib/HDLRuby/hruby_high.rb', line 3482

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