2011-03-22 03:51:58 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009 Advanced Micro Devices, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors: Brad Beckmann
|
|
|
|
* Tushar Krishna
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-10-06 20:35:14 +02:00
|
|
|
machine(MachineType:L1Cache, "Garnet_standalone L1 Cache")
|
2014-09-01 23:55:47 +02:00
|
|
|
: Sequencer * sequencer;
|
|
|
|
Cycles issue_latency := 2;
|
2011-03-22 03:51:58 +01:00
|
|
|
|
2014-09-01 23:55:47 +02:00
|
|
|
// NETWORK BUFFERS
|
|
|
|
MessageBuffer * requestFromCache, network="To", virtual_network="0",
|
2015-08-14 07:19:45 +02:00
|
|
|
vnet_type = "request";
|
2014-09-01 23:55:47 +02:00
|
|
|
MessageBuffer * forwardFromCache, network="To", virtual_network="1",
|
2015-08-14 07:19:45 +02:00
|
|
|
vnet_type = "forward";
|
2014-09-01 23:55:47 +02:00
|
|
|
MessageBuffer * responseFromCache, network="To", virtual_network="2",
|
2015-08-14 07:19:45 +02:00
|
|
|
vnet_type = "response";
|
2015-09-05 16:34:24 +02:00
|
|
|
|
|
|
|
MessageBuffer * mandatoryQueue;
|
2014-09-01 23:55:47 +02:00
|
|
|
{
|
2011-03-22 03:51:58 +01:00
|
|
|
// STATES
|
|
|
|
state_declaration(State, desc="Cache states", default="L1Cache_State_I") {
|
|
|
|
I, AccessPermission:Invalid, desc="Not Present/Invalid";
|
|
|
|
}
|
|
|
|
|
|
|
|
// EVENTS
|
|
|
|
enumeration(Event, desc="Cache events") {
|
|
|
|
// From processor
|
2016-10-06 20:35:14 +02:00
|
|
|
Request, desc="Request from Garnet_standalone";
|
|
|
|
Forward, desc="Forward from Garnet_standalone";
|
|
|
|
Response, desc="Response from Garnet_standalone";
|
2011-03-22 03:51:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// STRUCTURE DEFINITIONS
|
|
|
|
DataBlock dummyData;
|
|
|
|
|
|
|
|
// CacheEntry
|
|
|
|
structure(Entry, desc="...", interface="AbstractCacheEntry") {
|
|
|
|
State CacheState, desc="cache state";
|
|
|
|
DataBlock DataBlk, desc="Data in the block";
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTIONS
|
2015-09-16 18:59:56 +02:00
|
|
|
Tick clockEdge();
|
2011-03-22 03:51:58 +01:00
|
|
|
|
|
|
|
// cpu/testers/networktest/networktest.cc generates packets of the type
|
|
|
|
// ReadReq, INST_FETCH, and WriteReq.
|
|
|
|
// These are converted to LD, IFETCH and ST by mem/ruby/system/RubyPort.cc.
|
|
|
|
// These are then sent to the sequencer, which sends them here.
|
2016-10-06 20:35:14 +02:00
|
|
|
// Garnet_standalone-cache.sm tags LD, IFETCH and ST as Request, Forward,
|
2011-03-22 03:51:58 +01:00
|
|
|
// and Response Events respectively, which are then injected into
|
|
|
|
// virtual networks 0, 1 and 2 respectively.
|
|
|
|
// This models traffic of different types within the network.
|
|
|
|
//
|
|
|
|
// Note that requests and forwards are MessageSizeType:Control,
|
|
|
|
// while responses are MessageSizeType:Data.
|
|
|
|
//
|
|
|
|
Event mandatory_request_type_to_event(RubyRequestType type) {
|
|
|
|
if (type == RubyRequestType:LD) {
|
|
|
|
return Event:Request;
|
|
|
|
} else if (type == RubyRequestType:IFETCH) {
|
|
|
|
return Event:Forward;
|
|
|
|
} else if (type == RubyRequestType:ST) {
|
|
|
|
return Event:Response;
|
|
|
|
} else {
|
|
|
|
error("Invalid RubyRequestType");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
State getState(Entry cache_entry, Addr addr) {
|
2011-03-22 03:51:58 +01:00
|
|
|
return State:I;
|
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
void setState(Entry cache_entry, Addr addr, State state) {
|
2011-03-22 03:51:58 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
AccessPermission getAccessPermission(Addr addr) {
|
2011-06-08 18:58:09 +02:00
|
|
|
return AccessPermission:NotPresent;
|
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
void setAccessPermission(Entry cache_entry, Addr addr, State state) {
|
2011-06-08 18:58:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
Entry getCacheEntry(Addr address), return_by_pointer="yes" {
|
2011-03-22 03:51:58 +01:00
|
|
|
return OOD;
|
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
void functionalRead(Addr addr, Packet *pkt) {
|
2016-10-06 20:35:14 +02:00
|
|
|
error("Garnet_standalone does not support functional read.");
|
2014-11-06 12:42:20 +01:00
|
|
|
}
|
|
|
|
|
2015-08-14 19:04:51 +02:00
|
|
|
int functionalWrite(Addr addr, Packet *pkt) {
|
2016-10-06 20:35:14 +02:00
|
|
|
error("Garnet_standalone does not support functional write.");
|
2011-07-03 18:33:46 +02:00
|
|
|
}
|
2011-03-22 03:51:58 +01:00
|
|
|
|
|
|
|
// NETWORK PORTS
|
|
|
|
|
|
|
|
out_port(requestNetwork_out, RequestMsg, requestFromCache);
|
|
|
|
out_port(forwardNetwork_out, RequestMsg, forwardFromCache);
|
|
|
|
out_port(responseNetwork_out, RequestMsg, responseFromCache);
|
|
|
|
|
|
|
|
// Mandatory Queue
|
2011-03-22 12:41:54 +01:00
|
|
|
in_port(mandatoryQueue_in, RubyRequest, mandatoryQueue, desc="...") {
|
2015-09-16 18:59:56 +02:00
|
|
|
if (mandatoryQueue_in.isReady(clockEdge())) {
|
2011-03-22 12:41:54 +01:00
|
|
|
peek(mandatoryQueue_in, RubyRequest) {
|
2011-03-22 03:51:58 +01:00
|
|
|
trigger(mandatory_request_type_to_event(in_msg.Type),
|
2012-12-11 17:05:55 +01:00
|
|
|
in_msg.LineAddress, getCacheEntry(in_msg.LineAddress));
|
2011-03-22 03:51:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ACTIONS
|
|
|
|
|
|
|
|
// The destination directory of the packets is embedded in the address
|
|
|
|
// map_Address_to_Directory is used to retrieve it.
|
|
|
|
|
|
|
|
action(a_issueRequest, "a", desc="Issue a request") {
|
2014-04-08 20:26:30 +02:00
|
|
|
enqueue(requestNetwork_out, RequestMsg, issue_latency) {
|
2015-08-14 19:04:47 +02:00
|
|
|
out_msg.addr := address;
|
2011-03-22 03:51:58 +01:00
|
|
|
out_msg.Type := CoherenceRequestType:MSG;
|
|
|
|
out_msg.Requestor := machineID;
|
|
|
|
out_msg.Destination.add(map_Address_to_Directory(address));
|
2016-10-06 20:35:14 +02:00
|
|
|
|
|
|
|
// To send broadcasts in vnet0 (to emulate broadcast-based protocols),
|
|
|
|
// replace the above line by the following:
|
|
|
|
// out_msg.Destination := broadcast(MachineType:Directory);
|
|
|
|
|
2011-03-22 03:51:58 +01:00
|
|
|
out_msg.MessageSize := MessageSizeType:Control;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
action(b_issueForward, "b", desc="Issue a forward") {
|
2014-04-08 20:26:30 +02:00
|
|
|
enqueue(forwardNetwork_out, RequestMsg, issue_latency) {
|
2015-08-14 19:04:47 +02:00
|
|
|
out_msg.addr := address;
|
2011-03-22 03:51:58 +01:00
|
|
|
out_msg.Type := CoherenceRequestType:MSG;
|
|
|
|
out_msg.Requestor := machineID;
|
|
|
|
out_msg.Destination.add(map_Address_to_Directory(address));
|
|
|
|
out_msg.MessageSize := MessageSizeType:Control;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
action(c_issueResponse, "c", desc="Issue a response") {
|
2014-04-08 20:26:30 +02:00
|
|
|
enqueue(responseNetwork_out, RequestMsg, issue_latency) {
|
2015-08-14 19:04:47 +02:00
|
|
|
out_msg.addr := address;
|
2011-03-22 03:51:58 +01:00
|
|
|
out_msg.Type := CoherenceRequestType:MSG;
|
|
|
|
out_msg.Requestor := machineID;
|
|
|
|
out_msg.Destination.add(map_Address_to_Directory(address));
|
|
|
|
out_msg.MessageSize := MessageSizeType:Data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
action(m_popMandatoryQueue, "m", desc="Pop the mandatory request queue") {
|
2015-09-16 18:59:56 +02:00
|
|
|
mandatoryQueue_in.dequeue(clockEdge());
|
2011-03-22 03:51:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
action(r_load_hit, "r", desc="Notify sequencer the load completed.") {
|
|
|
|
sequencer.readCallback(address, dummyData);
|
|
|
|
}
|
|
|
|
|
|
|
|
action(s_store_hit, "s", desc="Notify sequencer that store completed.") {
|
|
|
|
sequencer.writeCallback(address, dummyData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TRANSITIONS
|
|
|
|
|
|
|
|
// sequencer hit call back is performed after injecting the packets.
|
2016-10-06 20:35:14 +02:00
|
|
|
// The goal of the Garnet_standalone protocol is only to inject packets into
|
2011-03-22 03:51:58 +01:00
|
|
|
// the network, not to keep track of them via TBEs.
|
|
|
|
|
|
|
|
transition(I, Response) {
|
|
|
|
s_store_hit;
|
|
|
|
c_issueResponse;
|
|
|
|
m_popMandatoryQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
transition(I, Request) {
|
|
|
|
r_load_hit;
|
|
|
|
a_issueRequest;
|
|
|
|
m_popMandatoryQueue;
|
|
|
|
}
|
|
|
|
transition(I, Forward) {
|
|
|
|
r_load_hit;
|
|
|
|
b_issueForward;
|
|
|
|
m_popMandatoryQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|