7from pycde
import AppID, Clock, Module, Reset, System, esi, generator
23 req_type = esi.HostMem.write_req_channel_type(Bits(width))
24 wire_type = esi.HostMem.write_req_channel_type(Bits((width + 7) // 8 * 8))
25 req = esi.ChannelService.from_host(AppID(
"req"), wire_type)
26 req = req.transform(
lambda r: req_type({
29 "data": r.data[:width],
31 ack = esi.HostMem.write(AppID(
"host"), req)
32 gate = esi.ChannelService.from_host(AppID(
"gate"), UInt(8))
33 gate_data, gate_valid = gate.unwrap(Bits(1)(1))
34 enabled = gate_data.as_bits()[0].reg(ports.clk,
39 tag, valid = ack.unwrap(ready)
40 out, out_ready = ack.type.wrap(tag, valid & enabled)
41 ready.assign(out_ready & enabled)
42 esi.ChannelService.to_host(AppID(
"ack"), out)
55 for width
in [13, bus_width, bus_width + 24, bus_width * 2 + 24, 16384]:
56 Writer(width)(clk=ports.clk, rst=ports.rst, appid=AppID(
"wr", width))
58 window = esi.HostMem.write_window(Bits(24), 1)
59 req_type = StructType([(
"address", UInt(64)), (
"data", Bits(24)),
61 req = esi.ChannelService.from_host(AppID(
"list_req"), req_type)
62 req = req.transform(
lambda r: window.wrap(
68 "last": r.last.as_bits()[0],
70 ack = esi.HostMem.write(AppID(
"list_host"), req)
71 esi.ChannelService.to_host(AppID(
"list_ack"), ack)
75 gearbox = TaggedWriteGearbox(16384, bus_width, max(256, bus_width // 8))
76 req = esi.ChannelService.from_host(AppID(
"probe_req"),
77 gearbox.in_.type.inner_type)
78 probe = gearbox(clk=ports.clk, rst=ports.rst, in_=req)
79 resp_type = StructType([(
"address", UInt(64)), (
"tag", UInt(8)),
80 (
"data", Bits(bus_width)),
81 (
"valid_bytes", UInt(64)), (
"last", UInt(8))])
82 resp = probe.out.transform(
lambda r: resp_type({
86 "valid_bytes": r.valid_bytes.as_uint(64),
87 "last": r.last.as_uint(8),
89 esi.ChannelService.to_host(AppID(
"probe_resp"), resp)