1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 59 unchanged lines hidden (view full) --- 68 * Cycles is a wrapper class for representing cycle counts, i.e. a 69 * relative difference between two points in time, expressed in a 70 * number of clock cycles. 71 * 72 * The Cycles wrapper class is a type-safe alternative to a 73 * typedef, aiming to avoid unintentional mixing of cycles and ticks 74 * in the code base. 75 * |
76 * Note that there is no overloading of the bool operator as the |
77 * compiler is allowed to turn booleans into integers and this causes 78 * a whole range of issues in a handful locations. The solution to 79 * this problem would be to use the safe bool idiom, but for now we 80 * make do without the test and use the more elaborate comparison > 81 * Cycles(0). 82 */ 83class Cycles 84{ 85 86 private: 87 88 /** Member holding the actual value. */ 89 uint64_t c; 90 91 public: 92 |
93 /** Explicit constructor assigning a value. */ 94 explicit constexpr Cycles(uint64_t _c) : c(_c) { } |
95 96 /** Default constructor for parameter classes. */ 97 Cycles() : c(0) { } 98 |
99 /** Converting back to the value type. */ 100 constexpr operator uint64_t() const { return c; } 101 102 /** Prefix increment operator. */ 103 Cycles& operator++() 104 { ++c; return *this; } 105 106 /** Prefix decrement operator. Is only temporarily used in the O3 CPU. */ --- 19 unchanged lines hidden (view full) --- 126 127 constexpr Cycles operator <<(const int32_t shift) const 128 { return Cycles(c << shift); } 129 130 constexpr Cycles operator >>(const int32_t shift) const 131 { return Cycles(c >> shift); } 132 133 friend std::ostream& operator<<(std::ostream &out, const Cycles & cycles); |
134}; 135 136/** 137 * Address type 138 * This will probably be moved somewhere else in the near future. 139 * This should be at least as big as the biggest address width in use 140 * in the system, which will probably be 64 bits. 141 */ --- 37 unchanged lines hidden (view full) --- 179 * Port index/ID type, and a symbolic name for an invalid port id. 180 */ 181typedef int16_t PortID; 182const PortID InvalidPortID = (PortID)-1; 183 184class FaultBase; 185typedef std::shared_ptr<FaultBase> Fault; 186 |
187// Rather than creating a shared_ptr instance and assigning it nullptr, 188// we just create an alias. 189constexpr decltype(nullptr) NoFault = nullptr; |
190 191struct AtomicOpFunctor 192{ 193 virtual void operator()(uint8_t *p) = 0; 194 virtual ~AtomicOpFunctor() {} 195}; 196 197template <class T> --- 12 unchanged lines hidden --- |