Class: HDLRuby::High::Std::ArbiterT
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::ArbiterT
- Defined in:
- lib/HDLRuby/std/sequencer_sync.rb
Overview
Describes an arbiter for a shared signal.
Direct Known Subclasses
Instance Method Summary collapse
-
#<=(val) ⇒ Object
Arbiter access code generation: 1 for acquire and 0 for release.
-
#add_point ⇒ Object
Adds an access point.
-
#call(*sigs) ⇒ Object
Adds the signals.
-
#initialize(name, *sigs) ⇒ ArbiterT
constructor
Create a new arbitrer named +name+ for shared signals +sigs+.
-
#select(point) ⇒ Object
Shared signal selection code generation.
Constructor Details
#initialize(name, *sigs) ⇒ ArbiterT
Create a new arbitrer named +name+ for shared signals +sigs+.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 128 def initialize(name,*sigs) # Sets the name. name = name.to_sym @name = name # Register the signals. @signals = [] # Adds the signals. self.(*sigs) # Create the set of access points. @size = 0 @points = {} # Create the acquire/release bit vector. acquires = nil HDLRuby::High.cur_system.open do acquires = [1].inner(HDLRuby.uniq_name(:"#{name}_acq") => 0) end @acquires = acquires # Register the arbiter. this = self HDLRuby::High.space_reg(name) { this } end |
Instance Method Details
#<=(val) ⇒ Object
Arbiter access code generation: 1 for acquire and 0 for release.
183 184 185 186 187 188 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 183 def <=(val) # Add an access point if required. point = self.add_point # Do the access. @acquires[point] <= val end |
#add_point ⇒ Object
Adds an access point.
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 161 def add_point # Maybe a point already exist for current sequencer. sequ = SequencerT.current point = @points[sequ] return point if point # No add it. point = @size @points[sequ] = point @size += 1 # Resize the acquire vector according to the new point. @acquires.type.instance_variable_set(:@range,0..point) return point end |
#call(*sigs) ⇒ Object
Adds the signals.
151 152 153 154 155 156 157 158 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 151 def call(*sigs) sigs.each do |sig| unless sig.is_a?(SharedSignalI) then raise "An arbitrer only works on a shared signal, not a #{sig.class}" end @signals << sig end end |
#select(point) ⇒ Object
Shared signal selection code generation.
176 177 178 179 180 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 176 def select(point) @signals.each do |signal| signal.select(@points.key(point)) end end |