origen_link 0.2.0.pre0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +1,78 @@
1
- require 'sinatra/base'
2
- module OrigenLink
3
- class Listener < Sinatra::Base
4
- def self.port
5
- @port || 20_020
6
- end
7
-
8
- def self.environment
9
- @environment || :production
10
- end
11
-
12
- def self.target_object
13
- @target_object || dut
14
- end
15
-
16
- def self.run!(options = {})
17
- @port = options[:port]
18
- @environment = options[:environment]
19
- @target_object = options[:dut]
20
- super
21
- end
22
-
23
- def target_object
24
- self.class.target_object
25
- end
26
-
27
- def expand_path(path)
28
- path.split('.').each do |p|
29
- if p =~ /(.*)\[(\d+)(:(\d+))?\]$/
30
- msb = Regexp.last_match(2).to_i
31
- lsb = Regexp.last_match(4).to_i if Regexp.last_match(4)
32
- yield Regexp.last_match(1)
33
- if lsb
34
- yield '[]', msb..lsb
35
- else
36
- yield '[]', msb
37
- end
38
- else
39
- yield p
40
- end
41
- end
42
- end
43
-
44
- get '/hello_world' do
45
- 'Hello there'
46
- end
47
-
48
- get '/dut_class' do
49
- target_object.class.to_s
50
- end
51
-
52
- post '/register' do
53
- t = target_object
54
- expand_path(params[:path]) do |method, arg|
55
- if arg
56
- t = t.send(method, arg)
57
- else
58
- t = t.send(method)
59
- end
60
- end
61
- t.write!(params[:data].to_i)
62
- nil
63
- end
64
-
65
- get '/register' do
66
- t = target_object
67
- expand_path(params[:path]) do |method, arg|
68
- if arg
69
- t = t.send(method, arg)
70
- else
71
- t = t.send(method)
72
- end
73
- end
74
- t.sync
75
- t.data.to_s
76
- end
77
- end
78
- end
1
+ require 'sinatra/base'
2
+ module OrigenLink
3
+ class Listener < Sinatra::Base
4
+ def self.port
5
+ @port || 20_020
6
+ end
7
+
8
+ def self.environment
9
+ @environment || :production
10
+ end
11
+
12
+ def self.target_object
13
+ @target_object || dut
14
+ end
15
+
16
+ def self.run!(options = {})
17
+ @port = options[:port]
18
+ @environment = options[:environment]
19
+ @target_object = options[:dut]
20
+ super
21
+ end
22
+
23
+ def target_object
24
+ self.class.target_object
25
+ end
26
+
27
+ def expand_path(path)
28
+ path.split('.').each do |p|
29
+ if p =~ /(.*)\[(\d+)(:(\d+))?\]$/
30
+ msb = Regexp.last_match(2).to_i
31
+ lsb = Regexp.last_match(4).to_i if Regexp.last_match(4)
32
+ yield Regexp.last_match(1)
33
+ if lsb
34
+ yield '[]', msb..lsb
35
+ else
36
+ yield '[]', msb
37
+ end
38
+ else
39
+ yield p
40
+ end
41
+ end
42
+ end
43
+
44
+ get '/hello_world' do
45
+ 'Hello there'
46
+ end
47
+
48
+ get '/dut_class' do
49
+ target_object.class.to_s
50
+ end
51
+
52
+ post '/register' do
53
+ t = target_object
54
+ expand_path(params[:path]) do |method, arg|
55
+ if arg
56
+ t = t.send(method, arg)
57
+ else
58
+ t = t.send(method)
59
+ end
60
+ end
61
+ t.write!(params[:data].to_i)
62
+ nil
63
+ end
64
+
65
+ get '/register' do
66
+ t = target_object
67
+ expand_path(params[:path]) do |method, arg|
68
+ if arg
69
+ t = t.send(method, arg)
70
+ else
71
+ t = t.send(method)
72
+ end
73
+ end
74
+ t.sync
75
+ t.data.to_s
76
+ end
77
+ end
78
+ end
@@ -1,180 +1,180 @@
1
- require 'origen_link/server/pin'
2
-
3
- module OrigenLink
4
- module Server
5
- class Jtag
6
- attr_reader :tdoval
7
- attr_accessor :verbose_enable
8
- attr_accessor :anytdofail
9
-
10
- def initialize(tdiio = 16, tdoio = 23, tmsio = 19, tckio = 26, tck_period = 0.000001)
11
- @tdipin = Pin.new(tdiio, :out)
12
- @tdopin = Pin.new(tdoio, :in)
13
- @tmspin = Pin.new(tmsio, :out)
14
- @tckpin = Pin.new(tckio, :out)
15
- @tck_half_period = tck_period / 2
16
- @tdoval = 0
17
- @tdostr = ''
18
- @verbose_enable = true
19
- @anytdofail = false
20
- end
21
-
22
- def tck_period=(value)
23
- @tck_half_period = value / 2
24
- end
25
-
26
- def destroy
27
- @tdipin.destroy
28
- @tdopin.destroy
29
- @tmspin.destroy
30
- @tckpin.destroy
31
- @tdipin = nil
32
- @tdopin = nil
33
- @tmspin = nil
34
- @tckpin = nil
35
- end
36
-
37
- def do_cycle(tdival, tmsval, capturetdo = false)
38
- @tdipin.out(tdival)
39
- @tmspin.out(tmsval)
40
- sleep @tck_half_period
41
- @tckpin.out(1)
42
- sleep @tck_half_period
43
-
44
- if capturetdo
45
- @tdostr = @tdopin.in + @tdostr
46
- end
47
- @tckpin.out(0)
48
- end
49
-
50
- def do_tlr
51
- 8.times { do_cycle(0, 1) }
52
- do_cycle(0, 0)
53
- end
54
-
55
- def do_shift(numbits, value, capturetdo = false, suppresscomments = false, tdocompare = '')
56
- @tdoval = 0
57
- @tdostr = ''
58
- (numbits - 1).times do |bit|
59
- do_cycle(value[bit], 0, capturetdo)
60
- end
61
- do_cycle(value[numbits - 1], 1, capturetdo)
62
-
63
- @tdoval = @tdostr.to_i(2) if capturetdo
64
-
65
- if !(suppresscomments) && @verbose_enable && capturetdo
66
- puts 'TDO output = 0x' + @tdoval.to_s(16)
67
- end
68
-
69
- if capturetdo && tdocompare != ''
70
- thiscomparefail = false
71
- numbits.times do |bit|
72
- if tdocompare[numbits - 1 - bit] == 'H'
73
- compareval = 1
74
- elsif tdocompare[numbits - 1 - bit] == 'L'
75
- compareval = 0
76
- else
77
- compareval = @tdoval[bit]
78
- end
79
-
80
- if @tdoval[bit] != compareval
81
- @anytdofail = true
82
- thiscomparefail = true
83
- end
84
- end
85
-
86
- tdovalstr = @tdoval.to_s(2)
87
- tdovalstr = '0' * (numbits - tdovalstr.length) + tdovalstr
88
-
89
- if thiscomparefail
90
- puts '****************************>>>>>>>>>>>>>>>>> TDO failure <<<<<<<<<<<<<<<<<<****************************'
91
- puts 'expected: ' + tdocompare
92
- puts 'received: ' + tdovalstr
93
- else
94
- puts 'TDO compare pass'
95
- puts 'expected: ' + tdocompare
96
- puts 'received: ' + tdovalstr
97
- end
98
- end
99
- end
100
-
101
- def do_ir(numbits, value, options = {})
102
- defaults = {
103
- capturetdo: false,
104
- suppresscomments: false,
105
- tdocompare: ''
106
- }
107
- options = defaults.merge(options)
108
-
109
- if !(options[:suppresscomments]) && @verbose_enable
110
- puts " shift IR, #{numbits} bits, value = 0x" + value.to_s(16)
111
- end
112
-
113
- if options[:tdocompare] != ''
114
- capturetdo = true
115
- else
116
- capturetdo = options[:capturetdo]
117
- end
118
-
119
- # Assume starting from run test idle
120
- # Advance to shift IR
121
- do_cycle(0, 1)
122
- do_cycle(0, 1)
123
- do_cycle(0, 0)
124
- do_cycle(0, 0)
125
-
126
- do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
127
-
128
- # Return to run test idle
129
- do_cycle(0, 1)
130
- do_cycle(0, 0)
131
- end
132
-
133
- def do_dr(numbits, value, options = {})
134
- defaults = {
135
- capturetdo: true,
136
- suppresscomments: false,
137
- tdocompare: ''
138
- }
139
- options = defaults.merge(options)
140
- if !(options[:suppresscomments]) && @verbose_enable
141
- puts " shift DR, #{numbits} bits, value = 0x" + value.to_s(16)
142
- end
143
-
144
- if options[:tdocompare] != ''
145
- capturetdo = true
146
- else
147
- capturetdo = options[:tdocompare]
148
- end
149
-
150
- # Assume starting from run test idle
151
- # Advance to shift DR
152
- do_cycle(0, 1)
153
- do_cycle(0, 0)
154
- do_cycle(0, 0)
155
-
156
- do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
157
-
158
- # Return to run test idle
159
- do_cycle(0, 1)
160
- do_cycle(0, 0)
161
- end
162
-
163
- def pause_dr
164
- do_cycle(0, 1)
165
- do_cycle(0, 0)
166
- do_cycle(0, 0)
167
- do_cycle(0, 1)
168
- do_cycle(0, 0)
169
- do_cycle(0, 1)
170
- do_cycle(0, 1)
171
- do_cycle(0, 0)
172
- end
173
-
174
- def pause_ir
175
- do_cycle(0, 1)
176
- pause_dr
177
- end
178
- end
179
- end
180
- end
1
+ require 'origen_link/server/pin'
2
+
3
+ module OrigenLink
4
+ module Server
5
+ class Jtag
6
+ attr_reader :tdoval
7
+ attr_accessor :verbose_enable
8
+ attr_accessor :anytdofail
9
+
10
+ def initialize(tdiio = 16, tdoio = 23, tmsio = 19, tckio = 26, tck_period = 0.000001)
11
+ @tdipin = Pin.new(tdiio, :out)
12
+ @tdopin = Pin.new(tdoio, :in)
13
+ @tmspin = Pin.new(tmsio, :out)
14
+ @tckpin = Pin.new(tckio, :out)
15
+ @tck_half_period = tck_period / 2
16
+ @tdoval = 0
17
+ @tdostr = ''
18
+ @verbose_enable = true
19
+ @anytdofail = false
20
+ end
21
+
22
+ def tck_period=(value)
23
+ @tck_half_period = value / 2
24
+ end
25
+
26
+ def destroy
27
+ @tdipin.destroy
28
+ @tdopin.destroy
29
+ @tmspin.destroy
30
+ @tckpin.destroy
31
+ @tdipin = nil
32
+ @tdopin = nil
33
+ @tmspin = nil
34
+ @tckpin = nil
35
+ end
36
+
37
+ def do_cycle(tdival, tmsval, capturetdo = false)
38
+ @tdipin.out(tdival)
39
+ @tmspin.out(tmsval)
40
+ sleep @tck_half_period
41
+ @tckpin.out(1)
42
+ sleep @tck_half_period
43
+
44
+ if capturetdo
45
+ @tdostr = @tdopin.in + @tdostr
46
+ end
47
+ @tckpin.out(0)
48
+ end
49
+
50
+ def do_tlr
51
+ 8.times { do_cycle(0, 1) }
52
+ do_cycle(0, 0)
53
+ end
54
+
55
+ def do_shift(numbits, value, capturetdo = false, suppresscomments = false, tdocompare = '')
56
+ @tdoval = 0
57
+ @tdostr = ''
58
+ (numbits - 1).times do |bit|
59
+ do_cycle(value[bit], 0, capturetdo)
60
+ end
61
+ do_cycle(value[numbits - 1], 1, capturetdo)
62
+
63
+ @tdoval = @tdostr.to_i(2) if capturetdo
64
+
65
+ if !(suppresscomments) && @verbose_enable && capturetdo
66
+ puts 'TDO output = 0x' + @tdoval.to_s(16)
67
+ end
68
+
69
+ if capturetdo && tdocompare != ''
70
+ thiscomparefail = false
71
+ numbits.times do |bit|
72
+ if tdocompare[numbits - 1 - bit] == 'H'
73
+ compareval = 1
74
+ elsif tdocompare[numbits - 1 - bit] == 'L'
75
+ compareval = 0
76
+ else
77
+ compareval = @tdoval[bit]
78
+ end
79
+
80
+ if @tdoval[bit] != compareval
81
+ @anytdofail = true
82
+ thiscomparefail = true
83
+ end
84
+ end
85
+
86
+ tdovalstr = @tdoval.to_s(2)
87
+ tdovalstr = '0' * (numbits - tdovalstr.length) + tdovalstr
88
+
89
+ if thiscomparefail
90
+ puts '****************************>>>>>>>>>>>>>>>>> TDO failure <<<<<<<<<<<<<<<<<<****************************'
91
+ puts 'expected: ' + tdocompare
92
+ puts 'received: ' + tdovalstr
93
+ else
94
+ puts 'TDO compare pass'
95
+ puts 'expected: ' + tdocompare
96
+ puts 'received: ' + tdovalstr
97
+ end
98
+ end
99
+ end
100
+
101
+ def do_ir(numbits, value, options = {})
102
+ defaults = {
103
+ capturetdo: false,
104
+ suppresscomments: false,
105
+ tdocompare: ''
106
+ }
107
+ options = defaults.merge(options)
108
+
109
+ if !(options[:suppresscomments]) && @verbose_enable
110
+ puts " shift IR, #{numbits} bits, value = 0x" + value.to_s(16)
111
+ end
112
+
113
+ if options[:tdocompare] != ''
114
+ capturetdo = true
115
+ else
116
+ capturetdo = options[:capturetdo]
117
+ end
118
+
119
+ # Assume starting from run test idle
120
+ # Advance to shift IR
121
+ do_cycle(0, 1)
122
+ do_cycle(0, 1)
123
+ do_cycle(0, 0)
124
+ do_cycle(0, 0)
125
+
126
+ do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
127
+
128
+ # Return to run test idle
129
+ do_cycle(0, 1)
130
+ do_cycle(0, 0)
131
+ end
132
+
133
+ def do_dr(numbits, value, options = {})
134
+ defaults = {
135
+ capturetdo: true,
136
+ suppresscomments: false,
137
+ tdocompare: ''
138
+ }
139
+ options = defaults.merge(options)
140
+ if !(options[:suppresscomments]) && @verbose_enable
141
+ puts " shift DR, #{numbits} bits, value = 0x" + value.to_s(16)
142
+ end
143
+
144
+ if options[:tdocompare] != ''
145
+ capturetdo = true
146
+ else
147
+ capturetdo = options[:tdocompare]
148
+ end
149
+
150
+ # Assume starting from run test idle
151
+ # Advance to shift DR
152
+ do_cycle(0, 1)
153
+ do_cycle(0, 0)
154
+ do_cycle(0, 0)
155
+
156
+ do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
157
+
158
+ # Return to run test idle
159
+ do_cycle(0, 1)
160
+ do_cycle(0, 0)
161
+ end
162
+
163
+ def pause_dr
164
+ do_cycle(0, 1)
165
+ do_cycle(0, 0)
166
+ do_cycle(0, 0)
167
+ do_cycle(0, 1)
168
+ do_cycle(0, 0)
169
+ do_cycle(0, 1)
170
+ do_cycle(0, 1)
171
+ do_cycle(0, 0)
172
+ end
173
+
174
+ def pause_ir
175
+ do_cycle(0, 1)
176
+ pause_dr
177
+ end
178
+ end
179
+ end
180
+ end