add test_MigLa_1 example : csr access analyzing

This commit is contained in:
Florent Kermarrec 2012-09-17 20:15:35 +02:00
parent 0be7704a85
commit b5980a90cc
9 changed files with 240 additions and 6192 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,10 @@ MIGLA_ADDR = 0x0200
csr = Uart2Spi(1,115200,debug=False)
# MigScope Configuration
# migIo
# migIo0
migIo0 = migIo.MigIo(MIGIO_ADDR, 8, "IO",csr)
# Trigger
# migIla0
term0 = trigger.Term(trig_width)
trigger0 = trigger.Trigger(trig_width, [term0])
recorder0 = recorder.Recorder(dat_width, record_size)
@ -87,4 +87,4 @@ capture(1024)
myvcd = Vcd()
myvcd.add(Var("wire", 16, "trig_dat", dat_vcd))
myvcd.write("test_MigLa.vcd")
myvcd.write("test_MigLa_0.vcd")

View file

@ -0,0 +1,73 @@
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("../../../")
from migScope import trigger, recorder, migIo, migLa
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 = 32
dat_width = 32
# Record Size
record_size = 4096
# Csr Addr
MIGIO0_ADDR = 0x0000
MIGLA1_ADDR = 0x0600
csr = Uart2Spi(1,115200,debug=False)
# MigScope Configuration
# migIo0
migIo0 = migIo.MigIo(MIGIO0_ADDR, 8, "IO",csr)
# migIla1
term1 = trigger.Term(trig_width)
trigger1 = trigger.Trigger(trig_width, [term1])
recorder1 = recorder.Recorder(dat_width, record_size)
migLa1 = migLa.MigLa(MIGLA1_ADDR, trigger1, recorder1, csr)
#==============================================================================
# T E S T M I G L A
#==============================================================================
dat_vcd = []
recorder1.size(1024)
term1.write(0x0100005A,0x0100005A)
sum_tt = gen_truth_table("term1")
migLa1.trig.sum.write(sum_tt)
migLa1.rec.reset()
migLa1.rec.offset(256)
migLa1.rec.arm()
print("-Recorder [Armed]")
print("-Waiting Trigger...", end = ' ')
csr.write(0x0000,0x5A)
while(not migLa1.rec.is_done()):
time.sleep(0.1)
print("[Done]")
print("-Receiving Data...", end = ' ')
sys.stdout.flush()
dat_vcd += migLa1.rec.read(1024)
print("[Done]")
myvcd = Vcd()
myvcd.add(Var("wire", 8, "csr_dat_w", get_bits(dat_vcd, 32, 0, 8)))
myvcd.add(Var("wire", 16, "csr_adr", get_bits(dat_vcd, 32, 8, 24)))
myvcd.add(Var("wire", 1, "csr_we", get_bits(dat_vcd, 32, 24)))
myvcd.write("test_MigLa_1.vcd")

View file

@ -60,30 +60,41 @@ clk_period_ns = clk_freq*ns
n = t2n(clk_period_ns)
# Bus Width
trig_width = 16
dat_width = 16
trig0_width = 16
dat0_width = 16
trig1_width = 32
dat1_width = 32
# Record Size
record_size = 4096
# Csr Addr
MIGIO_ADDR = 0x0000
MIGLA_ADDR = 0x0200
MIGIO0_ADDR = 0x0000
MIGLA0_ADDR = 0x0200
MIGLA1_ADDR = 0x0600
#==============================================================================
# M I S C O P E E X A M P L E
#==============================================================================
def get():
# migIo
migIo0 = migIo.MigIo(MIGIO_ADDR, 8, "IO")
# migIo0
migIo0 = migIo.MigIo(MIGIO0_ADDR, 8, "IO")
# migLa
term0 = trigger.Term(trig_width)
trigger0 = trigger.Trigger(trig_width, [term0])
recorder0 = recorder.Recorder(dat_width, record_size)
# migLa0
term0 = trigger.Term(trig0_width)
trigger0 = trigger.Trigger(trig0_width, [term0])
recorder0 = recorder.Recorder(dat0_width, record_size)
migLa0 = migLa.MigLa(MIGLA_ADDR, trigger0, recorder0)
migLa0 = migLa.MigLa(MIGLA0_ADDR, trigger0, recorder0)
# migLa1
term1 = trigger.Term(trig1_width)
trigger1 = trigger.Trigger(trig1_width, [term1])
recorder1 = recorder.Recorder(dat1_width, record_size)
migLa1 = migLa.MigLa(MIGLA1_ADDR, trigger1, recorder1)
# Spi2Csr
spi2csr0 = spi2Csr.Spi2Csr(16,8)
@ -93,7 +104,10 @@ def get():
[
migIo0.bank.interface,
migLa0.trig.bank.interface,
migLa0.rec.bank.interface
migLa0.rec.bank.interface,
migLa1.trig.bank.interface,
migLa1.rec.bank.interface,
])
comb = []
sync = []
@ -150,6 +164,17 @@ def get():
migLa0.in_dat.eq(sig_gen)
]
# MigLa1 input
comb += [
migLa1.in_trig[:8].eq(spi2csr0.csr.dat_w),
migLa1.in_trig[8:24].eq(spi2csr0.csr.adr),
migLa1.in_trig[24].eq(spi2csr0.csr.we),
migLa1.in_dat[:8].eq(spi2csr0.csr.dat_w),
migLa1.in_dat[8:24].eq(spi2csr0.csr.adr),
migLa1.in_dat[24].eq(spi2csr0.csr.we)
]
# HouseKeeping
cd_in = ClockDomain("in")
in_rst_n = Signal()

View file

@ -1,5 +1,5 @@
$date
2012-09-17 17:00
2012-09-17 20:01
$end
$version
miscope VCD dump

View file

@ -31,10 +31,10 @@ MIGLA_ADDR = 0x0200
csr = Uart2Spi(1,115200,debug=False)
# MigScope Configuration
# migIo
# migIo0
migIo0 = migIo.MigIo(MIGIO_ADDR, 8, "IO",csr)
# Trigger
# migIla0
term0 = trigger.Term(trig_width)
trigger0 = trigger.Trigger(trig_width, [term0])
recorder0 = recorder.Recorder(dat_width, record_size)
@ -87,4 +87,4 @@ capture(1024)
myvcd = Vcd()
myvcd.add(Var("wire", 16, "trig_dat", dat_vcd))
myvcd.write("test_MigLa.vcd")
myvcd.write("test_MigLa_0.vcd")

View file

@ -0,0 +1,73 @@
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("../../../")
from migScope import trigger, recorder, migIo, migLa
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 = 32
dat_width = 32
# Record Size
record_size = 4096
# Csr Addr
MIGIO0_ADDR = 0x0000
MIGLA1_ADDR = 0x0600
csr = Uart2Spi(1,115200,debug=False)
# MigScope Configuration
# migIo0
migIo0 = migIo.MigIo(MIGIO0_ADDR, 8, "IO",csr)
# migIla1
term1 = trigger.Term(trig_width)
trigger1 = trigger.Trigger(trig_width, [term1])
recorder1 = recorder.Recorder(dat_width, record_size)
migLa1 = migLa.MigLa(MIGLA1_ADDR, trigger1, recorder1, csr)
#==============================================================================
# T E S T M I G L A
#==============================================================================
dat_vcd = []
recorder1.size(1024)
term1.write(0x0100005A,0x0100005A)
sum_tt = gen_truth_table("term1")
migLa1.trig.sum.write(sum_tt)
migLa1.rec.reset()
migLa1.rec.offset(256)
migLa1.rec.arm()
print("-Recorder [Armed]")
print("-Waiting Trigger...", end = ' ')
csr.write(0x0000,0x5A)
while(not migLa1.rec.is_done()):
time.sleep(0.1)
print("[Done]")
print("-Receiving Data...", end = ' ')
sys.stdout.flush()
dat_vcd += migLa1.rec.read(1024)
print("[Done]")
myvcd = Vcd()
myvcd.add(Var("wire", 8, "csr_dat_w", get_bits(dat_vcd, 32, 0, 8)))
myvcd.add(Var("wire", 16, "csr_adr", get_bits(dat_vcd, 32, 8, 24)))
myvcd.add(Var("wire", 1, "csr_we", get_bits(dat_vcd, 32, 24)))
myvcd.write("test_MigLa_1.vcd")

View file

@ -60,30 +60,41 @@ clk_period_ns = clk_freq*ns
n = t2n(clk_period_ns)
# Bus Width
trig_width = 16
dat_width = 16
trig0_width = 16
dat0_width = 16
trig1_width = 32
dat1_width = 32
# Record Size
record_size = 4096
# Csr Addr
MIGIO_ADDR = 0x0000
MIGLA_ADDR = 0x0200
MIGIO0_ADDR = 0x0000
MIGLA0_ADDR = 0x0200
MIGLA1_ADDR = 0x0600
#==============================================================================
# M I S C O P E E X A M P L E
#==============================================================================
def get():
# migIo
migIo0 = migIo.MigIo(MIGIO_ADDR, 8, "IO")
# migIo0
migIo0 = migIo.MigIo(MIGIO0_ADDR, 8, "IO")
# migLa
term0 = trigger.Term(trig_width)
trigger0 = trigger.Trigger(trig_width, [term0])
recorder0 = recorder.Recorder(dat_width, record_size)
# migLa0
term0 = trigger.Term(trig0_width)
trigger0 = trigger.Trigger(trig0_width, [term0])
recorder0 = recorder.Recorder(dat0_width, record_size)
migLa0 = migLa.MigLa(MIGLA_ADDR, trigger0, recorder0)
migLa0 = migLa.MigLa(MIGLA0_ADDR, trigger0, recorder0)
# migLa1
term1 = trigger.Term(trig1_width)
trigger1 = trigger.Trigger(trig1_width, [term1])
recorder1 = recorder.Recorder(dat1_width, record_size)
migLa1 = migLa.MigLa(MIGLA1_ADDR, trigger1, recorder1)
# Spi2Csr
spi2csr0 = spi2Csr.Spi2Csr(16,8)
@ -93,7 +104,10 @@ def get():
[
migIo0.bank.interface,
migLa0.trig.bank.interface,
migLa0.rec.bank.interface
migLa0.rec.bank.interface,
migLa1.trig.bank.interface,
migLa1.rec.bank.interface,
])
comb = []
sync = []
@ -153,6 +167,17 @@ def get():
migLa0.in_dat.eq(sig_gen)
]
# MigLa1 input
comb += [
migLa1.in_trig[:8].eq(spi2csr0.csr.dat_w),
migLa1.in_trig[8:24].eq(spi2csr0.csr.adr),
migLa1.in_trig[24].eq(spi2csr0.csr.we),
migLa1.in_dat[:8].eq(spi2csr0.csr.dat_w),
migLa1.in_dat[8:24].eq(spi2csr0.csr.adr),
migLa1.in_dat[24].eq(spi2csr0.csr.we)
]
# HouseKeeping
cd_in = ClockDomain("in")
in_rst_n = Signal()

View file

@ -4,6 +4,19 @@ import datetime
sys.path.append("../../")
from migScope.tools.conv import *
def get_bits(values, width, low, high =None):
r = []
for val in values:
t = dec2bin(val,width)[::-1]
if high == None:
t = t[low]
else:
t = t[low:high]
t = t[::1]
t = int(t,2)
r.append(t)
return r
class Var:
def __init__(self,type , width , name, values=[], default="x"):
self.type = type