Final+Project+Explanation Updated Winter2025
Final+Project+Explanation Updated Winter2025
0 984DE132
0 116DE12F
0 100DE130
0 999DE12E
0 645DE10A
0 846DE107
0 211DE128
0 777DE133
(Note: Initially all the cache lines are initialized to invalid state. And since the first write is write
through it goes to Exclusive state)
Also during the first time processor reads data, it goes to exclusive state because no other processor is
having any shared data. During a Read miss the processor first checks the other processor’s L1 cache
first and if no other processor has the data then it fetches copy of data from main memory and writes it
to cache. If all the cache lines are filled at this point in the cache, then go for least recently used cache
line and evict it to accommodate the new data. If the evicted line is in modified state then it has to be
written back to the memory before eviction
LRU bits 000 001 010 011 100 101 110 111
MESI E E E E E E E E
Scenario 1 Explanation:
Binary Representation of 984DE132 is 1001 1000 0100 1101 1110 0001 0011 0010.
Binary Representation of 116DE12F is 0001 0001 0110 1101 1110 0001 0010 1111.
Binary Representation of 999DE12 is 1001 1001 1001 1101 1110 0001 0010 1111
Binary Representation of 645DE10A is 0110 0100 0101 1101 1110 0001 0000 1010
Binary Representation of 846DE107 is 1000 0100 0110 1101 1110 0001 0000 0111
Binary Representation of 777DE133 is 0111 0111 0111 1101 1110 0001 0011 0011
Note in this scenario, all the eight access has the same index address of 1101 1110 0001 00 (or 0x3784).
Assumes LRU bit: 000, MRU bit: 111
Scenario 2: Read and Write into a particular Set for data cache (index-3784)
0 999DE132
1 116DE123
1 666DE135
1 333DE12C
0 846DE10C
0 777DE136
1 ABCDE128
0 116DE101
1 100DE101
1 AAADE101
1 EDCDE101
4 AAADE101
Scenario 2 Explanation:
Step 1 0 999DE132 - Read Operation - Hit
Binary Representation of 999DE132 is 1001 1001 1001 1101 1110 0001 0011 0010
LRU bits 000 001 010 111 011 100 101 110
MESI E E E S E E E E
Binary Representation of 116DE12F is 0001 0001 0110 1101 1110 0001 0010 1111.
LRU bits 000 111 001 110 010 011 100 101
MESI E M E S E E E E
Step 3: 1 666DE135 - Write Operation – Miss. So replace using LRU. (No Write back)
Binary Representation of 666DE135 0110 0110 0110 1101 1110 0001 0011 0101.
LRU bits 111 110 000 101 001 010 011 100
MESI M M E S E E E E
Step 4: 1 333DE12C - Write Operation - Miss. So replace using LRU. (No Write back)
Binary Representation of 333DE12C is 0011 0011 0011 1101 1110 0001 0010 1100
LRU bits 110 101 111 100 000 001 010 011
MESI M M M S E E E E
Binary Representation of 846DE10C is 1000 0100 0110 1101 1110 0001 0000 1100
(Assume that during every read operation if the cache line is previously in Exclusive state, then consider
read is done by another processor. So in this scenario the MESI bits goes from Exclusive to Shared. This
is assumed so that all MESI states can be covered. If you are considering it as read from the same
processor then it will remain in the Exclusive state itself and will never go to the shared state. So consider
this read from other processors.)
Way-1 Way-2 Way-3 Way-4 Way-5 Way-6 Way-7 Way-8
Index 666 116 333 999 645 846 211 777
LRU bits 101 100 110 011 000 111 001 010
MESI M M M S E S E E
Binary Representation of 777DE136 is 0111 0111 0111 1101 1110 0001 0011 0110
Step 7: 1 ABCDE128 - Write Operation - Miss. So replace using LRU. (No Write back)
Binary Representation of ABCDE128 is 1010 1011 1100 1101 1110 0001 0010 1000
LRU bits 011 010 100 001 111 101 000 110
MESI M M M S M S E S
Binary Representation of 116DE101 is 0001 0001 0110 1101 1110 0001 0000 0001
LRU bits 010 111 011 001 110 100 000 101
MESI M M M S M S E S
Step 9: 1 100DE101 - Write Operation - Miss. So replace using LRU. (No Write back)
Binary Representation of 100DE101 is 0001 0000 0000 1101 1110 0001 0000 0001
LRU bits 001 110 010 000 101 011 111 100
MESI M M M S M S M S
Step 10: 1 AAADE101 - Write Operation - Miss. So replace using LRU. (No Write back)
Binary Representation of AAADE101 is 1010 1010 1010 1101 1110 0001 0000 0001
LRU bits 000 101 001 111 100 010 110 011
MESI M M M M M S M S
Step 11: 1 EDCDE101 - Write Operation - Miss. So replace using LRU. (Write back)
Binary Representation of EDCDE101 is 1110 1101 1100 1101 1110 0001 0000 0001
LRU bits 111 100 000 110 011 001 101 010
MESI M M M M M S M S
In this case, Way-1 was previously in M state and again a Write operation happens in this step. So the
previously modified content is written back to the memory before step 11 happens.
This is a two step process. AAA in previous case points to Modified state. The modified data pointed by
AAA is being requested by another processor(P2) for ownership. So AAA first writes back data to
Memory and shares the data to the requested processor thereby going to shared state. Once the
requested processor gets the shared data it modifies it(Read For Ownership first, then write) and goes
to Exclusive state(P2) and broadcasts the Invalidate signal to all other processors. So AAA of
processor(P1) goes to Invalid state finally .
Binary Representation of AAADE101 is 1010 1010 1010 1101 1110 0001 0000 0001
LRU bits 110 100 000 111 011 001 101 010
MESI M M M I M S M S
Note to students:
In this case when the cache line is Invalid keep the LRU as 111. The next time when a write miss
occurs check for the cache line with MESI bit as “Invalid”. If there is no Invalid cache line go for the cache
line with LRU bits 000 and evict and replace it (if needed write it back to memory).
If there is just one invalid cache line in that particular set during a read/write miss then new data is
written to the cache line with invalid MESI bit instead of evicting any other useful data in the cache. Now
update the LRU of this to 111.
If there are multiple cache lines with Invalid MESI bits during a read/write miss then again instead of
evicting useful data, you can write the new data to one of the invalid cache lines which has the least LRU
Value.
So in the above scenario the LRU bits of AAA will be 111. The next time a read/write miss occurs , instead
of evicting 333 in way3 , you will write the new data to Way-4 as it is in invalid state. LRU bits have to be
updated accordingly if needed. Give preference to cache line that is invalid before checking the LRU bits
during the read/write miss.
P.S -> The above two scenarios are explained for different operations only to a particular index (3784
in decimal or 1101 1110 0001 00 in HEX) in the D-cache.
Additional Notes:
1) If this processor (acting processor and the processor we are modeling/simulating) has a cache line
in M state, there is a read to the same cache line, we assume this read is from the acting processor
(my own processor), NOT from any other processor. So this project won’t have a case that another
processor is doing a read to the same cache line of the acting processor while the acting processor’s
cache line is in M state, and this acting processor’s cache in M state changes to S state since the
assumption is reads are from the acting processor (my own processor). In summary, there won’t be
a transition of M->S in this case.
2) If the acting processor is in E state, there is a read to the same cache line, here we assume this read
is from the other processor, and the acting processor will change cache line state from E to S. That
is the ONLY case in this project that we assume the read is from another processor.