Constructive Computer Architecture Tutorial 9 Final Project Part

  • Slides: 22
Download presentation
Constructive Computer Architecture Tutorial 9: Final Project: Part 1 Overview and Advice Andy Wright

Constructive Computer Architecture Tutorial 9: Final Project: Part 1 Overview and Advice Andy Wright 6. 175 TA October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -1

Final Project: Part 1 Make four modules: n n mk. Message. FIFO mk. Message.

Final Project: Part 1 Make four modules: n n mk. Message. FIFO mk. Message. Router mk. Parent. Protocol. Processor mk. NBCache To pass five sets of tests: n n n October 7, 2013 message-fifo-test message-router-test ppp-test nb-cache-mini-test nb-cache-test http: //csg. csail. mit. edu/6. s 195 T 05 -2

MSI Overview Three states for each cache line: n n n Invalid Shared Modified

MSI Overview Three states for each cache line: n n n Invalid Shared Modified Cache. Types. bsv has an MSI enumeration n October 7, 2013 Also has instance of Ord typeclass so y > I is a valid expression http: //csg. csail. mit. edu/6. s 195 T 05 -3

Coherency Messages Each message is either a request or a response n n Responses

Coherency Messages Each message is either a request or a response n n Responses can have data, requests cannot Cache to Parent messages: w upgrades are requests w downgrades are responses n Parent to Cache messages: w downgrades are requests w upgrades are responses October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -4

Coherency Message Types Cache. Mem. Resp: (struct) n n Cache. ID child Addr addr

Coherency Message Types Cache. Mem. Resp: (struct) n n Cache. ID child Addr addr MSI state Cache. Line data child sending or receiving request new (or next) state Data for I -> S, M or M -> S, I transitions Cache. Mem. Req: (struct) n n n Cache. ID child Addr addr MSI state child sending or receiving request new (or next) state Cache. Mem. Message: (tagged union) n n October 7, 2013 Cache. Mem. Resp Cache. Mem. Req http: //csg. csail. mit. edu/6. s 195 T 05 -5

Message FIFO Combination of two FIFOs: request FIFO and response FIFO The Dequeue logic

Message FIFO Combination of two FIFOs: request FIFO and response FIFO The Dequeue logic should prefer dequeuing from the response FIFO over the request FIFO October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -6

Message Router Sends messages from caches to the parent protocol processor, and from the

Message Router Sends messages from caches to the parent protocol processor, and from the parent to the correct cache n October 7, 2013 It must not allow requests to block responses from passing through the router http: //csg. csail. mit. edu/6. s 195 T 05 -7

Parent Protocol Processor Handles cache coherency for children caches and communicates with main memory

Parent Protocol Processor Handles cache coherency for children caches and communicates with main memory n October 7, 2013 Contains an MIS state, a waitc state, and the current tag for each cache line in each child cache http: //csg. csail. mit. edu/6. s 195 T 05 -8

Parent Protocol Processor Performs 3 of the 8 rules for our MSI coherency protocol

Parent Protocol Processor Performs 3 of the 8 rules for our MSI coherency protocol n n n October 7, 2013 Rule 2 – Cache n is requesting an upgrade that is compatible with other caches, so send an upgrade response Rule 4 – Send a downgrade request to a cache Rule 6 – Receive a downgrade response from a cache http: //csg. csail. mit. edu/6. s 195 T 05 -9

Parent Protocol Processor Rules 2 and 6 deals with responses that may have data

Parent Protocol Processor Rules 2 and 6 deals with responses that may have data n n October 7, 2013 When sending an upgrade response from I to S or M, the parent protocol processor first needs to read the main memory for the data to send When receiving a downgrade response from M to S or I, the parent protocol processor needs to write the cache line back to main memory http: //csg. csail. mit. edu/6. s 195 T 05 -10

Non-Blocking Cache Handles requests and responses coming from two directions n n n Load

Non-Blocking Cache Handles requests and responses coming from two directions n n n Load and store requests come from the processor Upgrade responses from the parent protocol processor bring in new cache lines Downgrade requests from the parent protocol processor downgrade or evict cache lines Uses store queue and load buffer to keep track of requests in flight October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -11

Non-Blocking Cache Handling load and store requests if load request: n n n if

Non-Blocking Cache Handling load and store requests if load request: n n n if hit in store queue -> return hit if hit in data cache -> return hit otherwise: w insert into load buffer w send upgrade request if possible if store request: n n if hit in data cache and store queue empty -> update data cache otherwise: w insert into store queue w send upgrade request if possible *Send upgrade request if possible implies rule 8 if necessary October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -12

Non-Blocking Cache FSM for handling responses from memory Ready state (if memory to cache

Non-Blocking Cache FSM for handling responses from memory Ready state (if memory to cache message FIFO has response) n n n update cache according to response save response to register go to load hit stage load hit state n n if hit in load buffer -> remove entry and return hit if no hit in load buffer -> go to store hit state n n if hit at head of store queue -> dequeue hit and update data cache if no hit at head of store queue -> go to store req state n n send upgrade request for head of store queue if possible go to load req state n n if conflicting address in load buffer -> send upgrade request if possible go to ready state *Send upgrade request if possible implies rule 8 if necessary October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -13

Non-Blocking Cache Handling requests from memory receiving downgrade to y request from parent if

Non-Blocking Cache Handling requests from memory receiving downgrade to y request from parent if cache line’s tag matches incoming address and the cache line’s state > y: n Do rule 5: w Update cache w send downgrade response if cache line’s tag doesn’t match incoming address or the cache line’s state <= y: n Do rule 7: w Ignore downgrade request October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -14

Module Tests Modules are tested with testbenches that emulate the use of each module

Module Tests Modules are tested with testbenches that emulate the use of each module in a larger system Testbenches are written using the Stmt. FSM library October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -15

Stmt. FSM example 1: Stmt test = (seq Each action in this 2: fifo.

Stmt. FSM example 1: Stmt test = (seq Each action in this 2: fifo. enq(1); seq is performed 3: fifo. enq(2); one at a time 4: action 5: fifo. enq(3); Performed together 6: fifo. deq; 7: endaction 8: action 9: $display(“Done”); 10: $finish; 11: endaction 12: endseq); 13: mk. Auto. FSM(test); Creates the requested FSM. Starts automatically and quits simulation when it finishes. October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -16

Stmt. FSM – Generated Rules Reg#(State) i <- mk. Reg(0); rule L 2 C

Stmt. FSM – Generated Rules Reg#(State) i <- mk. Reg(0); rule L 2 C 16(i == 0); fifo. enq(1); i <= 1; endrule L 3 C 16(i == 1); fifo. enq(2); i <= 2; endrule L 4 C 16(i == 2); fifo. enq(3); fifo. deq(4); i <= 3; endrule L 8 C 16(i == 3); $display(“Done”); $finish; endrule October 7, 2013 Generated rules have “l<line_num>c<column_num>” in their name If an action in an Stmt. FSM has a guard that is false, the FSM will stall until the guard is true. There is an additional FSM in the provided tests to cause a failure if the FSM has been stalled for too long. http: //csg. csail. mit. edu/6. s 195 T 05 -17

Provided Testbenches Lets look at some of the actual testbenches October 7, 2013 http:

Provided Testbenches Lets look at some of the actual testbenches October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -18

Advice Never use “? ” n n You can pass a poorly written test

Advice Never use “? ” n n You can pass a poorly written test benches by just returning “? ”. These modules won’t pass any tests in hardware Instead you can use “unpack(0)” to initialize something with all 0’s if its exact value doesn’t matter Work together n October 7, 2013 It is often more efficient to write the same module together than to work separately http: //csg. csail. mit. edu/6. s 195 T 05 -19

Advice – Non-Blocking Cache Combine rules 1 and 8 into one cycle n Rule

Advice – Non-Blocking Cache Combine rules 1 and 8 into one cycle n Rule 8 produces a response and rule 1 produces a request, so they can happen in the same cycle. Make two functions for “send upgrade request if possible” n n One to check if it is possible One to send the request (and response if necessary) Use vectors of registers, not Reg. File Don’t copy the code from lecture n October 7, 2013 Instead follow the pseudo code here and in the handout http: //csg. csail. mit. edu/6. s 195 T 05 -20

Advice Start early Understand what you are doing Take a structured approach to debugging

Advice Start early Understand what you are doing Take a structured approach to debugging n Record what steps you have taken when debugging Ask questions October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -21

Questions? October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -22

Questions? October 7, 2013 http: //csg. csail. mit. edu/6. s 195 T 05 -22