Class: RubyHDL::High::SblockTop

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes a SW implementation of the top block. It cannot contain any statement, but can register objects.

Direct Known Subclasses

Sblock

Instance Method Summary collapse

Constructor Details

#initializeSblockTop

Create a new top block.



41
42
43
44
45
46
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 41

def initialize
  # Initialize the table of callable procs from outside.
  @callables = { }
  # Initialize the list of signals declared in this block.
  @signals = []
end

Instance Method Details

#callable(m, *args, &ruby_block) ⇒ Object

Call a method from there.



87
88
89
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 87

def callable(m,*args,&ruby_block)
  return @callables[m].call(*args,&ruby_block)
end

#callable?(m) ⇒ Boolean

Tell if a method is callable from there.

Returns:

  • (Boolean)


82
83
84
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 82

def callable?(m)
  return @callables.key?(m)
end

#each_signal(&ruby_block) ⇒ Object

Iterate on the signal declared in the block.



92
93
94
95
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 92

def each_signal(&ruby_block)
  return to_enum(:each_signal) unless ruby_block
  @signals.each(&ruby_block)
end

#make_inners(type, *names) ⇒ Object

Generate inner signals with type +type+ and names from +names+ list.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 54

def make_inners(type,*names)
  type = type.to_type
  last_sig = nil
  names.each do |name|
    name = name.to_sym
    # Create and add the signal.
    sig = SignalI.new(type,name)
    @signals << sig
    # Register it.
    self.register(name) { sig }
    last_sig = sig
  end
  return last_sig
end

#register(name, &ruby_block) ⇒ Object

Register a new object named +name+ generated by +ruby_block+.



70
71
72
73
74
75
76
77
78
79
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 70

def register(name,&ruby_block)
  # Add a way to call it from the stack of SW blocks.
  ::Object.define_method(name) do
    RubyHDL::High.call_sblock(name)
  end
  # Add a method for accessing the object.
  # self.define_singleton_method(name,&ruby_block)
  res = ruby_block.call
  @callables[name] = ruby_block
end

#sequencerObject

The sequencer of the block: none since top Sblock for globals.



49
50
51
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 49

def sequencer
  nil
end