delayvector.hpp 1.38 KB
Newer Older
Ralf Stemmer's avatar
Ralf Stemmer committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef DELAYVECTOR_HPP
#define DELAYVECTOR_HPP

#include <vector>
#include <string>
#include <systemc.h>
#include <cstdlib>
#include <gsl/gsl_rng.h>

enum DISTRIBUTION
{
    INJECTED,
    GAUSSIAN,
14 15
    UNIFORM,
    WCET
Ralf Stemmer's avatar
Ralf Stemmer committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
};

// Important:
// Internal, this class works with doubles for the delays.
// A delay's unit is clock cycle.
// The external interfaces should be of type sc_time

class DelayVector
{
    public:
        DelayVector(const char *path, DISTRIBUTION distribution = DISTRIBUTION::INJECTED);
        DelayVector(std::string path, DISTRIBUTION distribution = DISTRIBUTION::INJECTED);

        sc_core::sc_time GetDelay();

    private:
        double GetInjectedDelay();
        double GetGaussianDelay();
        double GetUniformDelay();
35
        double GetWCETDelay();
Ralf Stemmer's avatar
Ralf Stemmer committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        void ReadDelayVector(const char *path);

        // This vector holds all measured delay
        std::vector<double> delayvector;

        // These variables are properties of the measured delay are
        double BCET;  // Lowest delay
        double WCET;  // Highest delay
        double sigma;
        double mu;

        // Some variables for accessing the delays
        unsigned int delayindex; // Next delay in delay vector
        gsl_rng *rng;   // Random number generator for Normal/Uniform distribution
        DISTRIBUTION distribution;
};

#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4