Class: AxiTdl::LogicVerify::Iteration

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/exlib/logic_verify.rb

Instance Method Summary collapse

Constructor Details

#initialize(length: 1024, data: [0], dsize: 8) ⇒ Iteration

Returns a new instance of Iteration.



8
9
10
11
12
# File 'lib/tdl/exlib/logic_verify.rb', line 8

def initialize(length: 1024, data: [0], dsize: 8)
    @data = data.to_a * (length / data.size + 1)
    @length = length
    @dsize = dsize
end

Instance Method Details

#coeObject



43
44
45
46
47
48
49
50
# File 'lib/tdl/exlib/logic_verify.rb', line 43

def coe 
    collect = []
    xxx = context
    xxx.each_index do |index|
        collect << "@%04x #{xxx[index]}\n"%index
    end
    collect.join("")
end

#contextObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tdl/exlib/logic_verify.rb', line 30

def context
    collect = []
    to_a.each do |index, data|
        u0 = data % (2**@dsize)
        collect << u0
    end

    collect.map do |e| 
        "%0#{(@dsize )/4  + ( ((@dsize)%4 == 0) ? 0 : 1 )}x"%e
    end
    # collect
end

#to_aObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tdl/exlib/logic_verify.rb', line 14

def to_a 
    collect = []
    index = 0
    while true 
        
        collect << [ index, @data[index] ]
        
        if @length <= index + 1
            break 
        end
        index += 1
    end

    collect 
end