Method: HDLRuby::High::Std#fsm
- Defined in:
- lib/HDLRuby/std/fsm.rb
#fsm(*args, &ruby_block) ⇒ Object
Declare a new fsm. The arguments can be any of (but in this order):
- +name+:: name.
- +clk+:: clock.
- +event+:: clock event.
- +rst+:: reset. (must be declared AFTER clock or clock event).
If provided, +ruby_block+ the fsm is directly instantiated with it.
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/HDLRuby/std/fsm.rb', line 532 def fsm(*args, &ruby_block) # Sets the name if any unless args[0].respond_to?(:to_event) then name = args.shift.to_sym else name = :"" end # Get the options from the arguments. , args = args.partition {|arg| arg.is_a?(Symbol) } # Create the fsm. fsmI = FsmT.new(name,*) # Process the clock event if any. unless args.empty? then fsmI.for_event(args.shift) end # Process the reset if any. unless args.empty? then fsmI.for_reset(args.shift) end # Is there a ruby block? if ruby_block then # Yes, generate the fsm. fsmI.build(&ruby_block) else # No return the fsm structure for later generation. return fsmI end end |