forked from M-Labs/artiq
shuttler: remove sdm constants
This commit is contained in:
parent
4f3e58db52
commit
43926574da
|
@ -100,12 +100,15 @@ class SigmaDeltaModulator(Module):
|
||||||
self.x = Signal(x_width)
|
self.x = Signal(x_width)
|
||||||
self.y = Signal(y_width)
|
self.y = Signal(y_width)
|
||||||
|
|
||||||
# The SDM cannot represent any sample >0x7ffc with pulse modulation
|
# SDM can at most output the max DAC code `Replicate(1, y_width-1)`,
|
||||||
# Allowing pulse modulation on values >0x7ffc may overflow the
|
# which represents the sample of value
|
||||||
# accumulator, so the DAC code becomes 0x2000 -> -10.V.
|
# `Replicate(1, y_width-1) << (x_width-y_width)`.
|
||||||
|
#
|
||||||
|
# If the input sample exceeds such limit, SDM may overflow.
|
||||||
x_capped = Signal(x_width)
|
x_capped = Signal(x_width)
|
||||||
self.comb += If((self.x & 0xfffc) == 0x7ffc,
|
max_dac_code = Replicate(1, (y_width-1))
|
||||||
x_capped.eq(0x7ffc),
|
self.comb += If(self.x[x_width-y_width:] == max_dac_code,
|
||||||
|
x_capped.eq(Cat(Replicate(0, x_width-y_width), max_dac_code)),
|
||||||
).Else(
|
).Else(
|
||||||
x_capped.eq(self.x),
|
x_capped.eq(self.x),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue