litex/examples/de1/client/test_MiLa_0.py

83 lines
1.9 KiB
Python
Raw Normal View History

2013-02-26 17:14:09 -05:00
from miscope import trigger, recorder, miIo, miLa
from miscope.tools.truthtable import *
from miscope.tools.vcd import *
2012-09-16 05:48:32 -04:00
import sys
sys.path.append("../../../")
from spi2Csr.tools.uart2Spi import *
#==============================================================================
# P A R A M E T E R S
#==============================================================================
# Bus Width
trig_width = 16
dat_width = 16
# Record Size
record_size = 4096
# Csr Addr
2013-02-26 17:14:09 -05:00
MIIO_ADDR = 0x0000
MILA_ADDR = 0x0200
2012-09-16 05:48:32 -04:00
2013-02-26 17:14:09 -05:00
csr = Uart2Spi(1, 115200, debug=False)
2012-09-16 05:48:32 -04:00
2013-02-26 17:14:09 -05:00
# MiScope Configuration
# miIo0
miIo0 = miIo.MigIo(MIIO_ADDR, 8, "IO",csr)
2012-09-16 05:48:32 -04:00
2013-02-26 17:14:09 -05:00
# miLa0
2012-09-16 05:48:32 -04:00
term0 = trigger.Term(trig_width)
2012-09-17 11:00:47 -04:00
trigger0 = trigger.Trigger(trig_width, [term0])
recorder0 = recorder.Recorder(dat_width, record_size)
2012-09-16 05:48:32 -04:00
2013-02-26 17:14:09 -05:00
miLa0 = miLa.MiLa(MILA_ADDR, trigger0, recorder0, csr)
2012-09-16 05:48:32 -04:00
#==============================================================================
# T E S T M I G L A
#==============================================================================
dat_vcd = []
recorder0.size(1024)
2012-09-17 12:37:23 -04:00
def capture(size):
2012-09-16 05:48:32 -04:00
global trigger0
global recorder0
global dat_vcd
sum_tt = gen_truth_table("term0")
2013-02-26 17:14:09 -05:00
miLa0.trig.sum.write(sum_tt)
miLa0.rec.reset()
miLa0.rec.offset(0)
miLa0.rec.arm()
2012-09-16 05:48:32 -04:00
print("-Recorder [Armed]")
print("-Waiting Trigger...", end = ' ')
2013-02-26 17:14:09 -05:00
while(not miLa0.rec.is_done()):
2012-09-16 05:48:32 -04:00
time.sleep(0.1)
print("[Done]")
print("-Receiving Data...", end = ' ')
sys.stdout.flush()
2013-02-26 17:14:09 -05:00
dat_vcd += miLa0.rec.read(size)
2012-09-16 05:48:32 -04:00
print("[Done]")
print("Capturing Ramp..")
print("----------------------")
2012-09-17 12:37:23 -04:00
term0.write(0x0000,0xFFFF)
2012-09-16 05:48:32 -04:00
csr.write(0x0000, 0)
2012-09-17 12:37:23 -04:00
capture(1024)
2012-09-16 05:48:32 -04:00
print("Capturing Square..")
print("----------------------")
2012-09-17 12:37:23 -04:00
term0.write(0x0000,0xFFFF)
2012-09-16 05:48:32 -04:00
csr.write(0x0000, 1)
2012-09-17 12:37:23 -04:00
capture(1024)
2012-09-16 05:48:32 -04:00
print("Capturing Sinus..")
print("----------------------")
2012-09-17 12:37:23 -04:00
term0.write(0x0080,0xFFFF)
2012-09-16 05:48:32 -04:00
csr.write(0x0000, 2)
2012-09-17 12:37:23 -04:00
capture(1024)
2012-09-16 05:48:32 -04:00
myvcd = Vcd()
myvcd.add(Var("wire", 16, "trig_dat", dat_vcd))
2013-02-26 17:14:09 -05:00
myvcd.write("test_MiLa_0.vcd")