origen_link 0.1.0.pre0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,177 @@
1
+ # rubocop:disable Style/For: Prefer each over for.
2
+ require_relative 'pin_interface'
3
+
4
+ class OrigenLinkJtag
5
+ attr_reader :tdoval
6
+ attr_accessor :verbose_enable
7
+ attr_accessor :anytdofail
8
+
9
+ def initialize(tdiio = 16, tdoio = 23, tmsio = 19, tckio = 26, tck_period = 0.000001)
10
+ @tdipin = OrigenLinkPin.new(tdiio, :out_low)
11
+ @tdopin = OrigenLinkPin.new(tdoio, :in)
12
+ @tmspin = OrigenLinkPin.new(tmsio, :out_low)
13
+ @tckpin = OrigenLinkPin.new(tckio, :out_low)
14
+ @tck_half_period = tck_period / 2
15
+ @tdoval = 0
16
+ @tdostr = ''
17
+ @verbose_enable = true
18
+ @anytdofail = false
19
+ end
20
+
21
+ def tck_period=(value)
22
+ @tck_half_period = value / 2
23
+ end
24
+
25
+ def destroy
26
+ @tdipin.destroy
27
+ @tdopin.destroy
28
+ @tmspin.destroy
29
+ @tckpin.destroy
30
+ @tdipin = nil
31
+ @tdopin = nil
32
+ @tmspin = nil
33
+ @tckpin = nil
34
+ end
35
+
36
+ def do_cycle(tdival, tmsval, capturetdo = false)
37
+ @tdipin.out(tdival)
38
+ @tmspin.out(tmsval)
39
+ sleep @tck_half_period
40
+ @tckpin.out(1)
41
+ sleep @tck_half_period
42
+
43
+ if capturetdo
44
+ @tdostr = @tdopin.in + @tdostr
45
+ end
46
+ @tckpin.out(0)
47
+ end
48
+
49
+ def do_tlr
50
+ for step in 1..8 do do_cycle(0, 1) end
51
+ do_cycle(0, 0)
52
+ end
53
+
54
+ def do_shift(numbits, value, capturetdo = false, suppresscomments = false, tdocompare = '')
55
+ @tdoval = 0
56
+ @tdostr = ''
57
+ for bit in 0..numbits - 2 do
58
+ do_cycle(value[bit], 0, capturetdo)
59
+ end
60
+ do_cycle(value[numbits - 1], 1, capturetdo)
61
+
62
+ @tdoval = @tdostr.to_i(2) if capturetdo
63
+
64
+ if !(suppresscomments) && @verbose_enable && capturetdo
65
+ puts 'TDO output = 0x' + @tdoval.to_s(16)
66
+ end
67
+
68
+ if capturetdo && tdocompare != ''
69
+ thiscomparefail = false
70
+ for bit in 0..numbits - 1 do
71
+ if tdocompare[numbits - 1 - bit] == 'H'
72
+ compareval = 1
73
+ elsif tdocompare[numbits - 1 - bit] == 'L'
74
+ compareval = 0
75
+ else
76
+ compareval = @tdoval[bit]
77
+ end
78
+
79
+ if @tdoval[bit] != compareval
80
+ @anytdofail = true
81
+ thiscomparefail = true
82
+ end
83
+ end
84
+
85
+ tdovalstr = @tdoval.to_s(2)
86
+ tdovalstr = '0' * (numbits - tdovalstr.length) + tdovalstr
87
+
88
+ if thiscomparefail
89
+ puts '****************************>>>>>>>>>>>>>>>>> TDO failure <<<<<<<<<<<<<<<<<<****************************'
90
+ puts 'expected: ' + tdocompare
91
+ puts 'received: ' + tdovalstr
92
+ else
93
+ puts 'TDO compare pass'
94
+ puts 'expected: ' + tdocompare
95
+ puts 'received: ' + tdovalstr
96
+ end
97
+ end
98
+ end
99
+
100
+ def do_ir(numbits, value, options = {})
101
+ defaults = {
102
+ capturetdo: false,
103
+ suppresscomments: false,
104
+ tdocompare: ''
105
+ }
106
+ options = defaults.merge(options)
107
+
108
+ if !(options[:suppresscomments]) && @verbose_enable
109
+ puts " shift IR, #{numbits} bits, value = 0x" + value.to_s(16)
110
+ end
111
+
112
+ if options[:tdocompare] != ''
113
+ capturetdo = true
114
+ else
115
+ capturetdo = options[:capturetdo]
116
+ end
117
+
118
+ # Assume starting from run test idle
119
+ # Advance to shift IR
120
+ do_cycle(0, 1)
121
+ do_cycle(0, 1)
122
+ do_cycle(0, 0)
123
+ do_cycle(0, 0)
124
+
125
+ do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
126
+
127
+ # Return to run test idle
128
+ do_cycle(0, 1)
129
+ do_cycle(0, 0)
130
+ end
131
+
132
+ def do_dr(numbits, value, options = {})
133
+ defaults = {
134
+ capturetdo: true,
135
+ suppresscomments: false,
136
+ tdocompare: ''
137
+ }
138
+ options = defaults.merge(options)
139
+ if !(options[:suppresscomments]) && @verbose_enable
140
+ puts " shift DR, #{numbits} bits, value = 0x" + value.to_s(16)
141
+ end
142
+
143
+ if options[:tdocompare] != ''
144
+ capturetdo = true
145
+ else
146
+ capturetdo = options[:tdocompare]
147
+ end
148
+
149
+ # Assume starting from run test idle
150
+ # Advance to shift DR
151
+ do_cycle(0, 1)
152
+ do_cycle(0, 0)
153
+ do_cycle(0, 0)
154
+
155
+ do_shift(numbits, value, capturetdo, options[:suppresscomments], options[:tdocompare])
156
+
157
+ # Return to run test idle
158
+ do_cycle(0, 1)
159
+ do_cycle(0, 0)
160
+ end
161
+
162
+ def pause_dr
163
+ do_cycle(0, 1)
164
+ do_cycle(0, 0)
165
+ do_cycle(0, 0)
166
+ do_cycle(0, 1)
167
+ do_cycle(0, 0)
168
+ do_cycle(0, 1)
169
+ do_cycle(0, 1)
170
+ do_cycle(0, 0)
171
+ end
172
+
173
+ def pause_ir
174
+ do_cycle(0, 1)
175
+ pause_dr
176
+ end
177
+ end
@@ -0,0 +1,134 @@
1
+ # OrigenLinkPin class manipulate input/output pins of the Udoo
2
+ # using exported file objects. If the pin is not exported, it
3
+ # will be exported when a pin is initialized
4
+ #
5
+ # initialize:
6
+ # description - This method will execute system command
7
+ # "sudo echo ionumber > /sys/class/gpio/export"
8
+ # to create the IO file interface. It will
9
+ # set the direction, initial pin state and initialize
10
+ # instance variables
11
+ # ionumber - required, value indicating the pin number (BCM IO number,
12
+ # not the header pin number)
13
+ # direction - optional, specifies the pin direction. A pin is
14
+ # initialized as an input if a direction isn't specified.
15
+ #
16
+ #
17
+ # out:
18
+ # description - Sets the output state of the pin. If the pin
19
+ # is setup as an input, the direction will first
20
+ # be changed to output.
21
+ #
22
+ #
23
+ # in:
24
+ # description - Reads and returns state of the pin. If the pin
25
+ # is setup as an output, the direction will first
26
+ # be changed to input.
27
+ #
28
+ #
29
+ # update_direction:
30
+ # description - Sets the pin direction
31
+ #
32
+ # direction - specifies the pin direction. A pin is
33
+ # initialized as an input if a direction isn't specified.
34
+ #
35
+ # Valid direction values:
36
+ # :in - input
37
+ # :out - output
38
+ # :out_high - output, initialized high
39
+ # :out_low - output, initialized low
40
+ class OrigenLinkPin
41
+ @@pin_setup = {
42
+ in: 'in',
43
+ out: 'out',
44
+ out_high: 'high',
45
+ out_low: 'low'
46
+ }
47
+
48
+ attr_reader :gpio_valid
49
+
50
+ def initialize(ionumber, direction = :in)
51
+ @ionumber = Integer(ionumber)
52
+ @pin_dir_name = "/sys/class/gpio/gpio#{@ionumber}/direction"
53
+ @pin_val_name = "/sys/class/gpio/gpio#{@ionumber}/value"
54
+ if notFile.exist?(@pin_dir_name)
55
+ system("echo #{@ionumber} > /sys/class/gpio/export")
56
+ sleep 0.05
57
+ if $CHILD_STATUS == 0
58
+ @gpio_valid = true
59
+ else
60
+ @gpio_valid = false
61
+ end
62
+ else
63
+ @gpio_valid = true
64
+ end
65
+ if @gpio_valid
66
+ if File.writable?(@pin_dir_name)
67
+ @pin_dir_obj = File.open(@pin_dir_name, 'w')
68
+ update_direction(direction)
69
+ else
70
+ @gpio_valid = false
71
+ puts "#{@pin_dir_name} is not writable. Fix permissions or run as super user."
72
+ end
73
+ @pin_val_obj = File.open(@pin_val_name, 'r+') if @gpio_valid
74
+ end
75
+ end
76
+
77
+ def destroy
78
+ if @gpio_valid
79
+ @pin_dir_obj.close
80
+ @pin_val_obj.close
81
+ system("echo #{@ionumber} > /sys/class/gpio/unexport")
82
+ puts "pin #{@ionumber} is no longer exported"
83
+ end
84
+ end
85
+
86
+ def out(value)
87
+ if @gpio_valid
88
+ if @direction == :in
89
+ if value == 1
90
+ update_direction(:out_high)
91
+ else
92
+ update_direction(:out_low)
93
+ end
94
+ end
95
+ @pin_val_obj.write(value)
96
+ @pin_val_obj.flush
97
+ end
98
+ end
99
+
100
+ # rubocop:disable Style/EmptyElse: Redundant else-clause.
101
+ def in
102
+ if @gpio_valid
103
+ if @direction == :out
104
+ update_direction(:in)
105
+ end
106
+ # below is original read - slow to reopen every time
107
+ # File.open(@pin_val_name, 'r') do |file|
108
+ # file.read#.chomp
109
+ # end
110
+ # end original read
111
+ @pin_val_obj.pos = 0
112
+ @pin_val_obj.getc
113
+ else
114
+ nil
115
+ end
116
+ end
117
+
118
+ def update_direction(direction)
119
+ if @gpio_valid
120
+ @pin_dir_obj.pos = 0
121
+ @pin_dir_obj.write(@@pin_setup[direction])
122
+ @pin_dir_obj.flush
123
+ if direction == :in
124
+ @direction = direction
125
+ else
126
+ @direction = :out
127
+ end
128
+ end
129
+ end
130
+
131
+ def to_s
132
+ 'OrigenLinkPin' + @ionumber.to_s
133
+ end
134
+ end
@@ -0,0 +1,51 @@
1
+ # rubocop:disable Style/FileName: Use snake_case for source file names.
2
+ require_relative '../LinkSequencer'
3
+ require 'test/unit'
4
+
5
+ class TestLinkSequencer < Test::Unit::TestCase
6
+ def test_pinmap
7
+ test_obj = OrigenLinkSequencer.new
8
+ assert_equal('P:', test_obj.processmessage('pin_assign:tck,23'))
9
+ assert_equal('OrigenLinkPin23', test_obj.pinmap['tck'].to_s)
10
+ assert_equal('F:pin tdo gpio1900 is invalid', test_obj.processmessage('pin_assign:tdo,1900'))
11
+ assert_equal('P:', test_obj.processmessage('pin_assign:tck,23'))
12
+ assert_equal('OrigenLinkPin23', test_obj.pinmap['tck'].to_s)
13
+ assert_equal(-1, test_obj.pinmap['tdo'])
14
+ end
15
+
16
+ def test_pinorder
17
+ test_obj2 = OrigenLinkSequencer.new
18
+ assert_equal('P:', test_obj2.processmessage('pin_patternorder:tdi,tdo,tms'))
19
+ assert_equal(%w(tdi tdo tms), test_obj2.patternorder)
20
+ assert_equal({ 'tdi' => 0, 'tdo' => 1, 'tms' => 2 }, test_obj2.patternpinindex)
21
+ assert_equal([%w(tdi tdo tms), [], []], test_obj2.cycletiming[0]['timing'])
22
+ end
23
+
24
+ def test_clear
25
+ end
26
+
27
+ def test_pinformat_timing
28
+ test_obj3 = OrigenLinkSequencer.new
29
+ assert_equal('P:', test_obj3.processmessage('pin_format:1,tck,rl'))
30
+ assert_equal(['tck'], test_obj3.cycletiming[1]['rl'])
31
+ assert_equal(nil, test_obj3.cycletiming[1]['rh'])
32
+
33
+ assert_equal('P:', test_obj3.processmessage('pin_format:1,xtal,rh'))
34
+ assert_equal(nil, test_obj3.cycletiming[1]['rl'])
35
+ assert_equal(['xtal'], test_obj3.cycletiming[1]['rh'])
36
+
37
+ assert_equal('P:', test_obj3.processmessage('pin_format:2,tck,rl'))
38
+ assert_equal(['tck'], test_obj3.cycletiming[2]['rl'])
39
+ assert_equal(nil, test_obj3.cycletiming[2]['rh'])
40
+ assert_equal(nil, test_obj3.cycletiming[1]['rl'])
41
+ assert_equal(['xtal'], test_obj3.cycletiming[1]['rh'])
42
+
43
+ assert_equal('P:', test_obj3.processmessage('pin_timing:1,tdi,0,tms,1,tdo,2'))
44
+ assert_equal(['tck'], test_obj3.cycletiming[2]['rl'])
45
+ assert_equal(nil, test_obj3.cycletiming[2]['rh'])
46
+ assert_equal(nil, test_obj3.cycletiming[1]['rl'])
47
+ assert_equal(['xtal'], test_obj3.cycletiming[1]['rh'])
48
+ assert_equal([['tdi'], ['tms'], ['tdo']], test_obj3.cycletiming[1]['timing'])
49
+ assert_equal([[], [], []], test_obj3.cycletiming[2]['timing'])
50
+ end
51
+ end
@@ -0,0 +1,6 @@
1
+ # You can define any Rake tasks to support your application here (or in any file
2
+ # ending in .rake in this directory).
3
+ #
4
+ # Rake (Ruby Make) is very useful for creating build scripts, see this short video
5
+ # for a quick introduction:
6
+ # http://railscasts.com/episodes/66-custom-rake-tasks
@@ -0,0 +1,4 @@
1
+ Pattern.create do
2
+ # Call controller methods from here...
3
+ # $dut.atd.convert
4
+ end
@@ -0,0 +1,14 @@
1
+ Pattern.create(options={:name => "JTAG_Test"})do
2
+ $dut.jtag.reset
3
+ $dut.jtag.idle
4
+ 1.upto(50) do
5
+ ss "reading Halo debugger ID"
6
+ $dut.jtag.write_ir 0xe, size: 4
7
+ $dut.reg(:testreg).read(0x5ba00477)
8
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
9
+ $dut.jtag.write_ir 0, size: 4
10
+ ss "reading Halo JTAG ID"
11
+ $dut.reg(:testreg).read(0x1984101d)
12
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ Pattern.create(options={:name => "JTAG_Test_Force_Fail"})do
2
+ $dut.jtag.reset
3
+ $dut.jtag.idle
4
+ ss "reading Halo debugger ID - setting wrong compare value"
5
+ #$dut.reg(:testreg).read(0x5ba00477)
6
+ $dut.reg(:testreg).read(0x5bd00477)
7
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
8
+ $dut.jtag.write_ir 0, size: 4
9
+ ss "reading Halo JTAG ID - setting wrong compare value"
10
+ #$dut.reg(:testreg).read(0x1984101d)
11
+ $dut.reg(:testreg).read(0x1984101a)
12
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
13
+ end
@@ -0,0 +1,11 @@
1
+ Pattern.create(options={:name => "JTAG_Test"})do
2
+ $dut.jtag.reset
3
+ $dut.jtag.idle
4
+ ss "reading Halo debugger ID"
5
+ $dut.reg(:testreg).read(0x5ba00477)
6
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
7
+ $dut.jtag.write_ir 0, size: 4
8
+ ss "reading Halo JTAG ID"
9
+ $dut.reg(:testreg).read(0x1984101d)
10
+ $dut.jtag.read_dr $dut.reg(:testreg), size: 32
11
+ end
@@ -0,0 +1,19 @@
1
+ % render "layouts/basic.html" do
2
+
3
+ %# HTML tags can be embedded in mark down files if you want to do specific custom
4
+ %# formatting like this, but in most cases that is not required.
5
+ <h1><%= Origen.app.namespace %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
6
+
7
+ ### Purpose
8
+
9
+ This application...
10
+
11
+ ### How To Use
12
+
13
+ Add quickstart documentation here...
14
+
15
+ ### How To Setup the Application Environment
16
+
17
+ Describe how a user would setup a new workspace for this application...
18
+
19
+ % end
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: <%= options[:title] || Origen.config.name %>
3
+ ---
4
+ <%= render "partials/navbar.html", tab: options[:tab] %>
5
+
6
+ <div class="row">
7
+ %# The markdown attribute is important if you are going to include content written
8
+ %# in markdown, without this is will be included verbatim
9
+ <div class="span12" markdown="1">
10
+ <%= yield %>
11
+
12
+ </div>
13
+ </div>
@@ -0,0 +1,20 @@
1
+ <nav class="navbar navbar-inverse navbar-fixed-top">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
5
+ <span class="sr-only">Toggle navigation</span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ </button>
10
+ <a class="navbar-brand" href="<%= path "/" %>">Home</a>
11
+ </div>
12
+ <div id="navbar" class="collapse navbar-collapse">
13
+ <ul class="nav navbar-nav">
14
+ <li class="<%= options[:tab] == :api ? 'active' : '' %>"><a href="<%= path "/api/" %>">API</a></li>
15
+ <li class="<%= options[:tab] == :release ? 'active' : '' %>"><a href="<%= path "/release_notes" %>">Release Notes</a></li>
16
+ </ul>
17
+ <%= import "origen/web/logo.html" %>
18
+ </div><!--/.nav-collapse -->
19
+ </div>
20
+ </nav>
@@ -0,0 +1,5 @@
1
+ % render "layouts/basic.html", tab: :release do
2
+
3
+ <%= render "#{Origen.root}/doc/history" %>
4
+
5
+ % end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: origen_link
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Derouen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: origen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: origen_testers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: origen_jtag
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: origen_doc_helpers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - paul.derouen@nxp.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - config/application.rb
77
+ - config/boot.rb
78
+ - config/commands.rb
79
+ - config/version.rb
80
+ - lib/origen_link.rb
81
+ - lib/origen_link/includes_vector_based.rb
82
+ - lib/origen_link/test/regression_tests.rb
83
+ - lib/origen_link/test/test_dut.rb
84
+ - lib/origen_link/test/test_dut_controller.rb
85
+ - lib/origen_link/test/vector_based_redefs.rb
86
+ - lib/origen_link/vector_based.rb
87
+ - lib/origen_link_server/LinkSequencer.rb
88
+ - lib/origen_link_server/LinkTCPServer.rb
89
+ - lib/origen_link_server/jtag_interface.rb
90
+ - lib/origen_link_server/pin_interface.rb
91
+ - lib/origen_link_server/test/test_Sequencer.rb
92
+ - lib/tasks/origen_link.rake
93
+ - pattern/example.rb
94
+ - pattern/jtag_100_operations.rb
95
+ - pattern/jtag_comm_fail_test.rb
96
+ - pattern/jtag_comm_test.rb
97
+ - templates/web/index.md.erb
98
+ - templates/web/layouts/_basic.html.erb
99
+ - templates/web/partials/_navbar.html.erb
100
+ - templates/web/release_notes.md.erb
101
+ homepage: http://origen-sdk.org/OrigenLink
102
+ licenses: []
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.9.3
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.11
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.2.2
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Origen interface to a live DUT tester
124
+ test_files: []
125
+ has_rdoc: