software/memtest: remove Mixxeo/M1 hardcoded values in bandwidth computation
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 25 Mar 2015 22:59:29 +0000 (23:59 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 25 Mar 2015 23:01:42 +0000 (00:01 +0100)
misoclib/mem/sdram/core/lasmicon/multiplexer.py
misoclib/mem/sdram/core/lasmicon/perf.py
software/memtest/main.c

index e5284713b128d09e70acfaa3b91e46b4edb853f6..7a9f3a3e52e327b717c0f043d112e94cfa97c163 100644 (file)
@@ -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)
index 910d831ab97ce460f164c79ab9f05f38af301b4c..41fd5325a98b030b9e8aea7260b013f351a1e162 100644 (file)
@@ -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)
 
                ###
 
index a52ddbac2e800c24b0a1e46fa729d9c805266870..c88580243967bb227b0de9d6b4d778ee12d3d026 100644 (file)
 #include <console.h>
 #include <system.h>
 
+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);
        }
 }