In [1]:
import magma as m
m.set_mantle_target('ice40')
In [2]:
import mantle
from loam.boards.icestick import IceStick
N = 8
DELTA = 0x8000
icestick = IceStick()
icestick.Clock.on()
icestick.J3[0].output().on()
main = icestick.main()
add = mantle.Add(16, cout=True)
reg = mantle.Register(16)
O, cout = add(reg, m.uint(DELTA,16))
m.wire( O, reg.I )
m.wire( cout, main.J3 )
m.EndDefine()
In [3]:
m.compile('build/deltasigma', main)
In [4]:
%%bash
cd build
cat pwm.pcf
yosys -q -p 'synth_ice40 -top main -blif deltasigma.blif' deltasigma.v
arachne-pnr -q -d 1k -o deltasigma.txt -p deltasigma.pcf deltasigma.blif
icepack deltasigma.txt deltasigma.bin
iceprog deltasigma.bin
We can wire up the GPIO pins to a logic analyzer to verify that our circuit produces the correct waveform.
In [ ]: