Class: HDLRuby::High::Std::TaskI
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::TaskI
- Includes:
- Hmissing
- Defined in:
- lib/HDLRuby/std/task.rb
Overview
Describes a high-level task instance.
Constant Summary
Constants included from Hmissing
Hmissing::High, Hmissing::NAMES
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the task instance.
-
#namespace ⇒ Object
readonly
The namespace associated with the current execution when building a task.
-
#scope ⇒ Object
readonly
The scope the task has been created in.
Instance Method Summary collapse
-
#finish(*args, &ruby_block) ⇒ Object
Performs a wait from the end of the computation of the task using +args+ and +ruby_block+ as arguments.
-
#finisher(&ruby_block) ⇒ Object
Sets the finisher procedure to be +ruby_block+.
-
#finisher_inout(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher inout port.
-
#finisher_input(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher input port.
-
#finisher_output(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher output port.
-
#finisher_signals ⇒ Object
Gets the list of the signals of the task to be connected to the finisher.
-
#initialize(name, &ruby_block) ⇒ TaskI
constructor
Creates a new task instance with +name+ built from +ruby_block+.
-
#inner(name) ⇒ Object
Declares the ports for accessing the task as an inner component and assigned them to +name+.
-
#input(name) ⇒ Object
Declares the ports for the runner and assigned them to +name+.
-
#output(name) ⇒ Object
Declares the ports for the finisher and assigned them to +name+.
-
#reset(*args, &ruby_block) ⇒ Object
Performs a reset on the task using +args+ and +ruby_block+ as arguments.
-
#reseter(&ruby_block) ⇒ Object
Sets the reset to be +ruby_block+.
-
#run(*args, &ruby_block) ⇒ Object
Runs the task using +args+ and +ruby_block+ as arguments.
-
#runner(&ruby_block) ⇒ Object
Sets the read procedure to be +ruby_block+.
-
#runner_inout(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run inout port.
-
#runner_input(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run input port.
-
#runner_output(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run output port.
-
#runner_signals ⇒ Object
Gets the list of the signals of the task to be connected to the runner.
Methods included from Hmissing
Constructor Details
#initialize(name, &ruby_block) ⇒ TaskI
Creates a new task instance with +name+ built from +ruby_block+.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/HDLRuby/std/task.rb', line 327 def initialize(name,&ruby_block) # Check and set the name of the task. @name = name.to_sym # Generate a name for the scope containing the signals of # the task. @scope_name = HDLRuby.uniq_name # # Sets the scope. # @scope = HDLRuby::High.cur_scope # Keep access to self. obj = self # The runner input ports by name. @runner_inputs = {} # The runner output ports by name. @runner_outputs = {} # The runner inout ports by name. @runner_inouts = {} # # The stopper input ports by name. # @stopper_inputs = {} # # The stopper output ports by name. # @stopper_outputs = {} # # The stopper inout ports by name. # @stopper_inouts = {} # The finisher input ports by name. @finisher_inputs = {} # The finisher output ports by name. @finisher_outputs = {} # The finisher inout ports by name. @finisher_inouts = {} # Create the namespaces for building the task, its readers # its writers and its accessers. # Creates the namespace of the task. @namespace = Namespace.new(self) # Make it give access to the internal of the class. @namespace.add_method(:runner_input, &method(:runner_input)) @namespace.add_method(:runner_output, &method(:runner_output)) @namespace.add_method(:runner_inout, &method(:runner_inout)) # @namespace.add_method(:stopper_input, &method(:stopper_input)) # @namespace.add_method(:stopper_output, &method(:stopper_output)) # @namespace.add_method(:stopper_inout, &method(:stopper_inout)) @namespace.add_method(:finisher_input, &method(:finisher_input)) @namespace.add_method(:finisher_output, &method(:finisher_output)) @namespace.add_method(:finisher_inout, &method(:finisher_inout)) @namespace.add_method(:runner, &method(:runner)) # @namespace.add_method(:stopper, &method(:stopper)) @namespace.add_method(:finisher, &method(:finisher)) # Creates the namespace of the runner. @runner_namespace = Namespace.new(self) # # Creates the namespace of the stopper. # @stopper_namespace = Namespace.new(self) # Creates the namespace of the finisher. @finisher_namespace = Namespace.new(self) @controller_namespace = Namespace.new(self) # Builds the task within a new scope. HDLRuby::High.space_push(@namespace) # puts "top_user=#{HDLRuby::High.top_user}" scope_name = @scope_name scope = nil HDLRuby::High.top_user.instance_eval do sub(scope_name) do # Generate the task code. ruby_block.call end end HDLRuby::High.space_pop # Keep access to the scope containing the code of the task. @scope = @namespace.send(scope_name) # puts "@scope=#{@scope}" # Adds the name space of the scope to the namespace of the # task @namespace.concat_namespace(@scope.namespace) # Gives access to the task by registering its name. obj = self # HDLRuby::High.space_reg(@name) { self } HDLRuby::High.space_reg(@name) { obj } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HDLRuby::High::Hmissing
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the task instance.
317 318 319 |
# File 'lib/HDLRuby/std/task.rb', line 317 def name @name end |
#namespace ⇒ Object (readonly)
The namespace associated with the current execution when building a task.
324 325 326 |
# File 'lib/HDLRuby/std/task.rb', line 324 def namespace @namespace end |
#scope ⇒ Object (readonly)
The scope the task has been created in.
320 321 322 |
# File 'lib/HDLRuby/std/task.rb', line 320 def scope @scope end |
Instance Method Details
#finish(*args, &ruby_block) ⇒ Object
Performs a wait from the end of the computation of the task using +args+ and +ruby_block+ as arguments.
780 781 782 783 784 785 786 787 788 789 790 |
# File 'lib/HDLRuby/std/task.rb', line 780 def finish(*args,&ruby_block) # Gain access to the finisher as local variable. finisher_proc = @finisher_proc # # The context is the one of the finisher. # Execute the code generating the finisher in context. HDLRuby::High.space_push(@namespace) HDLRuby::High.cur_block.open do instance_exec(ruby_block,*args,&finisher_proc) end HDLRuby::High.space_pop end |
#finisher(&ruby_block) ⇒ Object
Sets the finisher procedure to be +ruby_block+.
558 559 560 |
# File 'lib/HDLRuby/std/task.rb', line 558 def finisher(&ruby_block) @finisher_proc = ruby_block end |
#finisher_inout(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher inout port.
535 536 537 538 539 540 541 542 543 544 |
# File 'lib/HDLRuby/std/task.rb', line 535 def finisher_inout(*keys) # Registers each signal as finisher port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @finisher_inouts[name] = send(key) end end |
#finisher_input(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher input port.
511 512 513 514 515 516 517 518 519 520 |
# File 'lib/HDLRuby/std/task.rb', line 511 def finisher_input(*keys) # Registers each signal as finisher port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @finisher_inputs[name] = send(key) end end |
#finisher_output(*keys) ⇒ Object
Sets the signals accessible through +key+ to be finisher output port.
523 524 525 526 527 528 529 530 531 532 |
# File 'lib/HDLRuby/std/task.rb', line 523 def finisher_output(*keys) # Registers each signal as finisher port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @finisher_outputs[name] = send(key) end end |
#finisher_signals ⇒ Object
Gets the list of the signals of the task to be connected to the finisher.
587 588 589 590 |
# File 'lib/HDLRuby/std/task.rb', line 587 def finisher_signals return @finisher_inputs.values + @finisher_outputs.values + @finisher_inouts.values end |
#inner(name) ⇒ Object
Declares the ports for accessing the task as an inner component and assigned them to +name+.
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
# File 'lib/HDLRuby/std/task.rb', line 715 def inner(name) # Ensure name is a symbol. name = name.to_sym # Access the ports loc_inputs = @runner_inputs.merge(@finisher_inputs) loc_outputs = @runner_outputs.merge(@finisher_outputs) loc_inouts = @runner_inouts.merge(@finisher_inouts) locs = loc_inputs.merge(loc_outputs).merge(loc_inouts) # The generated port with corresponding task port pairs. port_pairs = [] # Add them to the current system. HDLRuby::High.cur_system.open do locs.each do |name,sig| port_pairs << [sig, sig.type.inner(name)] end end obj = self # Make the inner connection port_pairs.each do |sig, port| sig.parent.open do port.to_ref <= sig end end # Set ups the controller's namespace loc_inputs.each do |name,sig| @controller_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end loc_outputs.each do |name,sig| @controller_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end loc_inouts.each do |name,sig| @controller_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end # Give access to the ports through name. # NOTE: for now, simply associate the task to name. tp = TaskPortSA.new(@controller_namespace,@runner_proc,@finisher_proc,@reseter_proc) HDLRuby::High.space_reg(name) { chp } return tp end |
#input(name) ⇒ Object
Declares the ports for the runner and assigned them to +name+.
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/HDLRuby/std/task.rb', line 594 def input(name) # Ensure name is a symbol. name = name.to_sym # Access the ports loc_inputs = @runner_inputs loc_outputs = @runner_outputs loc_inouts = @runner_inouts # The generated port with corresponding task port pairs. port_pairs = [] # Add them to the current system. HDLRuby::High.cur_system.open do # The inputs loc_inputs.each do |name,sig| # puts "name=#{name} sig.name=#{sig.name}" port_pairs << [sig, sig.type.input(name)] end # The outputs loc_outputs.each do |name,sig| port_pairs << [sig, sig.type.output(name)] end # The inouts loc_inouts.each do |name,sig| port_pairs << [sig, sig.type.inout(name)] end end obj = self # Make the connection of the instance. HDLRuby::High.cur_system.on_instance do |inst| obj.scope.open do port_pairs.each do |sig, port| RefObject.new(inst,port.to_ref) <= sig end end end # Fill the runner namespace with the access to the runner signals. @runner_inputs.each do |name,sig| @runner_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end @runner_outputs.each do |name,sig| @runner_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end @runner_inouts.each do |name,sig| @runner_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end # Give access to the ports through name. # NOTE: for now, simply associate the task to name. tp = TaskPortS.new(@runner_namespace,@runner_proc,@reseter_proc) HDLRuby::High.space_reg(name) { tp } return tp end |
#output(name) ⇒ Object
Declares the ports for the finisher and assigned them to +name+.
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/HDLRuby/std/task.rb', line 654 def output(name) # Ensure name is a symbol. name = name.to_sym # Access the ports loc_inputs = @finisher_inputs loc_outputs = @finisher_outputs loc_inouts = @finisher_inouts # The generated port with corresponding task port pairs. port_pairs = [] # Add them to the current system. HDLRuby::High.cur_system.open do # The inputs loc_inputs.each do |name,sig| port_pairs << [sig, sig.type.input(name)] end # The outputs loc_outputs.each do |name,sig| port_pairs << [sig, sig.type.output(name)] end # The inouts loc_inouts.each do |name,sig| port_pairs << [sig, sig.type.inout(name)] end end obj = self # Make the connection of the instance. HDLRuby::High.cur_system.on_instance do |inst| obj.scope.open do port_pairs.each do |sig, port| RefObject.new(inst,port.to_ref) <= sig end end end # Fill the finisher namespace with the access to the finisher signals. @finisher_inputs.each do |name,sig| @finisher_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end @finisher_outputs.each do |name,sig| @finisher_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end @finisher_inouts.each do |name,sig| @finisher_namespace.add_method(sig.name) do HDLRuby::High.top_user.send(name) end end # Give access to the ports through name. # NOTE: for now, simply associate the task to name. chp = TaskPortA.new(@finisher_namespace,@finisher_proc,@output_reseter_proc) HDLRuby::High.space_reg(name) { chp } return chp end |
#reset(*args, &ruby_block) ⇒ Object
Performs a reset on the task using +args+ and +ruby_block+ as arguments.
794 795 796 797 798 799 800 801 802 803 804 |
# File 'lib/HDLRuby/std/task.rb', line 794 def reset(*args,&ruby_block) # Gain access to the writer as local variable. reseter_proc = @inout_reseter_proc # # The context is the one of the writer. # Execute the code generating the writer in context. HDLRuby::High.space_push(@namespace) HDLRuby::High.cur_block.open do instance_exec(ruby_block,*args,&reseter_proc) end HDLRuby::High.space_pop end |
#reseter(&ruby_block) ⇒ Object
Sets the reset to be +ruby_block+.
563 564 565 |
# File 'lib/HDLRuby/std/task.rb', line 563 def reseter(&ruby_block) @reseter_proc = ruby_block end |
#run(*args, &ruby_block) ⇒ Object
Runs the task using +args+ and +ruby_block+ as arguments.
766 767 768 769 770 771 772 773 774 775 776 |
# File 'lib/HDLRuby/std/task.rb', line 766 def run(*args,&ruby_block) # Gain access to the runner as local variable. runner_proc = @runner_proc # # The context is the one of the reader. # Execute the code generating the reader in context. HDLRuby::High.space_push(@namespace) HDLRuby::High.cur_block.open do instance_exec(ruby_block,*args,&runner_proc) end HDLRuby::High.space_pop end |
#runner(&ruby_block) ⇒ Object
Sets the read procedure to be +ruby_block+.
548 549 550 |
# File 'lib/HDLRuby/std/task.rb', line 548 def runner(&ruby_block) @runner_proc = ruby_block end |
#runner_inout(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run inout port.
463 464 465 466 467 468 469 470 471 472 |
# File 'lib/HDLRuby/std/task.rb', line 463 def runner_inout(*keys) # Registers each signal as run port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @runner_inouts[name] = send(key) end end |
#runner_input(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run input port.
439 440 441 442 443 444 445 446 447 448 |
# File 'lib/HDLRuby/std/task.rb', line 439 def runner_input(*keys) # Registers each signal as run port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @runner_inputs[name] = send(key) end end |
#runner_output(*keys) ⇒ Object
Sets the signals accessible through +key+ to be run output port.
451 452 453 454 455 456 457 458 459 460 |
# File 'lib/HDLRuby/std/task.rb', line 451 def runner_output(*keys) # Registers each signal as run port keys.each do |key| # Ensure the key is a symbol. key = key.to_sym # Register it with the corresponding signal. name = HDLRuby.uniq_name # The name of the signal is uniq. @runner_outputs[name] = send(key) end end |
#runner_signals ⇒ Object
Gets the list of the signals of the task to be connected to the runner.
573 574 575 576 |
# File 'lib/HDLRuby/std/task.rb', line 573 def runner_signals return @runner_inputs.values + @runner_outputs.values + @runner_inouts.values end |