random.hh (10349:939094c17866) random.hh (10905:a6ca6831e775)
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 39 unchanged lines hidden (view full) ---

48
49#ifndef __BASE_RANDOM_HH__
50#define __BASE_RANDOM_HH__
51
52#include <random>
53#include <string>
54#include <type_traits>
55
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 39 unchanged lines hidden (view full) ---

48
49#ifndef __BASE_RANDOM_HH__
50#define __BASE_RANDOM_HH__
51
52#include <random>
53#include <string>
54#include <type_traits>
55
56#include "base/compiler.hh"
56#include "base/types.hh"
57#include "base/types.hh"
58#include "sim/serialize.hh"
57
58class Checkpoint;
59
59
60class Checkpoint;
61
60class Random
62class Random : public Serializable
61{
62
63 private:
64
65 std::mt19937_64 gen;
66
67 public:
68

--- 28 unchanged lines hidden (view full) ---

97 template <typename T>
98 typename std::enable_if<std::is_integral<T>::value, T>::type
99 random(T min, T max)
100 {
101 std::uniform_int_distribution<T> dist(min, max);
102 return dist(gen);
103 }
104
63{
64
65 private:
66
67 std::mt19937_64 gen;
68
69 public:
70

--- 28 unchanged lines hidden (view full) ---

99 template <typename T>
100 typename std::enable_if<std::is_integral<T>::value, T>::type
101 random(T min, T max)
102 {
103 std::uniform_int_distribution<T> dist(min, max);
104 return dist(gen);
105 }
106
105 void serialize(std::ostream &os);
106 void unserialize(Checkpoint *cp, const std::string &section);
107 void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
108 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
107};
108
109extern Random random_mt;
110
111#endif // __BASE_RANDOM_HH__
109};
110
111extern Random random_mt;
112
113#endif // __BASE_RANDOM_HH__