torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VirtexAssembler.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL: https://svn.east.isi.edu/torc/trunk/src/torc/bitstream/assembler/lut/parser.yy $
3 // $Id: parser.yy 1303 2013-02-25 23:18:16Z nsteiner $
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 VirtexAssembler.cpp
17 /// \brief Class to implement common functionalities of Virtex architectures
18 
20 #include "torc/Bitstream.hpp"
23 #include "torc/Physical.hpp"
24 #include <iostream>
25 
26 using namespace torc::bitstream;
27 using namespace torc::physical;
28 
29 namespace torc {
30 namespace bitstream {
31 
32 /// \details Public function to be called by user to initiate bitstream generation process.
33 /// The parameter inBaseBitstreamPath will act as base bitstream for micro-bitstream assembly process.
34 /// This function might be implemented in derived class for additional architecture specific processing.
35 int VirtexAssembler::generateBitstream(DesignSharedPtr inDesignPtr, const path inTargetBitstreamPath,
36  EMergeMode inMergeMode, path baseBitstreamPath) {
37 
38  int error = Assembler::generateBitstream(inDesignPtr, inTargetBitstreamPath,inMergeMode, baseBitstreamPath);
39 
40  if(error)
41  return error;
42 
43  initializeFullFrameBlocks();
44 
46 
47  updateFullFrameBlocks();
48 
49  saveBitstream();
50 
51  return 0;
52 }
53 
54 /// \details Store frame data and bit offset for site
56 
57  SiteIndex siteIndex = mSites.findSiteIndex(siteName);
58  const Site& site = mSites.getSite(siteIndex);
59 
60  // look up the site tile index
61  TileIndex tileIndex = site.getTileIndex();
62  return initializeFrameDataForTile(tileIndex);
63 }
64 
65 /// \details Go over all the bitaddresses, split it into frame address, word address, and bit address.
66 /// Merge bits with outBitstream after handling offset.
67 void VirtexAssembler::mergeWithBaseBitstream(const std::vector<uint32_t> &bitAddresses,
68  uint32_t blockIndex) {
69  int32_t numSetBits = bitAddresses.size();
70  //std::cout << "\tNumber of bits set: " << numSetBits
71  // << " Word offset: " << Hex32(mCurrWordOffset) << std::endl;
72 
73  VirtexFrameSet& frameSet = mCurrFrameBlocks.mBlock[blockIndex];
74  if(!frameSet.empty()) {
75  for(int i = 0; i < numSetBits; i++) {
76  uint32_t bitAddr = bitAddresses[i];
77  int32_t bitIndex = bitAddr & 0x000000FF; // get the lowest byte
78  int32_t wordIndex = (bitAddr & 0x0000FF00) >> 8;
79  // Library setting is for first row of clock region. Word index has to be offset to reach the correct row.
80  wordIndex += mCurrWordOffset;
81  int32_t frameIndex = (bitAddr & 0xFFFF0000) >> 16;
82  //std::cout << "\t Frame: " << Hex32(frameIndex) << " Word: "
83  // << Hex32(wordIndex) << " bit: " << Hex32(bitIndex)
84  // << std::endl;
85  VirtexFrameSharedPtr virtexFrame = frameSet[frameIndex];
86 
87  VirtexFrame::word_t currentWord = virtexFrame->getWords()[wordIndex];
88  if(mMergeMode == eSet) {
89  currentWord = (1 << (bitIndex)) | currentWord;
90  } else if(mMergeMode == eClear) {
91  currentWord = ((1 << (bitIndex)) ^ 0xFFFFFFFF) & currentWord;
92  }
93  virtexFrame->setWord(wordIndex, currentWord);
94 
95  }
96  } else {
97  /// \todo Determine what this error condition actually means.
98  std::cout << "WARNING: Unknown frame type." << std::endl;
99  }
100 }
101 
102 } // namespace bitstream
103 } // namespace torc
Encapsulation of a tile index in an unsigned 32-bit integer.
torc::physical::DesignSharedPtr DesignSharedPtr
Imported type name.
Definition: Assembler.hpp:61
Header for the DirectoryTree class.
Main torc::bitstream namespace header.
void convertXdlToBitstream(DesignSharedPtr inDesignPtr, Bitstream &outBitstream, const Sites &sites, const Tiles &tiles, TiletypeElementMap &library)
Definition: Xdl2Bit.cpp:230
virtual void mergeWithBaseBitstream(const std::vector< uint32_t > &bitAddresses, uint32_t blockIndex)
Merge compressed micro-bitstream with base bitstream.
std::string string
Encapsulation of a device logic site.
Definition: Site.hpp:30
Main torc::physical namespace header.
boost::filesystem::path path
Imported type name.
Definition: Assembler.hpp:67
TileIndex getTileIndex(void) const
Returns the index of the containing tile.
Definition: Site.hpp:83
virtual int generateBitstream(DesignSharedPtr inDesignPtr, const path inTargetBitstreamPath, EMergeMode inMergeMode=eSet, path baseBitstreamPath=path())
Function to generate bitstream, takes target bitstream path and optional base bitstream path...
Definition: Assembler.cpp:64
boost::shared_ptr< VirtexFrame > VirtexFrameSharedPtr
Virtex frame type.
Definition: Frame.hpp:108
Definition of base Virtex class to implement functions common across all/some Virtex architectures...
Encapsulation of a site index in an unsigned 32-bit integer.
virtual void initializeFrameDataForSite(const std::string &siteName)
Store frame blocks and bit offset for given site.
virtual int generateBitstream(DesignSharedPtr inDesignPtr, const path inTargetBitstreamPath, EMergeMode inMergeMode=eSet, path baseBitstreamPath=path())
Function to generate bitstream to be called by user.
Header for the DDB class.
WORD_TYPE word_t
Frame word type.
Definition: Frame.hpp:48