torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VirtexBitstream.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the VirtexBitstream class.
18 
19 #ifndef TORC_BITSTREAM_VIRTEXBITSTREAM_HPP
20 #define TORC_BITSTREAM_VIRTEXBITSTREAM_HPP
21 
22 #include <boost/cstdint.hpp>
27 #include <fstream>
28 
29 namespace torc {
30 namespace bitstream {
31 
32 namespace bitstream { class VirtexBitstreamUnitTest; }
33 
34  /// \brief Virtex-class bitstream.
35  class VirtexBitstream : virtual public Bitstream, public VirtexPacketVector,
38  protected:
39  // typedefs
40  /// \brief Imported type name.
41  typedef boost::uint32_t uint32_t;
42  // functions
43  /// \brief Reports the named function as not yet implemented in the current architecture.
44  void unimplemented(std::string inName);
45  /// \brief Update CRC-16 packets.
47  /// \brief Update CRC-32 packets.
49  /// \brief Read frame packets in for Virtex4/5/6/7 devices.
50  template <class ARCH> void readFramePackets4567(uint32_t inBlockFrameIndexBounds[],
51  std::map<typename ARCH::FrameAddress, uint32_t>& inFrameAddressToIndex,
52  std::map<uint32_t, typename ARCH::FrameAddress>& inFrameIndexToAddress);
53  /// \brief Discard the existing frame packets for Virtex4/5/6/7 devices.
54  template <class ARCH> VirtexPacketVector::iterator deleteFramePackets4567(void);
55  /// \brief Return a packet vector with full frame data for Virtex4/5/6/7 devices.
57  uint32_t inBlockFrameIndexBounds[]);
58  /// \brief Return a packet vector with partial frame data for Virtex4/5/6/7 devices.
60  EFrameInclude inFrameInclusion,
61  std::map<typename ARCH::FrameAddress, uint32_t>& inFrameAddressToIndex,
62  std::map<uint32_t, typename ARCH::FrameAddress>& inFrameIndexToAddress);
63  // members
64  /// \brief Input Frame blocks.
66  public:
67  // constructors
68  /// \brief Basic constructor.
71  // functions
72  /// \brief Read bitstream packets from a stream.
73  /// \note This function should be called after the bitstream header has been read.
74  virtual void readPackets(std::istream& inStream);
75  /// \brief Write bitstream packets to a stream.
76  virtual void writePackets(std::ostream& inStream);
77  /// \brief Read frame data into the frame blocks structure.
78  virtual void readFramePackets(void);
79  /// \brief Update the bitstream frame packets
80  /// \detail By default this updates the bitstream with full frame data.
81  /// \param inBitstreamType The type of bitstream to generate: full or partial.
82  /// \param inFrameInclusion The type of frames to include in partial bitstreams: only dirty
83  /// frames or all frames.
84  virtual void updateFramePackets(EBitstreamType inBitstreamType = eBitstreamTypeFull,
85  EFrameInclude inFrameInclusion = eFrameIncludeAllUsedFrames);
86  /// \brief Discard existing packets and generate bitstream packets from frame data.
87  /// \detail By default this generates packets for a full bitstream.
88  /// \param inBitstreamType The type of bitstream to generate: full, active partial, or
89  /// shutdown partial.
90  /// \param inFrameInclusion The type of frames to include in partial bitstreams: only dirty
91  /// frames or all frames.
92  virtual void generateBitstream(EBitstreamType inBitstreamType = eBitstreamTypeFull,
93  EFrameInclude inFrameInclusion = eFrameIncludeAllUsedFrames);
94  /// \brief Discard the existing frame packets and return an iterator to the start position.
95  virtual VirtexPacketVector::iterator deleteFramePackets(void);
96  /// \brief Return a packet vector with full frame data.
98  /// \brief Return a packet vector with the full bitstream prefix.
100  /// \brief Return a packet vector with the full bitstream suffix.
102  /// \brief Return a packet vector with partial frame data.
103  /// \param inFrameInclusion The type of frames to include: only dirty frames or all frames.
105  /// \brief Return a packet vector with the partial bitstream prefix.
106  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
108  /// \brief Return a packet vector with the partial bitstream suffix.
109  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
111  /// \brief Preflight the packets.
112  virtual void preflightPackets(void);
113  /// \brief Update the header packet length.
114  virtual void updatePacketLength(void);
115  /// \brief Regular std::vector inserter.
116  iterator insert(iterator position, const value_type& val) {
117  return VirtexPacketVector::insert(position, val);
118  }
119  /// \brief Regular std::vector inserter.
120  void insert(iterator position, size_type n, const value_type& val) {
121  VirtexPacketVector::insert(position, n, val);
122  }
123  /// \brief Regular std::vector inserter.
124  template <class InputIterator> void insert(iterator position, InputIterator first,
125  InputIterator last) {
126  VirtexPacketVector::insert(position, first, last);
127  }
128  /// \brief Insert the contents of a packet vector at the specified position.
129  void insert(VirtexPacketVector::iterator inPosition,
130  const VirtexPacketVector& inVector) {
131  VirtexPacketVector::insert(inPosition, inVector.begin(), inVector.end());
132  }
133  /// \brief Append the contents of a packet vector to the end of the bitstream.
134  void append(const VirtexPacketVector& inVector) {
135  VirtexPacketVector::insert(end(), inVector.begin(), inVector.end());
136  }
137  // accessors
138  /// \brief Return the configuration frame blocks.
140  };
141 
142 } // namespace bitstream
143 } // namespace torc
144 
145 #endif // TORC_BITSTREAM_VIRTEXBITSTREAM_HPP
Virtex-class bitstream.
virtual VirtexPacketVector generatePartialBitstreamPackets(EFrameInclude inFrameInclusion)
Return a packet vector with partial frame data.
virtual VirtexPacketVector generatePartialBitstreamPrefix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream prefix.
VirtexFrameBlocks mFrameBlocks
Input Frame blocks.
EFrameInclude
The frames to include in a partial bitstream. Use eFrameIncludeOnlyDirtyFrames to include only dirty...
void readFramePackets4567(uint32_t inBlockFrameIndexBounds[], std::map< typename ARCH::FrameAddress, uint32_t > &inFrameAddressToIndex, std::map< uint32_t, typename ARCH::FrameAddress > &inFrameIndexToAddress)
Read frame packets in for Virtex4/5/6/7 devices.
boost::uint32_t uint32_t
Imported type name.
void insert(VirtexPacketVector::iterator inPosition, const VirtexPacketVector &inVector)
Insert the contents of a packet vector at the specified position.
Header for the DeviceDesignator class.
void insert(iterator position, InputIterator first, InputIterator last)
Regular std::vector inserter.
VirtexBitstream(void)
Basic constructor.
iterator insert(iterator position, const value_type &val)
Regular std::vector inserter.
virtual void updatePacketLength(void)
Update the header packet length.
std::string string
void unimplemented(std::string inName)
Reports the named function as not yet implemented in the current architecture.
virtual void updateCrc32(torc::common::DeviceDesignator::EFamily inFamily)
Update CRC-32 packets.
boost::uint32_t uint32_t
Imported type name.
VirtexPacketVector generateFullBitstreamPackets4567(uint32_t inBlockFrameIndexBounds[])
Return a packet vector with full frame data for Virtex4/5/6/7 devices.
virtual void generateBitstream(EBitstreamType inBitstreamType=eBitstreamTypeFull, EFrameInclude inFrameInclusion=eFrameIncludeAllUsedFrames)
Discard existing packets and generate bitstream packets from frame data. By default this generates p...
Xilinx bitstream base class.
virtual VirtexPacketVector::iterator deleteFramePackets(void)
Discard the existing frame packets and return an iterator to the start position.
void insert(iterator position, size_type n, const value_type &val)
Regular std::vector inserter.
Header for the FrameSet class.
virtual void readPackets(std::istream &inStream)
Read bitstream packets from a stream.
virtual void readFramePackets(void)
Read frame data into the frame blocks structure.
Header for the Bitstream class.
EBitstreamType
The bitstream type to generate. Use eBitstreamFull to fully reconfigure a device, eBitstreamTypePartialActive to partially reconfigure it while it continues to run, or eBitstreamTypePartialShutdown to partially recongifure it after shutting it down.
Bitstream packet constants for Virtex class architectures.
VirtexPacketVector generatePartialBitstreamPackets4567(EFrameInclude inFrameInclusion, std::map< typename ARCH::FrameAddress, uint32_t > &inFrameAddressToIndex, std::map< uint32_t, typename ARCH::FrameAddress > &inFrameIndexToAddress)
Return a packet vector with partial frame data for Virtex4/5/6/7 devices.
virtual void preflightPackets(void)
Preflight the packets.
virtual VirtexPacketVector generatePartialBitstreamSuffix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream suffix.
std::vector< VirtexPacket > VirtexPacketVector
Vector of Virtex packets.
VirtexPacketVector::iterator deleteFramePackets4567(void)
Discard the existing frame packets for Virtex4/5/6/7 devices.
friend class torc::bitstream::bitstream::VirtexBitstreamUnitTest
Header for the VirtexPacket class.
virtual void writePackets(std::ostream &inStream)
Write bitstream packets to a stream.
void append(const VirtexPacketVector &inVector)
Append the contents of a packet vector to the end of the bitstream.
virtual VirtexPacketVector generateFullBitstreamPrefix(void)
Return a packet vector with the full bitstream prefix.
VirtexFrameBlocks & getFrameBlocks(void)
Return the configuration frame blocks.
virtual VirtexPacketVector generateFullBitstreamSuffix(void)
Return a packet vector with the full bitstream suffix.
virtual void updateFramePackets(EBitstreamType inBitstreamType=eBitstreamTypeFull, EFrameInclude inFrameInclusion=eFrameIncludeAllUsedFrames)
Update the bitstream frame packets By default this updates the bitstream with full frame data...
virtual VirtexPacketVector generateFullBitstreamPackets(void)
Return a packet vector with full frame data.
virtual void updateCrc16(torc::common::DeviceDesignator::EFamily inFamily)
Update CRC-16 packets.