ruby-adept 1.0.3 → 1.1.0

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.
data/bin/bprog CHANGED
@@ -145,6 +145,25 @@ def configure_fpga(jtag, bitstream)
145
145
 
146
146
  end
147
147
 
148
+ #
149
+ # Configures the first connected PROM with the provided bitstream.
150
+ #
151
+ def configure_prom(jtag, bitstream)
152
+
153
+ #
154
+ # TEMPORARY CODE ONLY!
155
+ # Replace me at the soonest opportunity.
156
+ #
157
+ jtag.close
158
+ jtag.device.close
159
+
160
+ #Delegate PROM programming to the Digilent utility.
161
+ Core.class_eval do
162
+ with_temporary_files(bitstream.to_s, '', '.bit') { |_, source| system("djtgcfg prog -d Basys2 -i 1 -f #{source}") }
163
+ end
164
+
165
+ end
166
+
148
167
  #
149
168
  # Displays a list of available cores.
150
169
  #
@@ -171,7 +190,7 @@ end
171
190
  # Merge the provided file into the specified core, and return the resultant
172
191
  # bitstream.
173
192
  #
174
- def merge_file_and_core(core_name, file, target=nil)
193
+ def merge_file_and_core(core_name, file, target=nil, prom=false)
175
194
 
176
195
  #... try to find a core with the given name.
177
196
  core = Core.from_shortname(core_name)
@@ -186,8 +205,12 @@ def merge_file_and_core(core_name, file, target=nil)
186
205
  puts "Merging".bold + " #{File.basename(file)} into the #{core.shortname} core..."
187
206
  end
188
207
 
208
+ #If we're going to be programming the PROM, keep everythin in the raw string format.
209
+ #TODO: Remove me when the PROM is implemented correctly!
210
+ file_format = prom ? :to_raw_bitstream : :to_bitstream
211
+
189
212
  #Create a bitstream from the given core.
190
- file = core.to_bitstream(target, file)
213
+ file = core.send(file_format, target, file, prom)
191
214
 
192
215
  #Notify the user that programming is about to begin.
193
216
  puts "Programming".bold + " the attached board with the #{core.shortname} core..."
@@ -222,6 +245,7 @@ options = Trollop::options do
222
245
 
223
246
  opt :core, "Specifies a soft-core to use. If a compiled program is provided, it will be merged into the specified core.", :type => String
224
247
  opt :'list-cores', "Display a list of all available processor cores."
248
+ opt :prom, "Programs the given file to the PROM of the given board, when possible."
225
249
 
226
250
  end
227
251
 
@@ -239,6 +263,7 @@ connection = get_target_connection(options[:'list-cores'])
239
263
  # Get the name of the connected FPGA, if applicable.
240
264
  part_name = connected_fpga_part_name(connection)
241
265
 
266
+
242
267
  #If the list_available_cores flag is set, list the compatible cores,
243
268
  #
244
269
  #and quit.
@@ -255,13 +280,18 @@ file = get_target_file(do_not_guess, allow_none)
255
280
  # If the core option was specified, attempt to merge it with the provided
256
281
  # filename. (If no filename was provided, the core's bitstream will be returned.)
257
282
  if options[:core]
258
- file = merge_file_and_core(options[:core], file, part_name)
283
+ file = merge_file_and_core(options[:core], file, part_name, options[:prom])
259
284
 
260
285
  # Otherwise, read the file as a bitstream directly.
261
286
  else
262
287
  file = read_bitstream(file)
263
288
  end
264
289
 
290
+ if options[:prom]
291
+ configure_prom(connection, file)
292
+ exit!
293
+ end
294
+
265
295
  begin
266
296
  configure_fpga(connection, file)
267
297
  rescue Error => e
Binary file
@@ -1,6 +1,6 @@
1
1
  // BMM LOC annotation file.
2
2
  //
3
- // Release 14.1 - P.49d, build 2.8 Mar 16, 2012
3
+ // Release 13.2 - Data2MEM O.61xd, build 2.2 May 20, 2011
4
4
  // Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
5
5
 
6
6
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  ADDRESS_MAP avrmap PPC405 0
14
14
 
15
+
15
16
  ///////////////////////////////////////////////////////////////////////////////
16
17
  //
17
18
  // Processor 'avrmap' address space 'rom_code' 0x00000000:0x00003FFF (16 KBytes).
@@ -20,35 +21,35 @@ ADDRESS_MAP avrmap PPC405 0
20
21
 
21
22
  ADDRESS_SPACE rom_code RAMB16 [0x00000000:0x00003FFF]
22
23
  BUS_BLOCK
23
- PM_Inst/RAM_Word0 RAMB16 [15:0] [0:1023] PLACED = X0Y3;
24
+ PM_Inst/RAM_Word0 [15:0] PLACED = X1Y1;
24
25
  END_BUS_BLOCK;
25
26
 
26
27
  BUS_BLOCK
27
- PM_Inst/RAM_Word1 RAMB16 [15:0] [1024:2047] PLACED = X1Y2;
28
+ PM_Inst/RAM_Word1 [15:0] PLACED = X1Y4;
28
29
  END_BUS_BLOCK;
29
30
 
30
31
  BUS_BLOCK
31
- PM_Inst/RAM_Word2 RAMB16 [15:0] [2048:3071] PLACED = X0Y2;
32
+ PM_Inst/RAM_Word2 [15:0] PLACED = X1Y2;
32
33
  END_BUS_BLOCK;
33
34
 
34
35
  BUS_BLOCK
35
- PM_Inst/RAM_Word3 RAMB16 [15:0] [3072:4095] PLACED = X1Y1;
36
+ PM_Inst/RAM_Word3 [15:0] PLACED = X1Y3;
36
37
  END_BUS_BLOCK;
37
38
 
38
39
  BUS_BLOCK
39
- PM_Inst/RAM_Word4 RAMB16 [15:0] [4096:5119] PLACED = X1Y4;
40
+ PM_Inst/RAM_Word4 [15:0] PLACED = X0Y3;
40
41
  END_BUS_BLOCK;
41
42
 
42
43
  BUS_BLOCK
43
- PM_Inst/RAM_Word5 RAMB16 [15:0] [5120:6143] PLACED = X1Y3;
44
+ PM_Inst/RAM_Word5 [15:0] PLACED = X1Y5;
44
45
  END_BUS_BLOCK;
45
46
 
46
47
  BUS_BLOCK
47
- PM_Inst/RAM_Word6 RAMB16 [15:0] [6144:7167] PLACED = X0Y1;
48
+ PM_Inst/RAM_Word6 [15:0] PLACED = X1Y0;
48
49
  END_BUS_BLOCK;
49
50
 
50
51
  BUS_BLOCK
51
- PM_Inst/RAM_Word7 RAMB16 [15:0] [7168:8191] PLACED = X0Y0;
52
+ PM_Inst/RAM_Word7 [15:0] PLACED = X0Y2;
52
53
  END_BUS_BLOCK;
53
54
  END_ADDRESS_SPACE;
54
55
 
@@ -0,0 +1,57 @@
1
+ // BMM LOC annotation file.
2
+ //
3
+ // Release 13.2 - Data2MEM O.61xd, build 2.2 May 20, 2011
4
+ // Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
5
+
6
+
7
+ ///////////////////////////////////////////////////////////////////////////////
8
+ //
9
+ // Processor 'avrmap', ID 0, memory map.
10
+ //
11
+ ///////////////////////////////////////////////////////////////////////////////
12
+
13
+ ADDRESS_MAP avrmap PPC405 0
14
+
15
+
16
+ ///////////////////////////////////////////////////////////////////////////////
17
+ //
18
+ // Processor 'avrmap' address space 'rom_code' 0x00000000:0x00003FFF (16 KBytes).
19
+ //
20
+ ///////////////////////////////////////////////////////////////////////////////
21
+
22
+ ADDRESS_SPACE rom_code RAMB16 [0x00000000:0x00003FFF]
23
+ BUS_BLOCK
24
+ PM_Inst/RAM_Word0 [15:0] PLACED = X1Y1;
25
+ END_BUS_BLOCK;
26
+
27
+ BUS_BLOCK
28
+ PM_Inst/RAM_Word1 [15:0] PLACED = X1Y4;
29
+ END_BUS_BLOCK;
30
+
31
+ BUS_BLOCK
32
+ PM_Inst/RAM_Word2 [15:0] PLACED = X1Y2;
33
+ END_BUS_BLOCK;
34
+
35
+ BUS_BLOCK
36
+ PM_Inst/RAM_Word3 [15:0] PLACED = X1Y3;
37
+ END_BUS_BLOCK;
38
+
39
+ BUS_BLOCK
40
+ PM_Inst/RAM_Word4 [15:0] PLACED = X0Y3;
41
+ END_BUS_BLOCK;
42
+
43
+ BUS_BLOCK
44
+ PM_Inst/RAM_Word5 [15:0] PLACED = X1Y5;
45
+ END_BUS_BLOCK;
46
+
47
+ BUS_BLOCK
48
+ PM_Inst/RAM_Word6 [15:0] PLACED = X1Y0;
49
+ END_BUS_BLOCK;
50
+
51
+ BUS_BLOCK
52
+ PM_Inst/RAM_Word7 [15:0] PLACED = X0Y2;
53
+ END_BUS_BLOCK;
54
+ END_ADDRESS_SPACE;
55
+
56
+ END_ADDRESS_MAP;
57
+
@@ -1,11 +1,17 @@
1
1
  name: ATMega103-compatible AVR
2
2
  shortname: atmega103
3
- version: 1.0
3
+ version: 1.1
4
4
  targets:
5
5
 
6
6
  #Spartan 3E 250K-gate
7
7
  3s250ecp132:
8
+
9
+ #JTAG Clock (via USB)
8
10
  bit_file: avr_250k.bit
9
11
  memory_map: avr_250k.bmm
12
+
13
+ #Confiuration Clock (via PROM)
14
+ bit_file_prom: avr_250k_prom.bit
15
+ memory_map_prom: avr_250k_prom.bmm
10
16
 
11
17
 
@@ -75,19 +75,24 @@ module Adept
75
75
  end
76
76
 
77
77
  #
78
- # Returns a bitstream which can be use to load the given core onto the target
79
- # device. If a program is provided, it will be loaded into the resultant bitstream.
78
+ # Returns a byte-string encoded bitstream which can be use to load the given core
79
+ # onto the target device. If a program is provided, it will be loaded into the resultant bitstream.
80
80
  #
81
81
  # target: The Device ID string of the board to be programmed.
82
+ # program: The program that should be merged into the core.
83
+ # prom: If true, the PROM version of this core will be used.
82
84
  #
83
- def to_bitstream(target=@targets.keys.first, program=nil)
85
+ def to_raw_bitstream(target=@targets.keys.first, program=nil, prom=false)
84
86
 
85
87
  #Ensure the target is a string.
86
88
  target = target.to_s
87
89
 
90
+ #If we're in PROM mode, use the prom versions of the configured files.
91
+ suffix = prom ? '_prom' : '';
92
+
88
93
  #Get the path to the bitfile and memory map which will be used to generate the new bitfile.
89
- memory_map = "#@base_path/#{@targets[target]['memory_map']}"
90
- bit_file = "#@base_path/#{@targets[target]['bit_file']}"
94
+ memory_map = "#@base_path/#{@targets[target]["memory_map#{suffix}"]}"
95
+ bit_file = "#@base_path/#{@targets[target]["bit_file#{suffix}"]}"
91
96
 
92
97
  #If no program was provided, return the bitfile unmodified.
93
98
  return Adept::DataFormats::Bitstream.from_file(bit_file) unless program
@@ -97,11 +102,21 @@ module Adept
97
102
  mem = with_temporary_files(hex, '.mem', '.hex') { |dest, source| system("srec_cat #{source} -Intel -Byte_Swap 2 -Data_Only -Output_Block_Size 32 -o #{dest} -vmem 8") }
98
103
  bit = with_temporary_files(mem, '.bit', '.mem') { |dest, source| system("data2mem -bm #{memory_map} -bt #{bit_file} -bd #{source} -o b #{dest}") }
99
104
 
100
- #... wrap it in a Bitstream object, and return it.
101
- Adept::DataFormats::Bitstream.from_string(bit)
102
105
 
103
106
  end
104
107
 
108
+ #
109
+ # Returns a bitstream which can be use to load the given core onto the target
110
+ # device. If a program is provided, it will be loaded into the resultant bitstream.
111
+ #
112
+ # target: The Device ID string of the board to be programmed.
113
+ # program: The program that should be merged into the core.
114
+ # prom: If true, the PROM version of this core will be used.
115
+ #
116
+ def to_bitstream(target=@targets.keys.first, program=nil, prom=false)
117
+ Adept::DataFormats::Bitstream.from_string(to_raw_bitstream(target, program, prom))
118
+ end
119
+
105
120
  #
106
121
  # Print a debugging represntation of the core.
107
122
  #
@@ -111,12 +126,20 @@ module Adept
111
126
 
112
127
  private
113
128
 
129
+ #
130
+ # Convenience delegate which allows instance access to the with_temporary_files class method.
131
+ # (This allows for prettier code; e.g. with_temporary_files { do_something } ).
132
+ #
133
+ def with_temporary_files(*args, &block)
134
+ self.class.with_temporary_files(*args, &block)
135
+ end
136
+
114
137
  #
115
138
  # Executes a given block with an "anonymous" temporary file.
116
139
  # The temporary file is deleted at the end of the block, and its contents
117
140
  # are returned.
118
141
  #
119
- def with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)
142
+ def self.with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)
120
143
 
121
144
  #File mode for all of the created temporary files.
122
145
  #Create the files, and allow read/write, but do not lock for exclusive access.
@@ -96,7 +96,7 @@ module Adept
96
96
  #
97
97
  # Returns the bitstream as a bit string.
98
98
  #
99
- def to_s
99
+ def to_s(with_headers=false)
100
100
  to_a.pack("C*")
101
101
  end
102
102
 
@@ -71,8 +71,8 @@ module Adept
71
71
  #
72
72
  # Closes the given device.
73
73
  #
74
- def close
75
- ensure_handle_is_valid
74
+ def close(check_handle=true)
75
+ ensure_handle_is_valid if check_handle
76
76
  DeviceManager::close_device(@handle)
77
77
  end
78
78
 
@@ -13,6 +13,7 @@ module Adept
13
13
  extend ConnectionProvider
14
14
 
15
15
  attr_reader :tap_state
16
+ attr_reader :device
16
17
 
17
18
  #
18
19
  # Sets up a new JTAG connection.
@@ -1,3 +1,3 @@
1
1
  module Adept
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-adept
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Kyle J. Temkin
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-04 00:00:00.000000000 Z
12
+ date: 2013-04-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bindata
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: ffi
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: require_all
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: smart_colored
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: trollop
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: ruby-elf
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: ruby-ise
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: rspec
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ~>
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ~>
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: fakefs
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ~>
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ~>
137
156
  - !ruby/object:Gem::Version
@@ -156,6 +175,8 @@ files:
156
175
  - bin/bprog
157
176
  - cores/avr8/avr_250k.bit
158
177
  - cores/avr8/avr_250k.bmm
178
+ - cores/avr8/avr_250k_prom.bit
179
+ - cores/avr8/avr_250k_prom.bmm
159
180
  - cores/avr8/core.yaml
160
181
  - firmware/.gitignore
161
182
  - firmware/epp_stream/Basys2_100_250General.ucf
@@ -207,26 +228,27 @@ files:
207
228
  - spec/spec_helpers.rb
208
229
  homepage: http://www.github.com/ktemkin/ruby-adept
209
230
  licenses: []
210
- metadata: {}
211
231
  post_install_message:
212
232
  rdoc_options: []
213
233
  require_paths:
214
234
  - lib
215
235
  required_ruby_version: !ruby/object:Gem::Requirement
236
+ none: false
216
237
  requirements:
217
238
  - - ! '>='
218
239
  - !ruby/object:Gem::Version
219
240
  version: '0'
220
241
  required_rubygems_version: !ruby/object:Gem::Requirement
242
+ none: false
221
243
  requirements:
222
244
  - - ! '>='
223
245
  - !ruby/object:Gem::Version
224
246
  version: '0'
225
247
  requirements: []
226
248
  rubyforge_project:
227
- rubygems_version: 2.0.3
249
+ rubygems_version: 1.8.23
228
250
  signing_key:
229
- specification_version: 4
251
+ specification_version: 3
230
252
  summary: Framework for working with Digilent Adept devices.
231
253
  test_files:
232
254
  - spec/firmware/epp_loopback.bit
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTI4YTUxMDg5MzE1MWVlOWVmMTJhNzEyZWZkZWVlZDlhNDJlZGI1OA==
5
- data.tar.gz: !binary |-
6
- YmZlMmQ3OTE3NWE2MjI3MTc4NDUxZDAxMTg4NDUzZWIzNDliODEzZQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZGM2NTJkZWVmNzM2NzgyOTM0ZGY0ZGYzYWZjZjBkODU3ZGI3YTRlZWY3Yzc1
10
- Y2Q1ZTUyMDc4YTRiYjE5NDBmZmVhMjAwZjgwNjZmN2IwODIyY2U0YTc2ZGE3
11
- NTE2N2Y1ZDRlZDM4YmQ5YmNlMzRkMzIwY2I3ZGFjYjg2NjM1ZWQ=
12
- data.tar.gz: !binary |-
13
- NWI5M2QyODkwZjQ4MjBjM2QyYWQxMWQ2OTY0ZmQxMWY4MmM5N2UwMDVkYzVh
14
- N2JiMDc1NzU1ZWVmZGMyOGEzZDU4NWU1ZWY3ZDE3NjJlYTI0ZTNiNjdlOTA1
15
- ZmMzMTg4YzM2NGFjYjUwZDMwY2MyNzcwNDQ2OTU2MGEwNDUxMTg=