from AddressEncoder import AddressEncoder
+SA_NA = "00" # no action (none)
+SA_RD = "01" # read
+SA_WR = "10" # write
+
+
class SetAssociativeCache():
""" Set Associative Cache Memory
# Input
self.enable = Signal(1)
- self.command = Signal(2) # 00=None, 01=Read, 10=Write
+ self.command = Signal(2) # 00=None, 01=Read, 10=Write (see SA_XX)
self.set = Signal(max=set_count)
self.tag = Signal(tag_size)
self.data_i = Signal(data_size + tag_size)
with m.If(self.enable):
with m.Switch(self.command):
# Search all sets at a particular tag
- with m.Case("01"):
+ with m.Case(SA_RD):
# Vector to store valid results
valid_vector = []
# Loop through memory setting what set to read
]
# TODO
# Write to a given tag
- # with m.Case("10"):
+ # with m.Case(SA_WR):
# Search for available space
# What to do when there is no space
# Maybe catch multiple tags write here?
# TODO
- return m
\ No newline at end of file
+ return m