1/* 2 * Copyright (c) 2012-2014, TU Delft 3 * Copyright (c) 2012-2014, TU Eindhoven 4 * Copyright (c) 2012-2014, TU Kaiserslautern 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 30 unchanged lines hidden (view full) --- 39 40#include <algorithm> // for max 41 42#include "MemorySpecification.h" 43 44using namespace Data; 45using namespace std; 46 |
47 48MemCommand::MemCommand(MemCommand::cmds type, |
49 unsigned bank, int64_t timestamp) : |
50 type(type), 51 bank(bank), 52 timestamp(timestamp) 53{ 54} 55 56void MemCommand::setType(MemCommand::cmds _type) 57{ --- 11 unchanged lines hidden (view full) --- 69} 70 71unsigned MemCommand::getBank() const 72{ 73 return bank; 74} 75 76// For auto-precharge with read or write - to calculate cycle of precharge |
77int64_t MemCommand::getPrechargeOffset(const MemorySpecification& memSpec, |
78 MemCommand::cmds type) const 79{ |
80 int64_t precharge_offset = 0; |
81 |
82 int64_t BL = memSpec.memArchSpec.burstLength; 83 int64_t RTP = memSpec.memTimingSpec.RTP; 84 int64_t dataRate = memSpec.memArchSpec.dataRate; 85 int64_t AL = memSpec.memTimingSpec.AL; 86 int64_t WL = memSpec.memTimingSpec.WL; 87 int64_t WR = memSpec.memTimingSpec.WR; 88 int64_t B = BL/dataRate; |
89 90 const MemoryType::MemoryType_t& memType = memSpec.memoryType; 91 92 // Read with auto-precharge 93 if (type == MemCommand::RDA) { 94 if (memType == MemoryType::DDR2) { |
95 precharge_offset = B + AL - 2 + max(RTP, int64_t(2)); |
96 } else if (memType == MemoryType::DDR3) { |
97 precharge_offset = AL + max(RTP, int64_t(4)); |
98 } else if (memType == MemoryType::DDR4) { 99 precharge_offset = AL + RTP; 100 } else if (memType == MemoryType::LPDDR) { 101 precharge_offset = B; 102 } else if (memType == MemoryType::LPDDR2) { |
103 precharge_offset = B + max(int64_t(0), RTP - 2); |
104 } else if (memType == MemoryType::LPDDR3) { |
105 precharge_offset = B + max(int64_t(0), RTP - 4); |
106 } else if (memType == MemoryType::WIDEIO_SDR) { 107 precharge_offset = B; 108 } 109 } else if (type == MemCommand::WRA) { // Write with auto-precharge 110 if (memType == MemoryType::DDR2) { 111 precharge_offset = B + WL + WR; 112 } else if (memType == MemoryType::DDR3) { 113 precharge_offset = B + WL + WR; --- 8 unchanged lines hidden (view full) --- 122 } else if (memType == MemoryType::WIDEIO_SDR) { 123 precharge_offset = B + WL + WR - 1; 124 } 125 } 126 127 return precharge_offset; 128} // MemCommand::getPrechargeOffset 129 |
130void MemCommand::setTime(int64_t _timestamp) |
131{ 132 timestamp = _timestamp; 133} 134 |
135int64_t MemCommand::getTimeInt64() const |
136{ 137 return timestamp; 138} 139 |
140MemCommand::cmds MemCommand::typeWithoutAutoPrechargeFlag() const 141{ 142 if (type == MemCommand::RDA) { 143 return MemCommand::RD; 144 } else if (type == MemCommand::WRA) { 145 return MemCommand::WR; 146 } 147 return type; 148} |