1/*
2 * Copyright (c) 2009 Advanced Micro Devices, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 *
29 * Authors: Brad Beckmann
30 *          Tushar Krishna
31 */
32
33
34machine(MachineType:Directory, "Garnet_standalone Directory")
35    : MessageBuffer * requestToDir, network="From", virtual_network="0",
36            vnet_type = "request";
37      MessageBuffer * forwardToDir, network="From", virtual_network="1",
38            vnet_type = "forward";
39      MessageBuffer * responseToDir, network="From", virtual_network="2",
40            vnet_type = "response";
41{
42  // STATES
43  state_declaration(State, desc="Directory states", default="Directory_State_I") {
44    // Base states
45    I, AccessPermission:Invalid, desc="Invalid";
46  }
47
48  // Events
49  enumeration(Event, desc="Directory events") {
50    // processor requests
51    Receive_Request, desc="Receive Message";
52    Receive_Forward, desc="Receive Message";
53    Receive_Response, desc="Receive Message";
54  }
55
56  // TYPES
57  // DirectoryEntry
58  structure(Entry, desc="...", interface="AbstractEntry") {
59    State DirectoryState,          desc="Directory state";
60    DataBlock DataBlk,             desc="data for the block";
61  }
62
63  // ** FUNCTIONS **
64  Tick clockEdge();
65
66  State getState(Addr addr) {
67    return State:I;
68  }
69
70  void setState(Addr addr, State state) {
71
72  }
73
74  AccessPermission getAccessPermission(Addr addr) {
75    return AccessPermission:NotPresent;
76  }
77
78  void setAccessPermission(Addr addr, State state) {
79  }
80
81  void functionalRead(Addr addr, Packet *pkt) {
82    error("Garnet_standalone does not support functional read.");
83  }
84
85  int functionalWrite(Addr addr, Packet *pkt) {
86    error("Garnet_standalone does not support functional write.");
87  }
88
89  // ** IN_PORTS **
90
91  in_port(requestQueue_in, RequestMsg, requestToDir) {
92    if (requestQueue_in.isReady(clockEdge())) {
93      peek(requestQueue_in, RequestMsg) {
94        if (in_msg.Type == CoherenceRequestType:MSG) {
95          trigger(Event:Receive_Request, in_msg.addr);
96        } else {
97          error("Invalid message");
98        }
99      }
100    }
101  }
102  in_port(forwardQueue_in, RequestMsg, forwardToDir) {
103    if (forwardQueue_in.isReady(clockEdge())) {
104      peek(forwardQueue_in, RequestMsg) {
105        if (in_msg.Type == CoherenceRequestType:MSG) {
106          trigger(Event:Receive_Forward, in_msg.addr);
107        } else {
108          error("Invalid message");
109        }
110      }
111    }
112  }
113  in_port(responseQueue_in, RequestMsg, responseToDir) {
114    if (responseQueue_in.isReady(clockEdge())) {
115      peek(responseQueue_in, RequestMsg) {
116        if (in_msg.Type == CoherenceRequestType:MSG) {
117          trigger(Event:Receive_Response, in_msg.addr);
118        } else {
119          error("Invalid message");
120        }
121      }
122    }
123  }
124
125  // Actions
126
127  action(i_popIncomingRequestQueue, "i", desc="Pop incoming request queue") {
128    requestQueue_in.dequeue(clockEdge());
129  }
130
131  action(f_popIncomingForwardQueue, "f", desc="Pop incoming forward queue") {
132    forwardQueue_in.dequeue(clockEdge());
133  }
134
135  action(r_popIncomingResponseQueue, "r", desc="Pop incoming response queue") {
136    responseQueue_in.dequeue(clockEdge());
137  }
138
139  // TRANSITIONS
140
141  // The directory simply drops the received packets.
142  // The goal of Garnet_standalone is only to track network stats.
143
144  transition(I, Receive_Request) {
145    i_popIncomingRequestQueue;
146  }
147  transition(I, Receive_Forward) {
148    f_popIncomingForwardQueue;
149  }
150  transition(I, Receive_Response) {
151    r_popIncomingResponseQueue;
152  }
153}
154