3 * Copyright (c) 1999-2005 Mark D. Hill and David A. Wood
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * $Id: MOESI_CMP_token-dir.sm 1.6 05/01/19 15:48:35-06:00 mikem@royal16.cs.wisc.edu $
35 machine(Directory, "Token protocol") {
37 MessageBuffer requestToDir, network="From", virtual_network="2", ordered="false";
38 MessageBuffer responseToDir, network="From", virtual_network="3", ordered="false";
39 MessageBuffer responseFromDir, network="To", virtual_network="3", ordered="false";
42 enumeration(State, desc="Directory states", default="Directory_State_I") {
48 enumeration(Event, desc="Directory events") {
49 Fetch, desc="A GETX arrives";
50 Data, desc="A GETS arrives";
56 structure(Entry, desc="...") {
57 DataBlock DataBlk, desc="data for the block";
60 external_type(DirectoryMemory) {
61 Entry lookup(Address);
62 bool isPresent(Address);
68 DirectoryMemory directory, constructor_hack="i";
70 State getState(Address addr) {
74 void setState(Address addr, State state) {
78 out_port(responseNetwork_out, ResponseMsg, responseFromDir);
82 in_port(requestNetwork_in, RequestMsg, requestToDir) {
83 if (requestNetwork_in.isReady()) {
84 peek(requestNetwork_in, RequestMsg) {
85 assert(in_msg.Destination.isElement(machineID));
86 if (in_msg.Type == CoherenceRequestType:GETS) {
87 trigger(Event:Fetch, in_msg.Address);
88 } else if (in_msg.Type == CoherenceRequestType:GETX) {
89 trigger(Event:Fetch, in_msg.Address);
91 error("Invalid message");
97 in_port(responseNetwork_in, ResponseMsg, responseToDir) {
98 if (responseNetwork_in.isReady()) {
99 peek(responseNetwork_in, ResponseMsg) {
100 assert(in_msg.Destination.isElement(machineID));
101 if (in_msg.Type == CoherenceResponseType:MEMORY_DATA) {
102 trigger(Event:Data, in_msg.Address);
104 DEBUG_EXPR(in_msg.Type);
105 error("Invalid message");
112 action(a_sendAck, "a", desc="Send ack to L2") {
113 peek(responseNetwork_in, ResponseMsg) {
114 enqueue(responseNetwork_out, ResponseMsg, latency="MEMORY_LATENCY") {
115 out_msg.Address := address;
116 out_msg.Type := CoherenceResponseType:MEMORY_ACK;
117 out_msg.Sender := machineID;
118 out_msg.Destination.add(in_msg.Sender);
119 out_msg.MessageSize := MessageSizeType:Response_Control;
124 action(d_sendData, "d", desc="Send data to requestor") {
125 peek(requestNetwork_in, RequestMsg) {
126 enqueue(responseNetwork_out, ResponseMsg, latency="MEMORY_LATENCY") {
127 out_msg.Address := address;
128 out_msg.Type := CoherenceResponseType:MEMORY_DATA;
129 out_msg.Sender := machineID;
130 out_msg.Destination.add(in_msg.Requestor);
131 out_msg.DataBlk := directory[in_msg.Address].DataBlk;
132 out_msg.Dirty := false;
133 out_msg.MessageSize := MessageSizeType:Response_Data;
138 action(j_popIncomingRequestQueue, "j", desc="Pop incoming request queue") {
139 requestNetwork_in.dequeue();
142 action(k_popIncomingResponseQueue, "k", desc="Pop incoming request queue") {
143 responseNetwork_in.dequeue();
146 action(m_writeDataToMemory, "m", desc="Write dirty writeback to memory") {
147 peek(responseNetwork_in, ResponseMsg) {
148 directory[in_msg.Address].DataBlk := in_msg.DataBlk;
149 DEBUG_EXPR(in_msg.Address);
150 DEBUG_EXPR(in_msg.DataBlk);
156 transition(I, Fetch) {
158 j_popIncomingRequestQueue;
161 transition(I, Data) {
164 k_popIncomingResponseQueue;