Commit Graph

43 Commits

Author SHA1 Message Date
Rick Altherr 0fc3ba0400 lib: xc7series: implement builder pattern for generating COR0 values
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Rick Altherr a4fb9ff7d8 lib: xc7series: define known CMD register values
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Rick Altherr 80004a3737 lib: xc7series: config packet subclass for NOPs
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Rick Altherr ab1e60c037 lib: xc7series: add undocumented register used in init sequence
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Rick Altherr 2a1154ec16 lib: xc7series: config packet subclass that owns the payload
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Rick Altherr 43b70caf03 xc7series: Dynamically allocate config packets when writing bitstreams
ConfigurationPacket assumes that the payload data is owned by someone
else. For frame data, that is generally true.  For initialization and
finalization sequences, those payloads need to be created and managed.
Instead, dynamically allocate packets which allows for using subclasses
of ConfigurationPacket that store the payload with the packet.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-02-01 14:34:31 -08:00
Herbert Poetzl 9c4971162e Make loop condition more readable
Signed-off-by: Herbert Poetzl <herbert@13thfloor.at>
2018-01-31 18:48:01 -08:00
Herbert Poetzl b69ed5cc7e Code cleanup and additional comments
Signed-off-by: Herbert Poetzl <herbert@13thfloor.at>
2018-01-31 18:48:01 -08:00
Herbert Poetzl 86f49cc9da Added ICAP CRC and ECC calculations and tests
Signed-off-by: Herbert Poetzl <herbert@13thfloor.at>
2018-01-31 18:48:01 -08:00
Rick Altherr b0604362e0 lib: xc7series: const all the Span<>s
Span<T> can be converted to a Span<const T> but the reverse is not true.
Since most of the uses of spans do not allow modification of the data,
taking a Span<const T> is more versatile and importantly allows them to
be used in const methods.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-22 14:15:13 -08:00
John McMaster dab52e90ba
Merge branch 'master' into bit_write 2018-01-17 15:07:04 -08:00
John McMaster fe49ac6cee bitstream writer utility class
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
2018-01-17 15:06:12 -08:00
Rick Altherr 012494552d lib: xc7series: generate packets from a Configuration
ConfigurationPacketizer translates a Configuration's frame data to a
sequence of ConfigurationPackets that will write that configuration to
the configuration's Part.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-17 11:20:06 -08:00
Rick Altherr 5749352937 lib: xc7series: convience constructor for Configuration
Configuration's original constructor expects Span<uint32_t>s as part of
the map to avoid copying the actual frame data.  In tests or any other
place that needs to directly construct a Configuration, the caller will
already have a map with vector<uint32_t> to hold the actual frame data.
This new constructor just wraps those vectors in Spans.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-16 16:11:08 -08:00
Rick Altherr 2da520bea3 Remove unused ConfigurationFrameRange
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-10 14:28:30 -08:00
Rick Altherr 2b34fbb35d xc7series: refactor Part()
ConfigurationFrameAddress row-half and row fields translate directly to
the clock region structure used in 7-series parts.  Break these concepts
out into separate classes and encode them as such in Part YAML.

Columns within a row are more complicated. Column indices are relative
to a BlockType. Think of each BlockType as a data bus that terminates at
some particular tile type (e.g. CLB_IO_CLK maps to INT_{L,R} tiles).
Column indices act as addresses of endpoints on the associated BlockType
bus.  As the bus is 1 frame (101 words, 404 bytes) wide, each endpoint
feeds frames into multiple tiles simultaneously.

Minor addresses are frame addresses within a BlockType bus endpoint.
These can refer to frames either stored within the endpoint tiles
or in tiles chained behind them.

Note that a given tile can be connected on multiple BlockType buses.
For example, block RAMs appear to be attached both by being chained
behind an INT_{L,R} on the CLB_IO_CLK bus as well as being a direct
endpoint on the BLOCK_RAM bus.  Due to this, tiles conceptually belong
to the row rather than a single column.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-10 14:28:23 -08:00
Rick Altherr 53d7f1f80b lib: xc7series: shorten accessor names
_address suffix on accessors is unnecessary and somewhat inaccurate.
The returned values are indices rather than frame addresses.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-10 14:28:17 -08:00
Rick Altherr 50d2521b33 Apply clang-format to all C++ files
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-08 17:14:27 -08:00
Rick Altherr 5a664c04ec lib: xc7series: shorten ConfigurationFrameAddress to FrameAddress
Frame addresses are only used in the context of configuration frames.
Remove the prefix to reduce typing that does not improve clarity.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-04 15:33:15 -08:00
Rick Altherr 6222be77d3 lib: xc7series: Account for padding between rows in bitstreams
There seem to be 2 frames of padding between rows in a bitstream.  For
single-frame writes, these are parsed as type 0 packets and ignored.
Normal bitstreams use a single FDRI write that apparently includes this
padding and needs to be ignored in the auto-increment handling.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-04 15:17:40 -08:00
Rick Altherr 0d2c33bf0f lib: xc7series: ostream operator for ConfigurationFrameAddress
Writes a decoded version of the address to the stream.  Handy for logging.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-04 15:00:08 -08:00
Rick Altherr a4858be23a lib: accessor to get contents of a memory-mapped file as bytes
MemoryMappedFile's data() method returns a void* as it has no idea what
type the contents are.  Viewing it as bytes is a very common operation
so add a convience method that wraps the pointer in a Span<uint8_t>.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
2018-01-04 11:17:59 -08:00
Rick Altherr bd3fa58584 lib: xc7series: class to hold a configuration
Currently is able to parse IDCODE and frames from a sequence of
ConfigurationPackets.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr d251aa0ed7 lib: xc7series: wrapper for part-specific information
Currently just the pieces required to successfully identify and decode
a bitstream into configuration frames.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 4f6046d177 lib: xc7series: wrapper for ranges of config frame addresses
Includes conversion to/from YAML.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr e956bc8160 lib: xc7series: YAML user-defined type decoding requires a default constructor
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 195323e0c8 lib: xc7series: enable conversion to/from YAML for frame addresses
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr e85e51514d lib: bit_ops: Allow bit_field_set() to implicitly cast value to desired type
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 9cbd9bac28 lib: replace binary literals with hex literals
binary literals are a C++14 feature.  Use hex literals instead to
keep C++11 compatibility.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 4a80475db9 lib: xc7series: record header type in configuration packets
Type 2 packets are used for when the amount of data required exceeds the
word count field in a Type 1 header.  ConfigurationPacket mostly hides
this detail from the user but occasionally it is handy for debugging.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 78546b275d lib: xc7series: add accessor to get words in a bitstream
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr fd3a5d8bab lib: xc7series: ostream overload for BlockType
Makes debugging a bit easier.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 47e02d4cfd lib: xc7series: move register details to reusable enum
Both ConfigurationPacket and Configuration need to reference registers.
Use a common scoped enum to reduce change of errors.  Leverage stream
operator to simplify outputing register names.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 0a005ab5a1 lib: move Xilinx 7series classes into a separate namespace
Class names were getting unwieldy.  Use a namespace to group all the
7series classes and allow for shorter class names.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 82a989cfc9 lib: Parser for Xilinx bitstream file format
Reads the raw bitstream into configuration packets that represent
internal register writes.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr e0094d8538 lib: correct const-ness of MemoryMappedFile::data()
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 4bc1567103 lib: Xilinx 7-Series configuration packet
Encapsulates configuration packets used in Xilinx 7-Series bitstream
format.  The same class handles both Type 1 and Type 2 packets.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr fdf0bc46a1 lib: adapter to read big-endian words from a span<> containing bytes
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 9f1e936ab0 bitops: setter and add const
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr f65ee46f7c lib: bit manipulation functions
Functions for hiding all the masking and shifting required for accessing
bit ranges within an integer type.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 51b586365b lib: Wrapper for retrieving info from a database directory
Currently provides list of segbits files saved in the database.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 3e203b956b lib: Reader for segbits files
Acts as an iterator that yields a single record from the file.  Uses a
memory-mapped file and absl::string_view to avoid copies within the
reader.

Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00
Rick Altherr 30a1e466d3 lib: wrapper to manage memory-mapped files
Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
2017-12-20 22:46:39 +01:00