self.comb += load_store_address_low_2.eq(
decoder_immediate[:2] + register_rs1[:2])
+ load_store_misaligned = Signal()
+
+ lsa = self.get_ls_misaligned(load_store_misaligned, decoder_funct3,
+ load_store_address_low_2)
+ self.comb += lsa
+
+ def get_ls_misaligned(self, ls, funct3, load_store_address_low_2):
+ return Case(funct3[:2],
+ { F3.sb: ls.eq(Constant(0)),
+ F3.sh: ls.eq(load_store_address_low_2[0] != 0),
+ F3.sw: ls.eq(load_store_address_low_2[0:2] != Constant(0, 2)),
+ "default": ls.eq(Constant(1))
+ })
+
if __name__ == "__main__":
example = CPU()