[libre-riscv-dev] TLB
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Mon Apr 22 03:33:21 BST 2019
encoder is a one-out, therefore can be used as an index into the write_array?
the for-loop generates N Case statements equal to i, therefore it's:
* if self.encoder.o == 1 write_port == self.write_port[1]
* if self.encoder.o == 2 write_port == self.write_port[2]
* if self.encoder.o == 3 write_port == self.write_port[3]
....
....
might as well just be:
write_port = self.write_array[self.encoder.o]
diff --git a/TLB/src/SetAssociativeCache.py b/TLB/src/SetAssociativeCache.py
index cdf8829..1bc1e97 100644
--- a/TLB/src/SetAssociativeCache.py
+++ b/TLB/src/SetAssociativeCache.py
@@ -169,15 +169,12 @@ class SetAssociativeCache():
]
with m.If(self.encoder.single_match):
- with m.Switch(self.encoder.o):
- for i in range(len(self.write_array)):
- with m.Case(i):
- write_port = self.write_array[i]
- m.d.comb += [
- write_port.en.eq(1),
- write_port.addr.eq(self.cset),
- write_port.data.eq(Cat(1, self.data_i, self.tag))
- ]
+ write_port = self.write_array[self.encoder.o]
+ m.d.comb += [
+ write_port.en.eq(1),
+ write_port.addr.eq(self.cset),
+ write_port.data.eq(Cat(1, self.data_i, self.tag))
+ ]
More information about the libre-riscv-dev
mailing list