+2001-06-21 Ben Elliston <bje@redhat.com>
+
+ * cache.h (cache_component::hit_latency): New member.
+ (cache_component::miss_latency): Likewise.
+ * cache.cxx (cache_component ctor): Add attributes for these.
+ (cache_component::write_any): Add miss latency for misaligned
+ accesses. Set latency correctly for return.
+ (cache_component::read_any): Add miss latency for misaligned
+ accesses. Set latency correctly for return.
+ (cache_component::read_line): Return the true result of reads.
+ (cache_component::write_line): Likewise for writes.
+ * hw-cache.txt: Document latency extensions.
+
2001-06-19 Ben Elliston <bje@redhat.com>
* cache.cxx (CacheCreate): Re-work using sidutil::tokenize.
&cache_component::set_nothing,
"register");
+ add_attribute ("hit-latency", &hit_latency, "setting");
+ add_attribute ("miss-latency", &miss_latency, "setting");
+
// FIXME: state save/restore
}
cache_component::write_any (host_int_4 addr, DataType data)
{
bool hit;
- bus::status st;
+ bus::status st, read_status;
if (UNLIKELY (downstream == 0))
return bus::unmapped;
}
acache.expunge (line);
}
- return downstream->read (addr, data);
+
+ st = downstream->read (addr, data);
+ st.latency += miss_latency;
+ return st;
}
cache_line& line = acache.find (acache.addr_to_tag (addr), hit);
{
cache_line expelled_line (line_size);
cache_line new_line (line_size, acache.addr_to_tag (addr));
- if ((st = read_line (new_line)) != bus::ok)
- return st;
+ if ((read_status = read_line (new_line)) != bus::ok)
+ return read_status;
new_line.insert (line_offset (new_line, addr), data);
acache.replace (expelled_line, new_line);
return st;
}
}
- return bus::ok;
+
+ st = bus::ok;
+ if (hit)
+ st.latency = hit_latency;
+ else
+ st.latency = read_status.latency + miss_latency;
+ return st;
}
template <typename DataType>
bus::status
cache_component::read_any (host_int_4 addr, DataType& data)
{
+ bus::status st, read_status;
+
if (UNLIKELY (downstream == 0))
return bus::unmapped;
{
if (LIKELY (collect_p))
stats.misaligned_reads++;
- return downstream->read (addr, data);
+
+ st = downstream->read (addr, data);
+ st.latency += miss_latency;
+ return st;
}
bool hit;
- bus::status st;
-
cache_line& line = acache.find (acache.addr_to_tag (addr), hit);
if (LIKELY (hit))
{
{
cache_line expelled_line (line_size);
cache_line new_line (line_size, acache.addr_to_tag (addr));
-
- if ((st = read_line (new_line)) != bus::ok)
- return st;
- new_line.extract (line_offset (new_line, addr), data);
+ if ((read_status = read_line (new_line)) != bus::ok)
+ return read_status;
+ new_line.extract (line_offset (new_line, addr), data);
acache.replace (expelled_line, new_line);
if (collect_p)
{
// flush a dirty line being replaced
if ((st = write_line (expelled_line)) != bus::ok)
- return st;
+ return st;
}
}
else
- return downstream->read (addr, data);
+ {
+ st = downstream->read (addr, data);
+ st.latency += miss_latency;
+ return st;
+ }
}
- return bus::ok;
+
+ st = bus::ok;
+ if (hit)
+ st.latency += hit_latency;
+ else
+ st.latency = read_status.latency + miss_latency;
+ return st;
}
bus::status
cache_component::read_line (cache_line& line)
{
+ bus::status st;
host_int_4 base = acache.tag_to_addr (line.tag ());
for (host_int_4 offset = 0; offset < line_size; offset += 4)
{
sid::big_int_4 data;
- bus::status st = downstream->read (base + offset, data);
+ st = downstream->read (base + offset, data);
if (st != bus::ok)
return st;
line.insert (offset, data);
line.unlock ();
line.clean ();
line.validate ();
- return bus::ok;
+ return st;
}
bus::status
cache_component::write_line (cache_line& line)
{
+ bus::status st;
host_int_4 base = acache.tag_to_addr (line.tag ());
for (host_int_4 offset = 0; offset < line_size; offset += 4)
{
sid::big_int_4 data;
line.extract (offset, data);
- bus::status st = downstream->write (base + offset, data);
+ st = downstream->write (base + offset, data);
if (st != bus::ok)
return st;
}
line.clean ();
if (LIKELY (collect_p))
stats.flushes++;
- return bus::ok;
+ return st;
}
void
address that falls on the line. Subsequently, a line can be
unlocked by driving the "unlock" pin.
+ * Memory latency
+ The component models the effects of memory latency. The
+ "hit-latency" and "miss-latency" attribute values specify the
+ cumulative latencies for hit and missed cache operations. Any
+ misaligned accesses are penalised as if they are a miss.
+
* Statistics gathering
The component gathers statistics for a number of significant
events and records them in read-only attributes. The collection
- SID conventions
* This is a functional component.
+ * The component models memory latency.
* It presents attributes in the "setting" and "register" categories.
* Environment
- write-hit-rate | register | %age string | 0% | statistics gathering
- collect-statistics? | setting | boolean | true | statistics gathering
- report-heading | setting | string | cache profile report | stats g.
+ - hit-latency | setting | numeric | 0 | memory latency
+ - miss-latency | setting | numeric | 0 | memory latency
- dump! | setting | empty string | empty | internal diagnostics
* References