From 43cd15994910a0803fb77d2a830e4a12b2f61608 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 5 Mar 2019 11:28:07 +0000 Subject: [PATCH] moved code (hardware) which doesnt depend on the index out of the loop --- TLB/src/Cam.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/TLB/src/Cam.py b/TLB/src/Cam.py index ac0ec273..8edda056 100644 --- a/TLB/src/Cam.py +++ b/TLB/src/Cam.py @@ -67,8 +67,8 @@ class Cam(): ] # Set the key value for every CamEntry - for index in range(self.cam_size): - with m.If(self.enable): + with m.If(self.enable): + for index in range(self.cam_size): # Read Operation with m.If(~self.write_enable): @@ -86,27 +86,28 @@ class Cam(): # Send all entry matches to the priority encoder m.d.comb += self.encoder.i[index].eq(entry_array[index].match) - # Process out data based on encoder address - with m.If(self.encoder.n): - m.d.comb += [ - self.read_warning.eq(0), - self.single_match.eq(0), - self.multiple_match.eq(0), - self.match_address.eq(0) - ] - with m.Else(): - m.d.comb += [ - self.single_match.eq(1), - self.match_address.eq(self.encoder.o) - ] - + # Process out data based on encoder address + with m.If(self.encoder.n): + m.d.comb += [ + self.read_warning.eq(0), + self.single_match.eq(0), + self.multiple_match.eq(0), + self.match_address.eq(0) + ] with m.Else(): m.d.comb += [ - self.read_warning.eq(0), - self.single_match.eq(0), - self.multiple_match.eq(0), - self.match_address.eq(0) + self.single_match.eq(1), + self.match_address.eq(self.encoder.o) ] + + with m.Else(): + m.d.comb += [ + self.read_warning.eq(0), + self.single_match.eq(0), + self.multiple_match.eq(0), + self.match_address.eq(0) + ] + return m if __name__ == '__main__': -- 2.30.2