00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/bitstream/FrameSet.hpp $ 00003 // $Id: FrameSet.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the FrameSet class. 00018 00019 #ifndef TORC_BITSTREAM_FRAMESET_HPP 00020 #define TORC_BITSTREAM_FRAMESET_HPP 00021 00022 #include "torc/bitstream/Frame.hpp" 00023 #include "torc/bitstream/VirtexFrameAddress.hpp" 00024 00025 namespace torc { 00026 namespace bitstream { 00027 00028 class VirtexFrameAddress; 00029 /// \brief Set of contiguous frames. 00030 template <class FRAME_TYPE> class FrameSet 00031 : public std::vector<boost::shared_ptr<FRAME_TYPE> > { 00032 protected: 00033 // typedefs 00034 /// \brief Imported type name. 00035 typedef boost::uint32_t uint32_t; 00036 public: 00037 // typedefs 00038 /// \brief FrameSet frame type. 00039 typedef FRAME_TYPE frame_t; 00040 /// \brief FrameSet word type. 00041 typedef typename FRAME_TYPE::word_t word_t; 00042 /// \brief Shared pointer encapsulation of a Frame. 00043 typedef boost::shared_ptr<FRAME_TYPE> FrameSharedPtr; 00044 /// \brief Shared pointer for frame addressing. 00045 typedef boost::shared_ptr<VirtexFrameAddress> VirtexFarSharedPtr; 00046 /// \brief Word shared array for frame words 00047 typedef boost::shared_array<uint32_t> WordSharedArray; 00048 // constructors 00049 /// \brief Null constructor. 00050 FrameSet(void) {} 00051 /// \brief Basic constructor for full bitstream. 00052 /// \var inFrameLength The default length of each frame in the set. 00053 /// \var inFrameCount The number of frames in the set. 00054 FrameSet(uint32_t inFrameLength, uint32_t inFrameCount) { 00055 for(uint32_t i = 0; i < inFrameCount; i++) 00056 push_back(FrameSharedPtr(new FRAME_TYPE(inFrameLength))); 00057 } 00058 /// \brief Basic constructor for partial bitstream. 00059 /// \var inFrameLength The default length of each frame in the set. 00060 /// \var inFrameCount The number of frames in the set. 00061 /// \var inWords The frame words 00062 /// \var inFar Address of the frames in the set 00063 FrameSet(uint32_t inFrameLength, uint32_t inFrameCount, WordSharedArray inWords, VirtexFrameAddress& inFar) { 00064 VirtexFarSharedPtr farPtr = inFar; 00065 for(uint32_t i = 0; i < inFrameCount; i++) 00066 push_back(FrameSharedPtr(new FRAME_TYPE(inFrameLength, &inWords[i*inFrameLength]))); 00067 } 00068 }; 00069 00070 typedef FrameSet<VirtexFrame> VirtexFrameSet; ///< \brief Virtex frame set type. 00071 typedef FrameSet<SpartanFrame> SpartanFrameSet; ///< \brief Spartan frame set type. 00072 typedef FrameSet<Spartan6Frame> Spartan6FrameSet; ///< \brief Spartan6 frame set type. 00073 00074 /// \brief Set of contiguous frames for each of the eight possible block types. 00075 template <typename FRAME_TYPE> class FrameBlocks { 00076 protected: 00077 public: 00078 // enumerations 00079 /// \brief The block type count is fixed at eight across all Xilinx architectures. 00080 enum { eBlockTypeCount = 8 }; 00081 // typedefs 00082 /// \brief FrameSet frame type. 00083 typedef FRAME_TYPE frame_t; 00084 /// \brief FrameSet word type. 00085 typedef typename FRAME_TYPE::word_t word_t; 00086 // members 00087 /// \brief FrameSets for each of the eight block types. 00088 FrameSet<FRAME_TYPE> mBlock[eBlockTypeCount]; 00089 }; 00090 00091 typedef FrameBlocks<VirtexFrame> VirtexFrameBlocks; ///< \brief Virtex frame blocks type. 00092 typedef FrameBlocks<SpartanFrame> SpartanFrameBlocks; ///< \brief Spartan frame blocks type. 00093 typedef FrameBlocks<Spartan6Frame> Spartan6FrameBlocks; ///< \brief Spartan6 frame blocks type. 00094 00095 } // namespace bitstream 00096 } // namespace torc 00097 00098 #endif // TORC_BITSTREAM_FRAMESET_HPP