Files
DRAMSys/DRAMSys/library/src/common/AddressDecoder.h
Éder F. Zulian 5b67f2b268 Coding-style applied the project.
$ cd util
$ ./make_pretty.sh
2018-05-29 11:38:54 +02:00

92 lines
2.6 KiB
C++

/*
* Copyright (c) 2018, University of Kaiserslautern
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors:
* Johannes Feldmann
*/
#ifndef ADDRESSDECODER_H
#define ADDRESSDECODER_H
#include <tlm.h>
#include <iostream>
#include <sstream>
#include <string>
#include <map>
struct DecodedAddress {
DecodedAddress() : channel(0),
rank(0),
bankgroup(0),
row(0),
bank(0),
column(0),
bytes(0)
{
}
unsigned int channel;
unsigned int rank;
unsigned int bankgroup;
unsigned int row;
unsigned int bank;
unsigned int column;
unsigned int bytes;
};
class AddressDecoder
{
public:
enum class Type {
XML,
JSON
};
protected:
AddressDecoder();
static AddressDecoder *m_pInstance;
public:
static AddressDecoder &getInstance();
static void createInstance(Type t);
virtual void setConfiguration(std::string url) = 0;
virtual DecodedAddress decodeAddress(sc_dt::uint64 addr) = 0;
virtual sc_dt::uint64 encodeAddress(DecodedAddress n) = 0;
virtual void print() = 0;
std::map<std::string, unsigned int> amount;
};
#endif // ADDRESSDECODER_H