114184Sgabeblack@google.com/*
214184Sgabeblack@google.com * Copyright (c) 2009 Advanced Micro Devices, Inc.
314184Sgabeblack@google.com * All rights reserved.
414184Sgabeblack@google.com *
514184Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
614184Sgabeblack@google.com * modification, are permitted provided that the following conditions are
714184Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
814184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
914184Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1014184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1114184Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1214184Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1314184Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1414184Sgabeblack@google.com * this software without specific prior written permission.
1514184Sgabeblack@google.com *
1614184Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1714184Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1814184Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1914184Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2014184Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2114184Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2214184Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2314184Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2414184Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2514184Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2614184Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2714184Sgabeblack@google.com *
2814184Sgabeblack@google.com *
2914184Sgabeblack@google.com * Authors: Brad Beckmann
3014184Sgabeblack@google.com *          Tushar Krishna
3114184Sgabeblack@google.com */
3214184Sgabeblack@google.com
3314184Sgabeblack@google.com
3414184Sgabeblack@google.commachine(MachineType:Directory, "Garnet_standalone Directory")
3514184Sgabeblack@google.com    : MessageBuffer * requestToDir, network="From", virtual_network="0",
3614184Sgabeblack@google.com            vnet_type = "request";
3714184Sgabeblack@google.com      MessageBuffer * forwardToDir, network="From", virtual_network="1",
3814184Sgabeblack@google.com            vnet_type = "forward";
3914184Sgabeblack@google.com      MessageBuffer * responseToDir, network="From", virtual_network="2",
4014184Sgabeblack@google.com            vnet_type = "response";
4114184Sgabeblack@google.com{
4214184Sgabeblack@google.com  // STATES
4314184Sgabeblack@google.com  state_declaration(State, desc="Directory states", default="Directory_State_I") {
4414184Sgabeblack@google.com    // Base states
4514184Sgabeblack@google.com    I, AccessPermission:Invalid, desc="Invalid";
4614184Sgabeblack@google.com  }
4714184Sgabeblack@google.com
4814184Sgabeblack@google.com  // Events
4914184Sgabeblack@google.com  enumeration(Event, desc="Directory events") {
5014184Sgabeblack@google.com    // processor requests
5114184Sgabeblack@google.com    Receive_Request, desc="Receive Message";
5214184Sgabeblack@google.com    Receive_Forward, desc="Receive Message";
5314184Sgabeblack@google.com    Receive_Response, desc="Receive Message";
5414184Sgabeblack@google.com  }
5514184Sgabeblack@google.com
5614184Sgabeblack@google.com  // TYPES
5714184Sgabeblack@google.com  // DirectoryEntry
5814184Sgabeblack@google.com  structure(Entry, desc="...", interface="AbstractEntry") {
5914184Sgabeblack@google.com    State DirectoryState,          desc="Directory state";
6014184Sgabeblack@google.com    DataBlock DataBlk,             desc="data for the block";
6114184Sgabeblack@google.com  }
6214184Sgabeblack@google.com
6314184Sgabeblack@google.com  // ** FUNCTIONS **
6414184Sgabeblack@google.com  Tick clockEdge();
6514184Sgabeblack@google.com
6614184Sgabeblack@google.com  State getState(Addr addr) {
6714184Sgabeblack@google.com    return State:I;
6814184Sgabeblack@google.com  }
6914184Sgabeblack@google.com
7014184Sgabeblack@google.com  void setState(Addr addr, State state) {
7114184Sgabeblack@google.com
7214184Sgabeblack@google.com  }
7314184Sgabeblack@google.com
7414184Sgabeblack@google.com  AccessPermission getAccessPermission(Addr addr) {
7514184Sgabeblack@google.com    return AccessPermission:NotPresent;
7614184Sgabeblack@google.com  }
7714184Sgabeblack@google.com
7814184Sgabeblack@google.com  void setAccessPermission(Addr addr, State state) {
7914184Sgabeblack@google.com  }
8014184Sgabeblack@google.com
8114184Sgabeblack@google.com  void functionalRead(Addr addr, Packet *pkt) {
8214184Sgabeblack@google.com    error("Garnet_standalone does not support functional read.");
8314184Sgabeblack@google.com  }
8414184Sgabeblack@google.com
8514184Sgabeblack@google.com  int functionalWrite(Addr addr, Packet *pkt) {
8614184Sgabeblack@google.com    error("Garnet_standalone does not support functional write.");
8714184Sgabeblack@google.com  }
8814184Sgabeblack@google.com
8914184Sgabeblack@google.com  // ** IN_PORTS **
9014184Sgabeblack@google.com
9114184Sgabeblack@google.com  in_port(requestQueue_in, RequestMsg, requestToDir) {
9214184Sgabeblack@google.com    if (requestQueue_in.isReady(clockEdge())) {
9314184Sgabeblack@google.com      peek(requestQueue_in, RequestMsg) {
9414184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:MSG) {
9514184Sgabeblack@google.com          trigger(Event:Receive_Request, in_msg.addr);
9614184Sgabeblack@google.com        } else {
9714184Sgabeblack@google.com          error("Invalid message");
9814184Sgabeblack@google.com        }
9914184Sgabeblack@google.com      }
10014184Sgabeblack@google.com    }
10114184Sgabeblack@google.com  }
10214184Sgabeblack@google.com  in_port(forwardQueue_in, RequestMsg, forwardToDir) {
10314184Sgabeblack@google.com    if (forwardQueue_in.isReady(clockEdge())) {
10414184Sgabeblack@google.com      peek(forwardQueue_in, RequestMsg) {
10514184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:MSG) {
10614184Sgabeblack@google.com          trigger(Event:Receive_Forward, in_msg.addr);
10714184Sgabeblack@google.com        } else {
10814184Sgabeblack@google.com          error("Invalid message");
10914184Sgabeblack@google.com        }
11014184Sgabeblack@google.com      }
11114184Sgabeblack@google.com    }
11214184Sgabeblack@google.com  }
11314184Sgabeblack@google.com  in_port(responseQueue_in, RequestMsg, responseToDir) {
11414184Sgabeblack@google.com    if (responseQueue_in.isReady(clockEdge())) {
11514184Sgabeblack@google.com      peek(responseQueue_in, RequestMsg) {
11614184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:MSG) {
11714184Sgabeblack@google.com          trigger(Event:Receive_Response, in_msg.addr);
11814184Sgabeblack@google.com        } else {
11914184Sgabeblack@google.com          error("Invalid message");
12014184Sgabeblack@google.com        }
12114184Sgabeblack@google.com      }
12214184Sgabeblack@google.com    }
12314184Sgabeblack@google.com  }
12414184Sgabeblack@google.com
12514184Sgabeblack@google.com  // Actions
12614184Sgabeblack@google.com
12714184Sgabeblack@google.com  action(i_popIncomingRequestQueue, "i", desc="Pop incoming request queue") {
12814184Sgabeblack@google.com    requestQueue_in.dequeue(clockEdge());
12914184Sgabeblack@google.com  }
13014184Sgabeblack@google.com
13114184Sgabeblack@google.com  action(f_popIncomingForwardQueue, "f", desc="Pop incoming forward queue") {
13214184Sgabeblack@google.com    forwardQueue_in.dequeue(clockEdge());
13314184Sgabeblack@google.com  }
13414184Sgabeblack@google.com
13514184Sgabeblack@google.com  action(r_popIncomingResponseQueue, "r", desc="Pop incoming response queue") {
13614184Sgabeblack@google.com    responseQueue_in.dequeue(clockEdge());
13714184Sgabeblack@google.com  }
13814184Sgabeblack@google.com
13914184Sgabeblack@google.com  // TRANSITIONS
14014184Sgabeblack@google.com
14114184Sgabeblack@google.com  // The directory simply drops the received packets.
14214184Sgabeblack@google.com  // The goal of Garnet_standalone is only to track network stats.
14314184Sgabeblack@google.com
14414184Sgabeblack@google.com  transition(I, Receive_Request) {
14514184Sgabeblack@google.com    i_popIncomingRequestQueue;
14614184Sgabeblack@google.com  }
14714184Sgabeblack@google.com  transition(I, Receive_Forward) {
14814184Sgabeblack@google.com    f_popIncomingForwardQueue;
14914184Sgabeblack@google.com  }
15014184Sgabeblack@google.com  transition(I, Receive_Response) {
15114184Sgabeblack@google.com    r_popIncomingResponseQueue;
15214184Sgabeblack@google.com  }
15314184Sgabeblack@google.com}
154