cores/uart/RS232PHY: add with_dynamic_baudrate parameter and disable it by default.

Dynamic baudrate is rarely used and enabling it has a non negligeable cost (~100LCs).
This commit is contained in:
Florent Kermarrec 2021-02-16 20:00:43 +01:00
parent 9a8a8c0fe5
commit 285bb96278
1 changed files with 7 additions and 4 deletions

View File

@ -132,10 +132,13 @@ class RS232PHYTX(Module):
class RS232PHY(Module, AutoCSR): class RS232PHY(Module, AutoCSR):
def __init__(self, pads, clk_freq, baudrate=115200): def __init__(self, pads, clk_freq, baudrate=115200, with_dynamic_baudrate=False):
self._tuning_word = CSRStorage(32, reset=int((baudrate/clk_freq)*2**32)) tuning_word = int((baudrate/clk_freq)*2**32)
self.submodules.tx = RS232PHYTX(pads, self._tuning_word.storage) if with_dynamic_baudrate:
self.submodules.rx = RS232PHYRX(pads, self._tuning_word.storage) self._tuning_word = CSRStorage(32, reset=tuning_word)
tuning_word = self._tuning_word.storage
self.submodules.tx = RS232PHYTX(pads, tuning_word)
self.submodules.rx = RS232PHYRX(pads, tuning_word)
self.sink, self.source = self.tx.sink, self.rx.source self.sink, self.source = self.tx.sink, self.rx.source