Class: RubyHDL::High::SblockTop
- Inherits:
-
Object
- Object
- RubyHDL::High::SblockTop
- 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
Instance Method Summary collapse
-
#callable(m, *args, &ruby_block) ⇒ Object
Call a method from there.
-
#callable?(m) ⇒ Boolean
Tell if a method is callable from there.
-
#each_signal(&ruby_block) ⇒ Object
Iterate on the signal declared in the block.
-
#initialize ⇒ SblockTop
constructor
Create a new top block.
-
#make_inners(type, *names) ⇒ Object
Generate inner signals with type +type+ and names from +names+ list.
-
#make_inputs(type, *names) ⇒ Object
Generate input signals with type +type+ and names from +names+ list.
-
#make_outputs(type, *names) ⇒ Object
Generate output signals with type +type+ and names from +names+ list.
-
#register(name, &ruby_block) ⇒ Object
Register a new object named +name+ generated by +ruby_block+.
-
#sequencer ⇒ Object
The sequencer of the block: none since top Sblock for globals.
Constructor Details
#initialize ⇒ SblockTop
Create a new top block.
45 46 47 48 49 50 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 45 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.
129 130 131 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 129 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.
124 125 126 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 124 def callable?(m) return @callables.key?(m) end |
#each_signal(&ruby_block) ⇒ Object
Iterate on the signal declared in the block.
134 135 136 137 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 134 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.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 94 def make_inners(type,*names) # puts "make_inners with names=#{names.join(",")}" type = type.to_type last_sig = nil names.each do |name| name = name.to_sym # Create and add the signal. sig = SignalI.new(name,type,:inner) @signals << sig # Register it. # self.register(name) { puts("sig=",sig.inspect); sig } self.register(name) { sig } last_sig = sig end return last_sig end |
#make_inputs(type, *names) ⇒ Object
Generate input signals with type +type+ and names from +names+ list.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 58 def make_inputs(type,*names) # puts "make_inputs with names=#{names.join(",")}" type = type.to_type last_sig = nil names.each do |name| name = name.to_sym # Create and add the signal. sig = SignalI.new(name,type,:input) @signals << sig # Register it. # self.register(name) { puts("sig=",sig.inspect); sig } self.register(name) { sig } last_sig = sig end return last_sig end |
#make_outputs(type, *names) ⇒ Object
Generate output signals with type +type+ and names from +names+ list.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 76 def make_outputs(type,*names) # puts "make_outputs with names=#{names.join(",")}" type = type.to_type last_sig = nil names.each do |name| name = name.to_sym # Create and add the signal. sig = SignalI.new(name,type,:output) @signals << sig # Register it. # self.register(name) { puts("sig=",sig.inspect); sig } 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+.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 112 def register(name,&ruby_block) # Add a way to call it from the stack of SW blocks. ::Object.define_method(name) do |*args| RubyHDL::High.call_sblock(name,*args) end # Add a method for accessing the object. # self.define_singleton_method(name,&ruby_block) # res = ruby_block.call @callables[name] = ruby_block end |
#sequencer ⇒ Object
The sequencer of the block: none since top Sblock for globals.
53 54 55 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 53 def sequencer nil end |