Class: AxiTdl::AxisVerify::Iteration
- Inherits:
-
Object
- Object
- AxiTdl::AxisVerify::Iteration
- Defined in:
- lib/tdl/exlib/axis_verify.rb
Instance Method Summary collapse
-
#initialize(length: 1024, data: [0], vld_perc: 50, user: [0], keep: [1], rand_seed: 0, dsize: 8, usize: 1) ⇒ Iteration
constructor
attr_accessor :axis_tlast, :axis_tuser, :axis_tkeep, :axis_tdata.
- #stream_context ⇒ Object
-
#to_a ⇒ Object
if @length <= index + 1 break end index += 1 end end.
Constructor Details
#initialize(length: 1024, data: [0], vld_perc: 50, user: [0], keep: [1], rand_seed: 0, dsize: 8, usize: 1) ⇒ Iteration
attr_accessor :axis_tlast, :axis_tuser, :axis_tkeep, :axis_tdata
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tdl/exlib/axis_verify.rb', line 9 def initialize(length: 1024, data: [0], vld_perc: 50,user:[0], keep:[1] , rand_seed: 0 ,dsize: 8, usize: 1) @axis_tdata = data.to_a * (length / data.size + 1) @axis_tuser = user.to_a * (length / user.size + 1) @axis_tkeep = keep.to_a * (length / keep.size + 1) @vld_perc = vld_perc / 100.0 @length = length @prng = Random.new( rand_seed ) @dsize = dsize @usize = usize @ksize = @dsize / 8 + (@dsize%8==0 ? 0 : 1) raise TdlError.new("valid percetage cant be zero") if vld_perc==0 end |
Instance Method Details
#stream_context ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/tdl/exlib/axis_verify.rb', line 63 def stream_context collect = [] to_a.each do |axis_tcnt, axis_tvalid, axis_tuser, axis_tkeep, axis_tlast, axis_tdata| u0 = axis_tdata % (2**@dsize) u3 = axis_tlast << (@dsize) u1 = (axis_tkeep % (2**@ksize)) << (@dsize + 1) u2 = (axis_tuser % (2**@usize)) << (@dsize + @ksize + 1) u4 = axis_tvalid << (@dsize + @ksize + @usize + 1) collect << (u0+u1+u2+u3+u4) end collect.map do |e| "%0#{(@dsize + @ksize + @usize + 1 + 1)/4 + ( ((@dsize + @ksize + @usize + 1 + 1)%4 == 0) ? 0 : 1 )}x"%e end # collect end |
#to_a ⇒ Object
if @length <= index + 1
break
end
index += 1
end
end
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tdl/exlib/axis_verify.rb', line 44 def to_a collect = [] index = 0 10000.times do vld = (@vld_perc > @prng.rand ? 1 : 0) collect << [ index, vld , @axis_tuser[index], @axis_tkeep[index], (@length==(index+vld) ? 1 : 0), @axis_tdata[index] ] if @length <= index + vld break end index += vld end collect end |