origen_link 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,154 +1,154 @@
1
- module OrigenLink
2
- module ServerCom
3
- # send a single command to the server
4
- #
5
- # send_cmd(cmdstr, argstr)
6
- # cmdstr is a valid command. <category>_<command>
7
- # Ex: 'pin_assign'
8
- # argstr is a valid comma separated, no white space argument string.
9
- # Ex: 'tclk,26,tms,19,tdi,16,tdo,23'
10
- #
11
- # returns: response from server
12
- #
13
- # This method connects to the socket being served by the debugger, sends
14
- # the command and arguments separated by a semicolon (Ex: 'pin_cycle:110H'),
15
- # then waits for a response. The response is returned to the caller.
16
- #
17
- # In addition, this method also keeps track of time elapsed transfering data
18
- # and waiting for a response.
19
- def send_cmd(cmdstr, argstr)
20
- # objects have to be created outside of the block
21
- # to be accessible outside of the block
22
- t1 = 0
23
- t2 = 0
24
- t3 = 0
25
- t4 = 0
26
- t5 = 0
27
- response = ''
28
- user_status = ''
29
- success = false
30
-
31
- until success
32
- t1 = Time.now
33
-
34
- # open a connection to the server, send the command and wait for a response
35
- TCPSocket.open(@address, @port) do |link|
36
- t2 = Time.now
37
- link.write(@user_name + "\n" + cmdstr + ':' + argstr + "\n\n")
38
- t3 = Time.now
39
- user_status = link.gets
40
- response = link.gets
41
- t4 = Time.now
42
- end
43
-
44
- t5 = Time.now
45
-
46
- if @initial_comm_sent && ((user_status =~ /user_change/) || (response =~ /Busy:/))
47
- # there has been a collision
48
- Origen.log.error 'A collision (another user interrupted your link session) has occured'
49
- Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
50
- exit
51
- end
52
-
53
- if response =~ /Busy:/
54
- Origen.log.error response + ' retry in 1 second'
55
- sleep(1)
56
- else
57
- success = true
58
- @initial_comm_sent = true
59
- end
60
- end
61
-
62
- @total_comm_time += (t5 - t1)
63
- if @max_packet_time < (t5 - t1)
64
- @max_packet_time = (t5 - t1)
65
- @longest_packet = cmdstr + ':' + argstr
66
- end
67
- @total_connect_time += (t2 - t1)
68
- @total_xmit_time += (t3 - t2)
69
- @total_recv_time += (t4 - t3)
70
- @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
71
- @total_packets += 1
72
- Origen.log.error 'nil response from server (likely died) for command(' + cmdstr + ':' + argstr + ')' if response.nil?
73
- @pattern_link_messages << "#{cmdstr}:#{argstr}"
74
- response # ensure the response is passed along
75
- end
76
-
77
- # Send the stored batch of vectors to the server
78
- def send_batch(vector_batch)
79
- vector_batch_str = @user_name + "\n" + vector_batch.join("\n") + "\n\n"
80
- user_status = ''
81
- success = false
82
-
83
- until success
84
- t1 = 0
85
- t2 = 0
86
- t3 = 0
87
- t4 = 0
88
- t5 = 0
89
- response = []
90
- t1 = Time.now
91
- TCPSocket.open(@address, @port) do |link|
92
- t2 = Time.now
93
- link.write(vector_batch_str)
94
- t3 = Time.now
95
- while line = link.gets
96
- response << line.chomp
97
- end
98
- t4 = Time.now
99
- end
100
- t5 = Time.now
101
-
102
- user_status = response.delete_at(0)
103
- if @initial_comm_sent && ((user_status =~ /user_change/) || (response[0] =~ /Busy:/))
104
- # there has been a collision
105
- Origen.log.error 'A collision (another user interrupted your link session) has occured'
106
- Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
107
- exit
108
- end
109
-
110
- if response[0] =~ /Busy:/
111
- Origen.log.error response[0] + ' retry in 1 second'
112
- sleep(1)
113
- else
114
- success = true
115
- @initial_comm_sent = true
116
- end
117
-
118
- end
119
-
120
- @total_comm_time += (t5 - t1)
121
- @total_connect_time += (t2 - t1)
122
- @total_xmit_time += (t3 - t2)
123
- @total_recv_time += (t4 - t3)
124
- @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
125
- @total_packets += 1
126
- @pattern_link_messages.concat(vector_batch)
127
- response
128
- end
129
-
130
- # Handle a server response (inform of Failures)
131
- #
132
- # There are several setup commands that initialize the debugger device with
133
- # information about how to interact with the dut. All of the setup commands
134
- # return pass or fail. This method exists so that the code doesn't have to
135
- # be duplicated by every setup method.
136
- def setup_cmd_response_logger(command, response)
137
- if !response.nil?
138
- # if the server died (which hopefully it never will) response is nil
139
- case response.chr
140
- when 'P'
141
- Origen.log.debug command + ' setup was successful'
142
- when 'F'
143
- Origen.log.error command + ' setup FAILED with the following message:'
144
- Origen.log.error response.chomp
145
- else
146
- Origen.log.error 'Non standard response from ' + command + ' setup: ' + response
147
- end
148
- else
149
- # response was nil. The server died
150
- Origen.log.error command + ' caused a nil response. The server likely died.'
151
- end
152
- end
153
- end
154
- end
1
+ module OrigenLink
2
+ module ServerCom
3
+ # send a single command to the server
4
+ #
5
+ # send_cmd(cmdstr, argstr)
6
+ # cmdstr is a valid command. <category>_<command>
7
+ # Ex: 'pin_assign'
8
+ # argstr is a valid comma separated, no white space argument string.
9
+ # Ex: 'tclk,26,tms,19,tdi,16,tdo,23'
10
+ #
11
+ # returns: response from server
12
+ #
13
+ # This method connects to the socket being served by the debugger, sends
14
+ # the command and arguments separated by a semicolon (Ex: 'pin_cycle:110H'),
15
+ # then waits for a response. The response is returned to the caller.
16
+ #
17
+ # In addition, this method also keeps track of time elapsed transfering data
18
+ # and waiting for a response.
19
+ def send_cmd(cmdstr, argstr)
20
+ # objects have to be created outside of the block
21
+ # to be accessible outside of the block
22
+ t1 = 0
23
+ t2 = 0
24
+ t3 = 0
25
+ t4 = 0
26
+ t5 = 0
27
+ response = ''
28
+ user_status = ''
29
+ success = false
30
+
31
+ until success
32
+ t1 = Time.now
33
+
34
+ # open a connection to the server, send the command and wait for a response
35
+ TCPSocket.open(@address, @port) do |link|
36
+ t2 = Time.now
37
+ link.write(@user_name + "\n" + cmdstr + ':' + argstr + "\n\n")
38
+ t3 = Time.now
39
+ user_status = link.gets
40
+ response = link.gets
41
+ t4 = Time.now
42
+ end
43
+
44
+ t5 = Time.now
45
+
46
+ if @initial_comm_sent && ((user_status =~ /user_change/) || (response =~ /Busy:/))
47
+ # there has been a collision
48
+ Origen.log.error 'A collision (another user interrupted your link session) has occured'
49
+ Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
50
+ exit
51
+ end
52
+
53
+ if response =~ /Busy:/
54
+ Origen.log.error response + ' retry in 1 second'
55
+ sleep(1)
56
+ else
57
+ success = true
58
+ @initial_comm_sent = true
59
+ end
60
+ end
61
+
62
+ @total_comm_time += (t5 - t1)
63
+ if @max_packet_time < (t5 - t1)
64
+ @max_packet_time = (t5 - t1)
65
+ @longest_packet = cmdstr + ':' + argstr
66
+ end
67
+ @total_connect_time += (t2 - t1)
68
+ @total_xmit_time += (t3 - t2)
69
+ @total_recv_time += (t4 - t3)
70
+ @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
71
+ @total_packets += 1
72
+ Origen.log.error 'nil response from server (likely died) for command(' + cmdstr + ':' + argstr + ')' if response.nil?
73
+ @pattern_link_messages << "#{cmdstr}:#{argstr}"
74
+ response # ensure the response is passed along
75
+ end
76
+
77
+ # Send the stored batch of vectors to the server
78
+ def send_batch(vector_batch)
79
+ vector_batch_str = @user_name + "\n" + vector_batch.join("\n") + "\n\n"
80
+ user_status = ''
81
+ success = false
82
+
83
+ until success
84
+ t1 = 0
85
+ t2 = 0
86
+ t3 = 0
87
+ t4 = 0
88
+ t5 = 0
89
+ response = []
90
+ t1 = Time.now
91
+ TCPSocket.open(@address, @port) do |link|
92
+ t2 = Time.now
93
+ link.write(vector_batch_str)
94
+ t3 = Time.now
95
+ while line = link.gets
96
+ response << line.chomp
97
+ end
98
+ t4 = Time.now
99
+ end
100
+ t5 = Time.now
101
+
102
+ user_status = response.delete_at(0)
103
+ if @initial_comm_sent && ((user_status =~ /user_change/) || (response[0] =~ /Busy:/))
104
+ # there has been a collision
105
+ Origen.log.error 'A collision (another user interrupted your link session) has occured'
106
+ Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
107
+ exit
108
+ end
109
+
110
+ if response[0] =~ /Busy:/
111
+ Origen.log.error response[0] + ' retry in 1 second'
112
+ sleep(1)
113
+ else
114
+ success = true
115
+ @initial_comm_sent = true
116
+ end
117
+
118
+ end
119
+
120
+ @total_comm_time += (t5 - t1)
121
+ @total_connect_time += (t2 - t1)
122
+ @total_xmit_time += (t3 - t2)
123
+ @total_recv_time += (t4 - t3)
124
+ @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
125
+ @total_packets += 1
126
+ @pattern_link_messages.concat(vector_batch)
127
+ response
128
+ end
129
+
130
+ # Handle a server response (inform of Failures)
131
+ #
132
+ # There are several setup commands that initialize the debugger device with
133
+ # information about how to interact with the dut. All of the setup commands
134
+ # return pass or fail. This method exists so that the code doesn't have to
135
+ # be duplicated by every setup method.
136
+ def setup_cmd_response_logger(command, response)
137
+ if !response.nil?
138
+ # if the server died (which hopefully it never will) response is nil
139
+ case response.chr
140
+ when 'P'
141
+ Origen.log.debug command + ' setup was successful'
142
+ when 'F'
143
+ Origen.log.error command + ' setup FAILED with the following message:'
144
+ Origen.log.error response.chomp
145
+ else
146
+ Origen.log.error 'Non standard response from ' + command + ' setup: ' + response
147
+ end
148
+ else
149
+ # response was nil. The server died
150
+ Origen.log.error command + ' caused a nil response. The server likely died.'
151
+ end
152
+ end
153
+ end
154
+ end
@@ -1,48 +1,48 @@
1
- module OrigenLink
2
- module Test
3
- class TopLevel
4
- include Origen::TopLevel
5
-
6
- def initialize(options = {})
7
- instantiate_pins(options)
8
- instantiate_registers(options)
9
- instantiate_sub_blocks(options)
10
- end
11
-
12
- def instantiate_pins(options = {})
13
- options = {
14
- jtag_comm_config: false,
15
- invalid_pin_number_test: false,
16
- missing_pinmap_test: false
17
- }.merge(options)
18
- add_pin :tclk, meta: { link_io: 119 }
19
- add_pin :tdi, meta: { link_io: 116 }
20
- add_pin :tdo, meta: { link_io: 124 }
21
- add_pin :tms, meta: { link_io: 6 }
22
- add_pin :resetb
23
- add_pins :port_a, size: 8
24
-
25
- pin_pattern_order :tclk, :tms, :tdi, :tdo, only: true if options[:jtag_comm_config]
26
-
27
- # if tester.link? #.to_s == 'OrigenLink::VectorBased'
28
- if tester.to_s == 'OrigenLink::VectorBased'
29
- if options[:invalid_pin_number_test]
30
- tester.pinmap = 'tclk,119,tms,1900,tdi,116,tdo,124'
31
- else
32
- tester.pinmap = 'tclk,119,tms,6,tdi,116,tdo,124' unless options[:missing_pinmap_test]
33
- end
34
- # tester.pinorder = 'tclk,tms,tdi,tdo'
35
- end
36
- end
37
-
38
- def instantiate_registers(options = {})
39
- reg :testreg, 0 do |reg|
40
- reg.bits 31..0, :value
41
- end
42
- end
43
-
44
- def instantiate_sub_blocks(options = {})
45
- end
46
- end
47
- end
48
- end
1
+ module OrigenLink
2
+ module Test
3
+ class TopLevel
4
+ include Origen::TopLevel
5
+
6
+ def initialize(options = {})
7
+ instantiate_pins(options)
8
+ instantiate_registers(options)
9
+ instantiate_sub_blocks(options)
10
+ end
11
+
12
+ def instantiate_pins(options = {})
13
+ options = {
14
+ jtag_comm_config: false,
15
+ invalid_pin_number_test: false,
16
+ missing_pinmap_test: false
17
+ }.merge(options)
18
+ add_pin :tclk, meta: { link_io: 119 }
19
+ add_pin :tdi, meta: { link_io: 116 }
20
+ add_pin :tdo, meta: { link_io: 124 }
21
+ add_pin :tms, meta: { link_io: 6 }
22
+ add_pin :resetb
23
+ add_pins :port_a, size: 8
24
+
25
+ pin_pattern_order :tclk, :tms, :tdi, :tdo, only: true if options[:jtag_comm_config]
26
+
27
+ # if tester.link? #.to_s == 'OrigenLink::VectorBased'
28
+ if tester.to_s == 'OrigenLink::VectorBased'
29
+ if options[:invalid_pin_number_test]
30
+ tester.pinmap = 'tclk,119,tms,1900,tdi,116,tdo,124'
31
+ else
32
+ tester.pinmap = 'tclk,119,tms,6,tdi,116,tdo,124' unless options[:missing_pinmap_test]
33
+ end
34
+ # tester.pinorder = 'tclk,tms,tdi,tdo'
35
+ end
36
+ end
37
+
38
+ def instantiate_registers(options = {})
39
+ reg :testreg, 0 do |reg|
40
+ reg.bits 31..0, :value
41
+ end
42
+ end
43
+
44
+ def instantiate_sub_blocks(options = {})
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,46 +1,46 @@
1
- require 'origen_jtag'
2
-
3
- module OrigenLink
4
- module Test
5
- class TopLevelController
6
- include Origen::Controller
7
-
8
- include OrigenJTAG
9
-
10
- JTAG_CONFIG = {
11
- tclk_format: :rl,
12
- # tclk_format: :rh,
13
- tclk_multiple: 1,
14
- # tclk_multiple: 4,
15
- tdo_strobe: :tclk_high,
16
- # tdo_store_cycle: 3,
17
- init_state: :idle
18
- }
19
-
20
- def startup(options)
21
- pp 'Enter test mode' do
22
- # if tester.link?
23
- if tester.to_s == 'OrigenLink::VectorBased'
24
- # tester.initialize_pattern
25
- # below is for testing return format timing, requires tclk to be rl and multiple of 1
26
- tester.pinformat = 'func_25mhz,tclk,rl'
27
- tester.pintiming = 'func_25mhz,tdi,0,tms,0,tdo,1'
28
- end
29
- tester.set_timeset('func_25mhz', 40) # Where 40 is the period in ns
30
- tester.wait time_in_us: 100
31
- end
32
- end
33
-
34
- def shutdown(options)
35
- pp 'Reset the device' do
36
- pin(:resetb).drive!(0)
37
- pin(:tclk).drive!(0)
38
- end
39
- # if tester.link?
40
- if tester.to_s == 'OrigenLink::VectorBased'
41
- # tester.finalize_pattern
42
- end
43
- end
44
- end
45
- end
46
- end
1
+ require 'origen_jtag'
2
+
3
+ module OrigenLink
4
+ module Test
5
+ class TopLevelController
6
+ include Origen::Controller
7
+
8
+ include OrigenJTAG
9
+
10
+ JTAG_CONFIG = {
11
+ tclk_format: :rl,
12
+ # tclk_format: :rh,
13
+ tclk_multiple: 1,
14
+ # tclk_multiple: 4,
15
+ tdo_strobe: :tclk_high,
16
+ # tdo_store_cycle: 3,
17
+ init_state: :idle
18
+ }
19
+
20
+ def startup(options)
21
+ pp 'Enter test mode' do
22
+ # if tester.link?
23
+ if tester.to_s == 'OrigenLink::VectorBased'
24
+ # tester.initialize_pattern
25
+ # below is for testing return format timing, requires tclk to be rl and multiple of 1
26
+ tester.pinformat = 'func_25mhz,tclk,rl'
27
+ tester.pintiming = 'func_25mhz,tdi,0,tms,0,tdo,1'
28
+ end
29
+ tester.set_timeset('func_25mhz', 40) # Where 40 is the period in ns
30
+ tester.wait time_in_us: 100
31
+ end
32
+ end
33
+
34
+ def shutdown(options)
35
+ pp 'Reset the device' do
36
+ pin(:resetb).drive!(0)
37
+ pin(:tclk).drive!(0)
38
+ end
39
+ # if tester.link?
40
+ if tester.to_s == 'OrigenLink::VectorBased'
41
+ # tester.finalize_pattern
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end