mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
Add sigma-delta DAC LiteX core.
Signed-off-by: Tim Callahan <tcal@google.com>
This commit is contained in:
parent
ece286b15d
commit
8066e5d8a2
1 changed files with 24 additions and 0 deletions
24
litex/soc/cores/dac.py
Normal file
24
litex/soc/cores/dac.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# This file is part of LiteX.
|
||||
#
|
||||
# Copyright (c) 2022 Tim Callahan <tcal@google.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
from migen import *
|
||||
|
||||
from litex.soc.interconnect.csr import *
|
||||
|
||||
# DAC ---------------------------------------------------------------------------------------
|
||||
|
||||
class DAC(Module, AutoCSR):
|
||||
|
||||
def __init__(self, out, data_width):
|
||||
self.out = out
|
||||
|
||||
self._value = CSRStorage(data_width, reset_less=True, description="Digital value to convert to analog.")
|
||||
value = Signal(data_width)
|
||||
accum = Signal(data_width+1)
|
||||
|
||||
self.comb += value.eq(self._value.storage)
|
||||
self.sync += accum.eq(accum[0:data_width] + value)
|
||||
self.comb += out.eq(accum[data_width])
|
Loading…
Reference in a new issue