icache.py move icache_miss CLR_TAG FSM state into method icache_miss_clr_tag() to...
authorCole Poirier <colepoirier@gmail.com>
Mon, 5 Oct 2020 00:01:34 +0000 (17:01 -0700)
committerCole Poirier <colepoirier@gmail.com>
Mon, 5 Oct 2020 01:04:02 +0000 (18:04 -0700)
src/soc/experiment/icache.py

index e2d18868d154d7aadc4445789ad0cd6105af123e..05cf9385f335cd2f1350b238fce247149fc981b8 100644 (file)
@@ -873,6 +873,30 @@ class ICache(Elaboratable):
             # Track that we had one request sent
             sync += r.state.eq(State.CLR_TAG)
 
+    def icache_miss_clr_tag(self, m, r, replace_way,
+                            cache_valid_bits, req_index,
+                            tagset, cache_tags):
+
+        comb = m.d.comb
+        sync = m.d.sync
+
+        # Get victim way from plru
+        sync += r.store_way.eq(replace_way)
+        # Force misses on that way while reloading that line
+        cv = Signal(INDEX_BITS)
+        comb += cv.eq(cache_valid_bits[req_index])
+        comb += cv.bit_select(replace_way, 1).eq(0)
+        sync += cache_valid_bits[req_index].eq(cv)
+
+        for i in range(NUM_WAYS):
+            with m.If(i == replace_way):
+                comb += tagset.eq(cache_tags[r.store_index])
+                comb += write_tag(i, tagset, r.store_tag)
+                sync += cache_tags[r.store_index].eq(tagset)
+
+        sync += r.state.eq(State.WAIT_ACK)
+
+
     # Cache miss/reload synchronous machine
     def icache_miss(self, m, cache_valid_bits, r, req_is_miss,
                     req_index, req_laddr, req_tag, replace_way,
@@ -903,27 +927,19 @@ class ICache(Elaboratable):
         with m.Switch(r.state):
 
             with m.Case(State.IDLE):
-                self.icache_miss_idle(m, r, req_is_miss, req_laddr,
-                                      req_index, req_tag, replace_way,
-                                      real_addr)
+                self.icache_miss_idle(
+                    m, r, req_is_miss, req_laddr,
+                    req_index, req_tag, replace_way,
+                    real_addr
+                )
 
             with m.Case(State.CLR_TAG, State.WAIT_ACK):
                 with m.If(r.state == State.CLR_TAG):
-                    # Get victim way from plru
-                    sync += r.store_way.eq(replace_way)
-                    # Force misses on that way while reloading that line
-                    cv = Signal(INDEX_BITS)
-                    comb += cv.eq(cache_valid_bits[req_index])
-                    comb += cv.bit_select(replace_way, 1).eq(0)
-                    sync += cache_valid_bits[req_index].eq(cv)
-
-                    for i in range(NUM_WAYS):
-                        with m.If(i == replace_way):
-                            comb += tagset.eq(cache_tags[r.store_index])
-                            comb += write_tag(i, tagset, r.store_tag)
-                            sync += cache_tags[r.store_index].eq(tagset)
-
-                    sync += r.state.eq(State.WAIT_ACK)
+                    self.icache_miss_clr_tag(
+                        m, r, replace_way,
+                        cache_valid_bits, req_index,
+                        tagset, cache_tags
+                    )
 
                 # Requests are all sent if stb is 0
                 stbs_zero = Signal()