From 06f7192fb6892da863adb50b49ee55c62545b4c0 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 5 Aug 2020 11:41:48 +0200 Subject: [PATCH] frontend/adapter/LiteDRAMNativePortConverter: simplify using ratio. --- litedram/frontend/adapter.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/litedram/frontend/adapter.py b/litedram/frontend/adapter.py index bd3e9ca..81579a0 100644 --- a/litedram/frontend/adapter.py +++ b/litedram/frontend/adapter.py @@ -348,15 +348,16 @@ class LiteDRAMNativePortConverter(Module): # # # - mode = port_from.mode + ratio = port_from.data_width/port_to.data_width - if port_from.data_width > port_to.data_width: - converter = LiteDRAMNativePortDownConverter(port_from, port_to, reverse) - self.submodules += converter - elif port_from.data_width < port_to.data_width: - converter = LiteDRAMNativePortUpConverter(port_from, port_to, reverse) - self.submodules += converter + if ratio > 1: + # DownConverter + self.submodules.converter = LiteDRAMNativePortDownConverter(port_from, port_to, reverse) + elif ratio < 1: + # UpConverter + self.submodules.converter = LiteDRAMNativePortUpConverter(port_from, port_to, reverse) else: + # Identity self.comb += [ port_from.cmd.connect(port_to.cmd), port_from.wdata.connect(port_to.wdata),