ruby: message buffers: significant changes
[gem5.git] / src / mem / protocol / Network_test-dir.sm
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
34 machine(Directory, "Network_test Directory")
35 : MessageBuffer * requestToDir, network="From", virtual_network="0",
36 ordered="false", vnet_type = "request";
37 MessageBuffer * forwardToDir, network="From", virtual_network="1",
38 ordered="false", vnet_type = "forward";
39 MessageBuffer * responseToDir, network="From", virtual_network="2",
40 ordered="false", 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 // ** OBJECTS **
64 State getState(Address addr) {
65 return State:I;
66 }
67
68 void setState(Address addr, State state) {
69
70 }
71
72 AccessPermission getAccessPermission(Address addr) {
73 return AccessPermission:NotPresent;
74 }
75
76 void setAccessPermission(Address addr, State state) {
77 }
78
79 DataBlock getDataBlock(Address addr), return_by_ref="yes" {
80 error("Network Test does not support get data block.");
81 }
82
83 // ** IN_PORTS **
84
85 in_port(requestQueue_in, RequestMsg, requestToDir) {
86 if (requestQueue_in.isReady()) {
87 peek(requestQueue_in, RequestMsg) {
88 if (in_msg.Type == CoherenceRequestType:MSG) {
89 trigger(Event:Receive_Request, in_msg.Addr);
90 } else {
91 error("Invalid message");
92 }
93 }
94 }
95 }
96 in_port(forwardQueue_in, RequestMsg, forwardToDir) {
97 if (forwardQueue_in.isReady()) {
98 peek(forwardQueue_in, RequestMsg) {
99 if (in_msg.Type == CoherenceRequestType:MSG) {
100 trigger(Event:Receive_Forward, in_msg.Addr);
101 } else {
102 error("Invalid message");
103 }
104 }
105 }
106 }
107 in_port(responseQueue_in, RequestMsg, responseToDir) {
108 if (responseQueue_in.isReady()) {
109 peek(responseQueue_in, RequestMsg) {
110 if (in_msg.Type == CoherenceRequestType:MSG) {
111 trigger(Event:Receive_Response, in_msg.Addr);
112 } else {
113 error("Invalid message");
114 }
115 }
116 }
117 }
118
119 // Actions
120
121 action(i_popIncomingRequestQueue, "i", desc="Pop incoming request queue") {
122 requestQueue_in.dequeue();
123 }
124
125 action(f_popIncomingForwardQueue, "f", desc="Pop incoming forward queue") {
126 forwardQueue_in.dequeue();
127 }
128
129 action(r_popIncomingResponseQueue, "r", desc="Pop incoming response queue") {
130 responseQueue_in.dequeue();
131 }
132
133 // TRANSITIONS
134
135 // The directory simply drops the received packets.
136 // The goal of Network_test is only to track network stats.
137
138 transition(I, Receive_Request) {
139 i_popIncomingRequestQueue;
140 }
141 transition(I, Receive_Forward) {
142 f_popIncomingForwardQueue;
143 }
144 transition(I, Receive_Response) {
145 r_popIncomingResponseQueue;
146 }
147 }