Module: HDLRuby::High::Std::HchannelI

Included in:
ChannelB, ChannelI
Defined in:
lib/HDLRuby/std/channel.rb

Overview

Module giving the methods for accessing a channel instance.

Instance Method Summary collapse

Instance Method Details

#read(*args, &ruby_block) ⇒ Object

Performs a read on the channel using +args+ and +ruby_block+ as arguments. NOTE:

  • Will generate a port if not present.
  • Will generate an error if a read is tempted while the read port has been declared within another system.


337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/HDLRuby/std/channel.rb', line 337

def read(*args,&ruby_block)
    # Is there a port to read?
    unless self.read_port then
        # No, generate a new one.
        # Is it possible to be inout?
        if self.inout? then
            # Yes, create an inout port.
            self.inout(HDLRuby.uniq_name)
        else
            # No, create an input port.
            self.input(HDLRuby.uniq_name)
        end
    end
    # Ensure the read port is within current system.
    unless self.read_port.scope.system != HDLRuby::High.cur_system then
        raise "Cannot read from a port external of current system for channel " + self.name
    end
    # Performs the read.
    self.read_port.read(*args,&ruby_block)
end

#reset(*args, &ruby_block) ⇒ Object

Performs a reset on the channel using +args+ and +ruby_block+ as arguments.



388
389
390
391
392
393
394
395
396
397
398
# File 'lib/HDLRuby/std/channel.rb', line 388

def reset(*args,&ruby_block)
    # Gain access to the writer as local variable.
    reseter_proc = @inout_reseter_proc
    # # The context is the one of the writer.
    # Execute the code generating the writer in context.
    HDLRuby::High.space_push(@namespace)
    HDLRuby::High.cur_block.open do
        instance_exec(ruby_block,*args,&reseter_proc)
    end
    HDLRuby::High.space_pop
end

#wrap(*args) ⇒ Object

Wrap with +args+ arguments.



402
403
404
# File 'lib/HDLRuby/std/channel.rb', line 402

def wrap(*args)
    return ChannelB.new(self,*args)
end

#write(*args, &ruby_block) ⇒ Object

Performs a write on the channel using +args+ and +ruby_block+ as arguments. NOTE:

  • Will generate a port if not present.
  • Will generate an error if a read is tempted while the read port has been declared within another system.


364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/HDLRuby/std/channel.rb', line 364

def write(*args,&ruby_block)
    # Is there a port to write?
    unless self.write_port then
        # No, generate a new one.
        # Is it possible to be inout?
        if self.inout? then
            # Yes, create an inout port.
            self.inout(HDLRuby.uniq_name)
        else
            # No, create an output port.
            self.output(HDLRuby.uniq_name)
        end
    end
    # Ensure the write port is within current system.
    unless self.write_port.scope.system != HDLRuby::High.cur_system then
        raise "Cannot write from a port external of current system for channel " + self.name
    end
    # Performs the write.
    self.write_port.write(*args,&ruby_block)
end