Class: HDLRuby::High::Std::PriorityArbiterT
- Defined in:
- lib/HDLRuby/std/sequencer_sync.rb
Overview
Describes a priority-based arbiter.
Direct Known Subclasses
Instance Method Summary collapse
-
#add_point ⇒ Object
Add a point.
-
#initialize(name, tbl = nil, *sigs, &ruby_block) ⇒ PriorityArbiterT
constructor
Create a new priority-based arbiter named +name+ with priority table +tbl+ or priority algorithm +ruby_block+ for shared signals +sigs+.
-
#policy(tbl = nil, &ruby_block) ⇒ Object
Set the policy either using a priority table +tbl+ by directly providing the priority algorithm through +ruby_block+.
Methods inherited from ArbiterT
Constructor Details
#initialize(name, tbl = nil, *sigs, &ruby_block) ⇒ PriorityArbiterT
Create a new priority-based arbiter named +name+ with priority table +tbl+ or priority algorithm +ruby_block+ for shared signals +sigs+.
197 198 199 200 201 202 203 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 197 def initialize(name, tbl = nil, *sigs, &ruby_block) super(name,*sigs) # Set the priority policy. self.policy(tbl,&ruby_block) # Create the name of the access procedure sub. @name_sub = HDLRuby.uniq_name(:"#{name}_sub") end |
Instance Method Details
#add_point ⇒ Object
Add a point.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 223 def add_point point = super # The point is added by the parent class. # Update the access procedure. name_sub = @name_sub this = self size = @size acquires = @acquires priority = @priority HDLRuby::High.cur_system.open do sub(name_sub) do seq do if(size == 1) then # Anyway, only one accesser. this.select(0) else hif(priority.(acquires,0)) do this.select(0) end (1..size-1).each do |i| helsif(priority.(acquires,i)) do this.select(i) end end helse do # No acquire at all, select the first point. this.select(0) end end end end end return point end |
#policy(tbl = nil, &ruby_block) ⇒ Object
Set the policy either using a priority table +tbl+ by directly providing the priority algorithm through +ruby_block+
207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 207 def policy(tbl = nil, &ruby_block) # By default the priority table is the points declaration order. if !tbl && ruby_block == nil then @priority = proc { |acquires,i| acquires[i] == 1 } elsif tbl then @priority = proc do |acquires,i| pri = tbl[i] raise "Invalid priority index: #{i}" unless pri acquires[pri] == 1 end else @priority = ruby_block end end |