2012-09-16 05:48:32 -04:00
|
|
|
from migen.fhdl.structure import *
|
|
|
|
from migen.fhdl import verilog, autofragment
|
|
|
|
from migen.bus import csr
|
|
|
|
from migen.bus.transactions import *
|
|
|
|
from migen.bank import description, csrgen
|
|
|
|
from migen.bank.description import *
|
|
|
|
|
|
|
|
import sys
|
|
|
|
sys.path.append("../../../")
|
|
|
|
|
2012-09-17 11:00:47 -04:00
|
|
|
from migScope import trigger, recorder, migIo, migLa
|
2012-09-16 05:48:32 -04:00
|
|
|
from migScope.tools.truthtable import *
|
|
|
|
from migScope.tools.vcd import *
|
|
|
|
import spi2Csr
|
|
|
|
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
|
2012-09-17 11:00:47 -04:00
|
|
|
MIGIO_ADDR = 0x0000
|
|
|
|
MIGLA_ADDR = 0x0200
|
2012-09-16 05:48:32 -04:00
|
|
|
|
2012-09-17 11:00:47 -04:00
|
|
|
csr = Uart2Spi(1,115200,debug=False)
|
2012-09-16 05:48:32 -04:00
|
|
|
|
|
|
|
# MigScope Configuration
|
|
|
|
# migIo
|
2012-09-17 11:00:47 -04:00
|
|
|
migIo0 = migIo.MigIo(MIGIO_ADDR, 8, "IO",csr)
|
2012-09-16 05:48:32 -04:00
|
|
|
|
|
|
|
# Trigger
|
|
|
|
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
|
|
|
|
2012-09-17 11:00:47 -04:00
|
|
|
migLa0 = migLa.MigLa(MIGLA_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")
|
2012-09-17 11:00:47 -04:00
|
|
|
migLa0.trig.sum.write(sum_tt)
|
|
|
|
migLa0.rec.reset()
|
|
|
|
migLa0.rec.offset(0)
|
|
|
|
migLa0.rec.arm()
|
2012-09-16 05:48:32 -04:00
|
|
|
print("-Recorder [Armed]")
|
|
|
|
print("-Waiting Trigger...", end = ' ')
|
2012-09-17 11:00:47 -04:00
|
|
|
while(not migLa0.rec.is_done()):
|
2012-09-16 05:48:32 -04:00
|
|
|
time.sleep(0.1)
|
|
|
|
print("[Done]")
|
|
|
|
|
|
|
|
print("-Receiving Data...", end = ' ')
|
|
|
|
sys.stdout.flush()
|
2012-09-17 12:37:23 -04:00
|
|
|
dat_vcd += migLa0.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))
|
|
|
|
myvcd.write("test_MigLa.vcd")
|