Class: Adept::DataFormats::Bitstream

Inherits:
BinData::Record
  • Object
show all
Extended by:
DataFactories
Defined in:
lib/adept/data_formats/bitstream.rb

Overview

Class for the Xilinx bitstream file format.

Format used was described at <www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm>

Constant Summary collapse

UsercodeFormat =
/UserID=0x([0-9A-Fa-f]+)/

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DataFactories

from_file

Class Method Details

.from_string(string) ⇒ Object

Parses the given string as a Xilinx BitStream file.



57
58
59
# File 'lib/adept/data_formats/bitstream.rb', line 57

def self.from_string(string)
  read(string)
end

Instance Method Details

#bit_lengthObject

Returns the length of the bitsream, in bits.



85
86
87
# File 'lib/adept/data_formats/bitstream.rb', line 85

def bit_length
  bitstream_length * 8
end

#filenameObject

Returns the routed logic (“ncd”) filename from which this bitstream was created.



64
65
66
# File 'lib/adept/data_formats/bitstream.rb', line 64

def filename
  info.split(';').first
end

#time_createdObject

Returns the time at which the bitfile was created.



78
79
80
# File 'lib/adept/data_formats/bitstream.rb', line 78

def time_created
  DateTime.parse("#{raw_date} #{raw_time}")
end

#to_aObject

Returns the bitstream as an arran array.



92
93
94
# File 'lib/adept/data_formats/bitstream.rb', line 92

def to_a
  raw_bitstream.to_a.map { |b| self.class.reverse_byte(b) }
end

#to_s(with_headers = false) ⇒ Object

Returns the bitstream as a bit string.



99
100
101
# File 'lib/adept/data_formats/bitstream.rb', line 99

def to_s(with_headers=false)
  to_a.pack("C*")
end

#usercodeObject

Returns the usercode for the given design.



71
72
73
# File 'lib/adept/data_formats/bitstream.rb', line 71

def usercode
  UsercodeFormat.match(info)[1]
end