Class: Adept::JTAG::Devices::FPGA
- Inherits:
-
Adept::JTAG::Device
- Object
- Adept::JTAG::Device
- Adept::JTAG::Devices::FPGA
- Defined in:
- lib/adept/jtag/devices/fpga.rb
Overview
Base module for JTAG devices.
Constant Summary collapse
- InstructionWidth =
Basic device definitions.
6
- Instructions =
Supported boundary-scan instructions.
{ :extest => 0b001111, :sample => 0b000001, :preload => 0b000001, # Same as :sample :user1 => 0b000010, # Not available until after configuration :user2 => 0b000011, # Not available until after configuration :cfg_out => 0b000100, # Not available during configuration with another mode. :cfg_in => 0b000101, # Not available during configuration with another mode. :intest => 0b000111, :usercode => 0b001000, :idcode => 0b001001, :highz => 0b001010, :jprogram => 0b001011, # Not available during configuration with another mode. :jstart => 0b001100, # Not available during configuration with another mode. :jshutdown => 0b001101, # Not available during configuration with another mode. :bypass => 0b111111, :isc_enable => 0b010000, :isc_program => 0b010001, :isc_noop => 0b010101, :isc_disable => 0b010110 }
- PartIdcodes =
Database which maps IDCodes to bit-file part numbers. Used to validate
{ '3s100ecp132' => 'X1c10093', '3s250ecp132' => 'X1c1a093' }
- ConfigurationStartup =
14_000
- FPGAStartup =
100
Instance Attribute Summary
Attributes inherited from Adept::JTAG::Device
Instance Method Summary collapse
-
#configure(bitstream) ⇒ Object
Configures (programs) the given FPGA.
- #part_name ⇒ Object
-
#supports_bitstream?(bitstream) ⇒ Boolean
Returns true iff the provided bitstream is intended for this FPGA.
-
#usercode ⇒ Object
Returns the “user code”, an ID number which identifies the configuration of the FPGA.
-
#verify_idcode ⇒ Object
Verifies the device’s IDcode using the explicit IDCode instruction.
Methods inherited from Adept::JTAG::Device
from_idcode, inherited, #initialize, #instruction=, #instruction_width, #receive_data, #run_test, supports?, #transmit_data
Constructor Details
This class inherits a constructor from Adept::JTAG::Device
Instance Method Details
#configure(bitstream) ⇒ Object
Configures (programs) the given FPGA.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/adept/jtag/devices/fpga.rb', line 90 def configure(bitstream) validate_bitstream(bitstream) #Send the bitstream to the FPGA. initialize_configuration transmit_data(bitstream.to_s) finalize_configuration #And verify that the programming succeeded. unless bitstream.usercode == usercode || bitstrea.usercode.nil? raise ProgrammingError, "Programming failed; expected a usercode of #{bitstream.usercode}, recieved #{usercode}." end end |
#part_name ⇒ Object
106 107 108 109 |
# File 'lib/adept/jtag/devices/fpga.rb', line 106 def part_name connected_part, _ = PartIdcodes.find { |part, mask| self.class.idcode_matches_mask(mask, @idcode) } connected_part end |
#supports_bitstream?(bitstream) ⇒ Boolean
Returns true iff the provided bitstream is intended for this FPGA.
114 115 116 |
# File 'lib/adept/jtag/devices/fpga.rb', line 114 def supports_bitstream?(bitstream) self.class.idcode_matches_mask(PartIdcodes[bitstream.part], @idcode) end |
#usercode ⇒ Object
Returns the “user code”, an ID number which identifies the configuration of the FPGA.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/adept/jtag/devices/fpga.rb', line 74 def usercode #Put the device into IDCode retrival mode. self.instruction = :usercode #And attempt to retrieve the 32-bit IDcode. usercode_packed = receive_data(32).reverse #Return the usercode as a hex string. usercode_packed.unpack("H*").first.upcase end |
#verify_idcode ⇒ Object
Verifies the device’s IDcode using the explicit IDCode instruction.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/adept/jtag/devices/fpga.rb', line 58 def verify_idcode #Put the device into IDCode retrival mode. self.instruction = :idcode #And attempt to retrieve the 32-bit IDcode. id_code = receive_data(32).reverse #If the two IDcodes don't match, raise an error. raise JTAG::Error, "IDCode verification failed! Expected: #{@idcode.unpack("H*")}, receieved #{id_code.unpack("H*")}. " unless id_code == @idcode end |