Method: HDLRuby::High::Std#after
- Defined in:
- lib/HDLRuby/std/counters.rb
#after(init, rst = $rst, clk = $clk, &code) ⇒ Object
Sets a counter to +init+ when +rst+ is 1 that is decreased according to +clk+. When this counter reaches 0, +code+ is executed. When not within a block, a behavior will be created which is activated on the rising edge of +clk+.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/HDLRuby/std/counters.rb', line 65 def after(init, rst = $rst, clk = $clk, &code) with_counter(init,rst,clk) do |counter| seq do hif(rst.to_expr == 1) do counter.to_ref <= init.to_expr end helsif(counter.to_expr == 0) do # code.call instance_eval(&code) end helse do counter.to_ref <= counter.to_expr - 1 end end end end |