From d193bd33214f79876a173ed155362654635d96c6 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 15 Dec 2014 19:04:07 +0100 Subject: [PATCH] hdd: improve debug print --- lib/sata/test/hdd.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/sata/test/hdd.py b/lib/sata/test/hdd.py index e459e7e2..c327632d 100644 --- a/lib/sata/test/hdd.py +++ b/lib/sata/test/hdd.py @@ -471,14 +471,22 @@ class HDD(Module): def write(self, sector, data): n = math.ceil(self.dwords2sectors(len(data))) if self.debug: - print_hdd("Writing sector {s} to {e}".format(s=sector, e=sector+n-1)) + if n == 1: + s = "{}".format(sector) + else: + s = "{s} to {e}".format(s=sector, e=sector+n-1) + print_hdd("Writing sector " + s) for i in range(len(data)): offset = self.sectors2dwords(sector) self.mem.data[offset+i] = data[i] def read(self, sector, count): if self.debug: - print_hdd("Reading sector {s} to {e}".format(s=sector, e=sector+count-1)) + if count == 1: + s = "{}".format(sector) + else: + s = "{s} to {e}".format(s=sector, e=sector+count-1) + print_hdd("Reading sector " + s) data = [] for i in range(self.sectors2dwords(count)): data.append(self.mem.data[self.sectors2dwords(sector)+i]) -- 2.30.2