artiq-zynq/sim_eop.py
morgan 910bad029c sim GW: prototyping frame decoding pipeine
sim: add double buffer
sim: add eop marker for crc checker in double buffer
sim: add KCode, pak type & CRC generator
sim: add Stream crossbar
sim: add stream pipeline with parser & buffer
sim: add frame generator & image viewer
sim: add arbiter
sim: add broadcaster, double buffer & eop tester

sim: add roi pipeline

sim: update roi
2025-01-09 15:56:10 +08:00

73 lines
2.2 KiB
Python

from migen import *
from misoc.interconnect.csr import *
from misoc.interconnect import stream
from sim_generator import CXPCRC32Inserter
from src.gateware.cxp_frame_pipeline import *
from src.gateware.cxp_pipeline import *
class EOP_Pipeline(Module):
def __init__(self):
dchar_decoder = Duplicated_Char_Decoder()
eop_inserter = EOP_Inserter()
buffer = stream.SyncFIFO(word_layout_dchar, 32)
pipeline = [dchar_decoder, eop_inserter, buffer]
self.submodules += pipeline
for s, d in zip(pipeline, pipeline[1:]):
self.comb += s.source.connect(d.sink)
self.sink = pipeline[0].sink
self.source = pipeline[-1].source
# for sim, no backpressure
self.comb += self.source.ack.eq(1)
dut = EOP_Pipeline()
def packet_sim(packets=[]):
print("=================TEST========================")
sink = dut.sink
cyc = len(packets)
pak = packets
for c in range(cyc):
yield sink.data.eq(pak[c]["data"])
yield sink.k.eq(pak[c]["k"])
yield sink.stb.eq(1)
yield
# extra clk cycles
for _ in range(cyc, cyc + 10):
yield sink.data.eq(0)
yield sink.k.eq(0)
yield sink.stb.eq(0)
yield sink.eop.eq(0)
yield
assert True
def testbench():
paks = [
{"data": Replicate(KCode["pak_start"], 4), "k": Replicate(1, 4)},
{"data": C(0x1111, word_dw), "k": Replicate(1, 4)},
{"data": C(0x2222, word_dw), "k": Replicate(0, 4)},
{"data": C(0x3333, word_dw), "k": Replicate(0, 4)},
{"data": C(0x4444, word_dw), "k": Replicate(0, 4)},
{"data": Replicate(KCode["pak_end"], 4), "k": Replicate(1, 4)},
{"data": Replicate(KCode["pak_start"], 4), "k": Replicate(1, 4)},
{"data": C(0xAAAA, word_dw), "k": Replicate(1, 4)},
{"data": C(0xBBBB, word_dw), "k": Replicate(0, 4)},
{"data": C(0xCCCC, word_dw), "k": Replicate(0, 4)},
{"data": C(0xDDDD, word_dw), "k": Replicate(0, 4)},
{"data": Replicate(KCode["pak_end"], 4), "k": Replicate(1, 4)},
]
yield from packet_sim(paks)
run_simulation(dut, testbench(), vcd_name="sim-cxp.vcd")