From: Florent Kermarrec Date: Wed, 25 Mar 2015 22:59:29 +0000 (+0100) Subject: software/memtest: remove Mixxeo/M1 hardcoded values in bandwidth computation X-Git-Tag: 24jan2021_ls180~2436 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=257706517ee5c76e6ebc5ce647fead8c1937f833;p=litex.git software/memtest: remove Mixxeo/M1 hardcoded values in bandwidth computation --- diff --git a/misoclib/mem/sdram/core/lasmicon/multiplexer.py b/misoclib/mem/sdram/core/lasmicon/multiplexer.py index e5284713..7a9f3a3e 100644 --- a/misoclib/mem/sdram/core/lasmicon/multiplexer.py +++ b/misoclib/mem/sdram/core/lasmicon/multiplexer.py @@ -92,6 +92,7 @@ class Multiplexer(Module, AutoCSR): def __init__(self, phy_settings, geom_settings, timing_settings, controller_settings, bank_machines, refresher, dfi, lasmic, with_bandwidth=False): assert(phy_settings.nphases == len(dfi.phases)) + self.phy_settings = phy_settings # Command choosing requests = [bm.cmd for bm in bank_machines] @@ -218,4 +219,5 @@ class Multiplexer(Module, AutoCSR): def do_finalize(self): if self.with_bandwidth: - self.submodules.bandwidth = Bandwidth(self.choose_req.cmd) + data_width = self.phy_settings.dfi_databits*self.phy_settings.nphases + self.submodules.bandwidth = Bandwidth(self.choose_req.cmd, data_width) diff --git a/misoclib/mem/sdram/core/lasmicon/perf.py b/misoclib/mem/sdram/core/lasmicon/perf.py index 910d831a..41fd5325 100644 --- a/misoclib/mem/sdram/core/lasmicon/perf.py +++ b/misoclib/mem/sdram/core/lasmicon/perf.py @@ -2,10 +2,11 @@ from migen.fhdl.std import * from migen.bank.description import * class Bandwidth(Module, AutoCSR): - def __init__(self, cmd, period_bits=24): + def __init__(self, cmd, data_width, period_bits=24): self._update = CSR() self._nreads = CSRStatus(period_bits) self._nwrites = CSRStatus(period_bits) + self._data_width = CSRStatus(bits_for(data_width), reset=data_width) ### diff --git a/software/memtest/main.c b/software/memtest/main.c index a52ddbac..c8858024 100644 --- a/software/memtest/main.c +++ b/software/memtest/main.c @@ -10,20 +10,30 @@ #include #include +static unsigned int log2(unsigned int v) +{ + unsigned int r; + r = 0; + while(v>>=1) r++; + return r; +} + static void membw_service(void) { static int last_event; unsigned long long int nr, nw; unsigned long long int f; unsigned int rdb, wrb; + unsigned int dw; if(elapsed(&last_event, identifier_frequency_read())) { sdram_controller_bandwidth_update_write(1); nr = sdram_controller_bandwidth_nreads_read(); nw = sdram_controller_bandwidth_nwrites_read(); f = identifier_frequency_read(); - rdb = (nr*f >> (24 - 7))/1000000ULL; - wrb = (nw*f >> (24 - 7))/1000000ULL; + dw = sdram_controller_bandwidth_data_width_read(); + rdb = (nr*f >> (24 - log2(dw)))/1000000ULL; + wrb = (nw*f >> (24 - log2(dw)))/1000000ULL; printf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); } }