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