Deleted Added
sdiff udiff text old ( 10428:0caf62b57dfd ) new ( 11555:2efa95cf8504 )
full compact
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
47MemCommand::MemCommand() :
48 type(MemCommand::PRE),
49 bank(0),
50 timestamp(0)
51{
52}
53
54MemCommand::MemCommand(MemCommand::cmds type,
55 unsigned bank, double timestamp) :
56 type(type),
57 bank(bank),
58 timestamp(timestamp)
59{
60}
61
62void MemCommand::setType(MemCommand::cmds _type)
63{

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

75}
76
77unsigned MemCommand::getBank() const
78{
79 return bank;
80}
81
82// For auto-precharge with read or write - to calculate cycle of precharge
83int MemCommand::getPrechargeOffset(const MemorySpecification& memSpec,
84 MemCommand::cmds type) const
85{
86 int precharge_offset = 0;
87
88 int BL(static_cast<int>(memSpec.memArchSpec.burstLength));
89 int RTP(static_cast<int>(memSpec.memTimingSpec.RTP));
90 int dataRate(static_cast<int>(memSpec.memArchSpec.dataRate));
91 int AL(static_cast<int>(memSpec.memTimingSpec.AL));
92 int WL(static_cast<int>(memSpec.memTimingSpec.WL));
93 int WR(static_cast<int>(memSpec.memTimingSpec.WR));
94 int B = BL/dataRate;
95
96 const MemoryType::MemoryType_t& memType = memSpec.memoryType;
97
98 // Read with auto-precharge
99 if (type == MemCommand::RDA) {
100 if (memType == MemoryType::DDR2) {
101 precharge_offset = B + AL - 2 + max(RTP, 2);
102 } else if (memType == MemoryType::DDR3) {
103 precharge_offset = AL + max(RTP, 4);
104 } else if (memType == MemoryType::DDR4) {
105 precharge_offset = AL + RTP;
106 } else if (memType == MemoryType::LPDDR) {
107 precharge_offset = B;
108 } else if (memType == MemoryType::LPDDR2) {
109 precharge_offset = B + max(0, RTP - 2);
110 } else if (memType == MemoryType::LPDDR3) {
111 precharge_offset = B + max(0, RTP - 4);
112 } else if (memType == MemoryType::WIDEIO_SDR) {
113 precharge_offset = B;
114 }
115 } else if (type == MemCommand::WRA) { // Write with auto-precharge
116 if (memType == MemoryType::DDR2) {
117 precharge_offset = B + WL + WR;
118 } else if (memType == MemoryType::DDR3) {
119 precharge_offset = B + WL + WR;

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

128 } else if (memType == MemoryType::WIDEIO_SDR) {
129 precharge_offset = B + WL + WR - 1;
130 }
131 }
132
133 return precharge_offset;
134} // MemCommand::getPrechargeOffset
135
136void MemCommand::setTime(double _timestamp)
137{
138 timestamp = _timestamp;
139}
140
141double MemCommand::getTime() const
142{
143 return timestamp;
144}
145
146int64_t MemCommand::getTimeInt64() const
147{
148 return static_cast<int64_t>(timestamp);
149}
150
151MemCommand::cmds MemCommand::typeWithoutAutoPrechargeFlag() const
152{
153 if (type == MemCommand::RDA) {
154 return MemCommand::RD;
155 } else if (type == MemCommand::WRA) {
156 return MemCommand::WR;
157 }
158 return type;
159}