Class: RubyHDL::High::Scall

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

Overview

Describes a SW implementation of an call statement.

Instance Method Summary collapse

Constructor Details

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

Create a new call statement in sequencer +sequencer+ for function named +name+ with arguments +args+.



2376
2377
2378
2379
2380
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2376

def initialize(sequencer, name, *args)
  @sequencer = sequencer
  @name = name.to_sym
  @args = args
end

Instance Method Details

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

Create an iterator for a given method +meth+.



2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2395

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)


2423
2424
2425
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2423

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)


2429
2430
2431
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2429

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+



2434
2435
2436
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2434

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.



2440
2441
2442
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2440

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.



2446
2447
2448
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2446

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).



2467
2468
2469
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2467

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

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

WH implementation of the Ruby count.



2473
2474
2475
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2473

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.



2478
2479
2480
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2478

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

#sdrop(n) ⇒ Object

HW implementation of the Ruby drop.



2490
2491
2492
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2490

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

#sdrop_while(&ruby_block) ⇒ Object

HW implementation of the Ruby drop_while.



2495
2496
2497
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2495

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



2500
2501
2502
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2500

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.



2506
2507
2508
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2506

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.


2721
2722
2723
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2721

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.


2417
2418
2419
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2417

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



2511
2512
2513
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2511

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.



2516
2517
2518
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2516

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.



2521
2522
2523
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2521

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.



2485
2486
2487
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2485

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.



2536
2537
2538
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2536

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.



2541
2542
2543
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2541

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



2461
2462
2463
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2461

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.



2547
2548
2549
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2547

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.



2553
2554
2555
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2553

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.



2559
2560
2561
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2559

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)


2564
2565
2566
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2564

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

#sinject(*args, &ruby_block) ⇒ Object

HW implementation of the Ruby inject.



2569
2570
2571
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2569

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.



2581
2582
2583
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2581

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.



2454
2455
2456
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2454

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

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

HW implementation of the Ruby max.



2586
2587
2588
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2586

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.



2591
2592
2593
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2591

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.



2596
2597
2598
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2596

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.



2601
2602
2603
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2601

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.



2606
2607
2608
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2606

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

#sminmax_by(&ruby_block) ⇒ Object

HW implementation of the Ruby minmax_by.



2611
2612
2613
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2611

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)


2617
2618
2619
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2617

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)


2623
2624
2625
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2623

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.



2629
2630
2631
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2629

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

#sreduceObject

HW implementation of the Ruby reduce.



2574
2575
2576
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2574

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

#sreject(&ruby_block) ⇒ Object

HW implementatiob of the Ruby reject.



2634
2635
2636
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2634

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.



2639
2640
2641
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2639

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.



2531
2532
2533
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2531

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.



2645
2646
2647
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2645

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.



2651
2652
2653
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2651

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.



2657
2658
2659
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2657

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

#ssort(&ruby_block) ⇒ Object

HW implementation of the Ruby sort.



2667
2668
2669
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2667

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

#ssort_by(&ruby_block) ⇒ Object

HW implementation of the Ruby sort.



2672
2673
2674
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2672

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.



2662
2663
2664
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2662

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.



2677
2678
2679
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2677

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.



2682
2683
2684
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2682

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

#stake_while(&ruby_block) ⇒ Object

The HW implementation of the Ruby take_while.



2687
2688
2689
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2687

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.



2693
2694
2695
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2693

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

#sto_aObject

HW implementation of the Ruby to_a.



2526
2527
2528
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2526

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.



2699
2700
2701
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2699

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

#suniq(&ruby_block) ⇒ Object

HW implementation of the Ruby uniq.



2704
2705
2706
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2704

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.



2711
2712
2713
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2711

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

#to_cObject

Convert to C code.



2389
2390
2391
2392
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2389

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

#to_rubyObject

Convert to Ruby code.



2383
2384
2385
2386
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2383

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