Class: RubyHDL::High::Scall

Inherits:
Expression show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes a SW implementation of an call statement.

Instance Attribute Summary

Attributes inherited from Expression

#type

Instance Method Summary collapse

Methods inherited from Expression

#<=, #[], #heach, #mux, #sdownto, #seach, #stimes, #supto, #to_expr, #to_value

Methods included from HEnumerable

#hall?, #hany?, #hchain, #hchunk, #hchunk_while, #hcompact, #hcount, #hcycle, #hdrop, #hdrop_while, #heach_cons, #heach_entry, #heach_range, #heach_slice, #heach_with_index, #heach_with_object, #hfind, #hfind_index, #hfirst, #hflat_map, #hgrep, #hgrep_v, #hgroup_by, #hinclude?, #hinject, #hlazy, #hmap, #hmax, #hmax_by, #hmin, #hmin_by, #hminmax, #hminmax_by, #hnone?, #hone?, #hpartition, #hreduce, #hreject, #hreverse_each, #hselect, #hslice_after, #hslice_before, #hslice_when, #hsort, #hsort_by, #hsum, #htake, #htake_while, #htally, #hto_a, #hto_h, #huniq, #hzip

Constructor Details

#initialize(func, sequencer, *args) ⇒ Scall

Create a new call to function named +func+ statement in sequencer +sequencer+ with arguments +args+.



3436
3437
3438
3439
3440
3441
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3436

def initialize(func, sequencer, *args)
  super(func.type)
  @sequencer = sequencer
  @name = func.name
  @args = args
end

Instance Method Details

#each_statement(&ruby_block) ⇒ Object

Iterate on the statements.



3444
3445
3446
3447
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3444

def each_statement(&ruby_block)
  return to_enum(:each_statement) unless ruby_block
  # By default nothing to do.
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterate deeply on the statements.



3450
3451
3452
3453
3454
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3450

def each_statement_deep(&ruby_block)
  return to_enum(:each_statement_deep) unless ruby_block
  # Just apply ruby_block on self.
  ruby_block.call(self)
end

#make_iterator(meth, *args, &ruby_block) ⇒ Object

Create an iterator for a given method +meth+.



3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3477

def make_iterator(meth,*args,&ruby_block)
  if ruby_block then
    blk = Sblock.new(@sequencer,&ruby_block)
    command = RubyHDL::High::Ruby.new do
      "#{meth}(#{args.map{|arg| arg.to_ruby}.join(",")}) { #{blk.to_ruby} }"
    end
  else
    command = RubyHDL::High::Ruby.new do
      "#{meth}(#{args.map{|arg| arg.to_ruby}.join(",")})"
    end
  end
  return Iter.new(@sequencer,*self.commands,command,&ruby_block)
end

#sall?(arg = nil, &ruby_block) ⇒ Boolean

Tell if all the elements respect a given criterion given either as +arg+ or as block.

Returns:

  • (Boolean)


3505
3506
3507
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3505

def sall?(arg = nil,&ruby_block)
  return self.make_iterator("all?",arg,&ruby_block)
end

#sany?(arg = nil, &ruby_block) ⇒ Boolean

Tell if any of the elements respects a given criterion given either as +arg+ or as block.

Returns:

  • (Boolean)


3511
3512
3513
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3511

def sany?(arg = nil,&ruby_block)
  return self.make_iterator("any?",arg,&ruby_block)
end

#schain(arg) ⇒ Object

Returns an SEnumerator generated from current enumerable and +arg+



3516
3517
3518
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3516

def schain(arg)
  return self.make_iterator("chain",arg)
end

#schunk(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby chunk. NOTE: to do, or may be not.



3522
3523
3524
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3522

def schunk(*args,&ruby_block)
  raise "schunk is not supported yet."
end

#schunk_while(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby chunk_while. NOTE: to do, or may be not.



3528
3529
3530
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3528

def schunk_while(*args,&ruby_block)
  raise "schunk_while is not supported yet."
end

#scompactObject

HW implementation of the Ruby compact, but remove 0 values instead on nil (since nil that does not have any meaning in HW).



3549
3550
3551
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3549

def scompact
  return self.make_iterator("compact",&ruby_block)
end

#scount(obj = nil, &ruby_block) ⇒ Object

WH implementation of the Ruby count.



3555
3556
3557
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3555

def scount(obj = nil, &ruby_block)
  return self.make_iterator("count",obj,&ruby_block)
end

#scycle(n = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby cycle.



3560
3561
3562
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3560

def scycle(n = nil,&ruby_block)
  return self.make_iterator("cycle",n,&ruby_block)
end

#sdrop(n) ⇒ Object

HW implementation of the Ruby drop.



3572
3573
3574
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3572

def sdrop(n)
  return self.make_iterator("drop",n)
end

#sdrop_while(&ruby_block) ⇒ Object

HW implementation of the Ruby drop_while.



3577
3578
3579
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3577

def sdrop_while(&ruby_block)
  return self.make_iterator("drop_while",&ruby_block)
end

#seach_cons(n, &ruby_block) ⇒ Object

HW implementation of the Ruby each_cons



3582
3583
3584
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3582

def seach_cons(n,&ruby_block)
  return self.make_iterator("each_cons",n,&ruby_block)
end

#seach_entry(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby each_entry. NOTE: to do, or may be not.



3588
3589
3590
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3588

def seach_entry(*args,&ruby_block)
  raise "seach_entry is not supported yet."
end

#seach_nexts(num, &ruby_block) ⇒ Object

Iterator on the +num+ next elements. NOTE:

  • Stop iteration when the end of the range is reached or when there are no elements left
  • This is not a method from Ruby but one specific for hardware where creating a array is very expensive.


3803
3804
3805
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3803

def seach_nexts(num,&ruby_block)
  return self.seach.snexts(num,&ruby_block)
end

#seach_range(rng, &ruby_block) ⇒ Object

Iterator on each of the elements in range +rng+. NOTE:

  • Stop iteration when the end of the range is reached or when there are no elements left
  • This is not a method from Ruby but one specific for hardware where creating a array is very expensive.


3499
3500
3501
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3499

def seach_range(rng,&ruby_block)
  return self.make_iterator("each_range",rng,&ruby_block)
end

#seach_slice(n, &ruby_block) ⇒ Object

HW implementation of the Ruby each_slice



3593
3594
3595
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3593

def seach_slice(n,&ruby_block)
  return self.make_iterator("each_slice",n,&ruby_block)
end

#seach_with_index(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby each_with_index.



3598
3599
3600
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3598

def seach_with_index(*args,&ruby_block)
  return self.make_iterator("each_with_index",*args,&ruby_block)
end

#seach_with_object(obj, &ruby_block) ⇒ Object

HW implementation of the Ruby each_with_object.



3603
3604
3605
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3603

def seach_with_object(obj,&ruby_block)
  return self.make_iterator("each_with_object",obj,&ruby_block)
end

#sfind(if_none_proc, &ruby_block) ⇒ Object

HW implementation of the Ruby find. NOTE: contrary to Ruby, if_none_proc is mandatory since there is no nil in HW. Moreover, the argument can also be a value.



3567
3568
3569
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3567

def sfind(if_none_proc, &ruby_block)
  return self.make_iterator("find",if_none_proc,&ruby_block)
end

#sfind_index(obj = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby find_index.



3618
3619
3620
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3618

def sfind_index(obj = nil, &ruby_block)
  return self.make_iterator("find_index",obj,&ruby_block)
end

#sfirst(n = 1) ⇒ Object

HW implementation of the Ruby first.



3623
3624
3625
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3623

def sfirst(n=1)
  return self.make_iterator("first",n)
end

#sflat_map(&ruby_block) ⇒ Object

HW implementation of the Ruby flat_map. NOTE: actually due to the way HDLRuby handles vectors, should work like smap



3543
3544
3545
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3543

def sflat_map(&ruby_block)
  return self.make_iterator("flat_map",&ruby_block)
end

#sgrep(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby grep. NOTE: to do, or may be not.



3629
3630
3631
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3629

def sgrep(*args,&ruby_block)
  raise "sgrep is not supported yet."
end

#sgrep_v(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby grep_v. NOTE: to do, or may be not.



3635
3636
3637
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3635

def sgrep_v(*args,&ruby_block)
  raise "sgrep_v is not supported yet."
end

#sgroup_by(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby group_by. NOTE: to do, or may be not.



3641
3642
3643
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3641

def sgroup_by(*args,&ruby_block)
  raise "sgroup_by is not supported yet."
end

#sinclude?(obj) ⇒ Boolean

HW implementation of the Ruby include?

Returns:

  • (Boolean)


3646
3647
3648
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3646

def sinclude?(obj)
  return self.make_iterator("include?",obj)
end

#sinject(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby inject.



3651
3652
3653
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3651

def sinject(*args,&ruby_block)
  return self.make_iterator("inject",*args,&ruby_block)
end

#slazy(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby lazy. NOTE: to do, or may be not.



3663
3664
3665
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3663

def slazy(*args,&ruby_block)
  raise "slazy is not supported yet."
end

#smap(&ruby_block) ⇒ Object

Returns a vector containing the execution result of the given block on each element. If no block is given, return an SEnumerator. NOTE: be carful that the resulting vector can become huge if there are many element.



3536
3537
3538
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3536

def smap(&ruby_block)
  return self.make_iterator("map",&ruby_block)
end

#smax(n = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby max.



3668
3669
3670
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3668

def smax(n = nil, &ruby_block)
  return self.make_iterator("max",n,&ruby_block)
end

#smax_by(n = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby max_by.



3673
3674
3675
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3673

def smax_by(n = nil, &ruby_block)
  return self.make_iterator("max_by",n,&ruby_block)
end

#smin(n = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby min.



3678
3679
3680
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3678

def smin(n = nil, &ruby_block)
  return self.make_iterator("min",n,&ruby_block)
end

#smin_by(n = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby min_by.



3683
3684
3685
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3683

def smin_by(n = nil, &ruby_block)
  return self.make_iterator("min_by",n,&ruby_block)
end

#sminmax(&ruby_block) ⇒ Object

HW implementation of the Ruby minmax.



3688
3689
3690
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3688

def sminmax(&ruby_block)
  return self.make_iterator("minmax",&ruby_block)
end

#sminmax_by(&ruby_block) ⇒ Object

HW implementation of the Ruby minmax_by.



3693
3694
3695
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3693

def sminmax_by(&ruby_block)
  return self.make_iterator("minmax_by",&ruby_block)
end

#snone?(arg = nil, &ruby_block) ⇒ Boolean

Tell if none of the elements respects a given criterion given either as +arg+ or as block.

Returns:

  • (Boolean)


3699
3700
3701
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3699

def snone?(arg = nil,&ruby_block)
  return self.make_iterator("none?",arg,&ruby_block)
end

#sone?(arg = nil, &ruby_block) ⇒ Boolean

Tell if one and only one of the elements respects a given criterion given either as +arg+ or as block.

Returns:

  • (Boolean)


3705
3706
3707
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3705

def sone?(arg = nil,&ruby_block)
  return self.make_iterator("one?",arg,&ruby_block)
end

#spartition(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby partition. NOTE: to do, or may be not.



3711
3712
3713
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3711

def spartition(*args,&ruby_block)
  raise "spartition is not supported yet."
end

#sreduceObject

HW implementation of the Ruby reduce.



3656
3657
3658
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3656

def sreduce
  return self.make_iterator("reduce",*args,&ruby_block)
end

#sreject(&ruby_block) ⇒ Object

HW implementatiob of the Ruby reject.



3716
3717
3718
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3716

def sreject(&ruby_block)
  return self.make_iterator("reject",&ruby_block)
end

#sreverse_each(*args, &ruby_block) ⇒ Object

HW implementatiob of the Ruby reverse_each.



3721
3722
3723
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3721

def sreverse_each(*args,&ruby_block)
  return self.make_iterator("reverse_each",*args,&ruby_block)
end

#sselect(&ruby_block) ⇒ Object

HW implementation of the Ruby select.



3613
3614
3615
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3613

def sselect(&ruby_block)
  return self.make_iterator("select",&ruby_block)
end

#sslice_after(pattern = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby slice_after. NOTE: to do, or may be not.



3727
3728
3729
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3727

def sslice_after(pattern = nil,&ruby_block)
  raise "sslice_after is not supported yet."
end

#sslice_before(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby slice_before. NOTE: to do, or may be not.



3733
3734
3735
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3733

def sslice_before(*args,&ruby_block)
  raise "sslice_before is not supported yet."
end

#sslice_when(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby slice_when. NOTE: to do, or may be not.



3739
3740
3741
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3739

def sslice_when(*args,&ruby_block)
  raise "sslice_before is not supported yet."
end

#ssort(&ruby_block) ⇒ Object

HW implementation of the Ruby sort.



3749
3750
3751
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3749

def ssort(&ruby_block)
  return self.make_iterator("sort",&ruby_block)
end

#ssort_by(&ruby_block) ⇒ Object

HW implementation of the Ruby sort.



3754
3755
3756
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3754

def ssort_by(&ruby_block)
  return self.make_iterator("sort_by",&ruby_block)
end

#ssort_merge(arI, arO, first, middle, last, &ruby_block) ⇒ Object

Merge two arrays in order, for ssort only.



3744
3745
3746
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3744

def ssort_merge(arI, arO, first, middle, last, &ruby_block)
  return self.make_iterator("sort_merge",arI,arO,first,middle,last,&ruby_block)
end

#ssum(initial_value = nil, &ruby_block) ⇒ Object

HW implementation of the Ruby sum.



3759
3760
3761
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3759

def ssum(initial_value = nil,&ruby_block)
  return self.make_iterator("sum",initial_value,&ruby_block)
end

#stake(n) ⇒ Object

The HW implementation of the Ruby take.



3764
3765
3766
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3764

def stake(n)
  return self.make_iterator("take",n)
end

#stake_while(&ruby_block) ⇒ Object

The HW implementation of the Ruby take_while.



3769
3770
3771
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3769

def stake_while(&ruby_block)
  return self.make_iterator("take_while",&ruby_block)
end

#stally(h = nil) ⇒ Object

HW implementation of the Ruby tally. NOTE: to do, or may be not.



3775
3776
3777
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3775

def stally(h = nil)
  raise "stally is not supported yet."
end

#sto_aObject

HW implementation of the Ruby to_a.



3608
3609
3610
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3608

def sto_a
  return self.make_iterator("to_a")
end

#sto_h(h = nil) ⇒ Object

HW implementation of the Ruby to_h. NOTE: to do, or may be not.



3781
3782
3783
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3781

def sto_h(h = nil)
  raise "sto_h is not supported yet."
end

#suniq(&ruby_block) ⇒ Object

HW implementation of the Ruby uniq.



3786
3787
3788
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3786

def suniq(&ruby_block)
  return self.make_iterator("uniq",&ruby_block)
end

#szip(obj, &ruby_block) ⇒ Object

HW implementation of the Ruby zip. NOTE: for now szip is deactivated untile tuples are properly handled by HDLRuby.



3793
3794
3795
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3793

def szip(obj,&ruby_block)
  return self.make_iterator("zip",obj,&ruby_block)
end

#to_cObject

Convert to C code.



3462
3463
3464
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3462

def to_c
  return "\n__#{@name}(" + @args.map {|arg| arg.to_c}.join(",") + ");"
end

#to_python(l = "") ⇒ Object

Convert to Python code.



3467
3468
3469
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3467

def to_python(l = "")
  return "#{l}\n__#{@name}(" + @args.map {|arg| arg.to_python}.join(",") + ")"
end

#to_rubyObject

Convert to Ruby code.



3457
3458
3459
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3457

def to_ruby
  return "__#{@name}(" + @args.map {|arg| arg.to_ruby}.join(",") + ")"
end

#to_tf(l = "") ⇒ Object

Convert to TensorFlow code.



3472
3473
3474
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3472

def to_tf(l = "")
  return "#{l}\n__#{@name}(" + @args.map {|arg| arg.to_tf}.join(",") + ")"
end