forked from M-Labs/artiq
1
0
Fork 0

rtio/sed: make ON payload layout configurable, add latency function

This commit is contained in:
Sebastien Bourdeauducq 2017-09-11 09:06:40 +08:00
parent 527b403bb1
commit 1d2ebbe60f
2 changed files with 19 additions and 14 deletions

View File

@ -1,6 +1,9 @@
from migen import * from migen import *
__all__ = ["latency", "OutputNetwork"]
# Based on: https://github.com/Bekbolatov/SortingNetworks/blob/master/src/main/js/gr.js # Based on: https://github.com/Bekbolatov/SortingNetworks/blob/master/src/main/js/gr.js
def boms_get_partner(n, l, p): def boms_get_partner(n, l, p):
if p == 1: if p == 1:
@ -34,21 +37,17 @@ def boms_steps_pairs(lane_count):
return steps return steps
def layout_rtio_payload(fine_ts_width): def latency(lane_count):
return [ d = log2_int(lane_count)
("channel", 24), return sum(l for l in range(1, d+1))
("fine_ts", fine_ts_width),
("address", 16),
("data", 512),
]
def layout_node_data(seqn_width, fine_ts_width): def layout_node_data(seqn_width, layout_payload):
return [ return [
("valid", 1), ("valid", 1),
("seqn", seqn_width), ("seqn", seqn_width),
("replace_occured", 1), ("replace_occured", 1),
("payload", layout_rtio_payload(fine_ts_width)) ("payload", layout_payload)
] ]
@ -57,14 +56,14 @@ def cmp_wrap(a, b):
class OutputNetwork(Module): class OutputNetwork(Module):
def __init__(self, lane_count, seqn_width, fine_ts_width): def __init__(self, lane_count, seqn_width, layout_payload):
self.input = [Record(layout_node_data(seqn_width, fine_ts_width)) self.input = [Record(layout_node_data(seqn_width, layout_payload))
for _ in range(lane_count)] for _ in range(lane_count)]
self.output = None self.output = None
step_input = self.input step_input = self.input
for step in boms_steps_pairs(lane_count): for step in boms_steps_pairs(lane_count):
step_output = [Record(layout_node_data(seqn_width, fine_ts_width)) step_output = [Record(layout_node_data(seqn_width, layout_payload))
for _ in range(lane_count)] for _ in range(lane_count)]
for node1, node2 in step: for node1, node2 in step:

View File

@ -9,7 +9,13 @@ LANE_COUNT = 8
def simulate(input_events): def simulate(input_events):
dut = output_network.OutputNetwork(LANE_COUNT, LANE_COUNT*4, 3) layout_payload = [
("channel", 8),
("fine_ts", 3),
("address", 16),
("data", 512),
]
dut = output_network.OutputNetwork(LANE_COUNT, LANE_COUNT*4, layout_payload)
output = [] output = []
def gen(): def gen():
yield yield
@ -21,7 +27,7 @@ def simulate(input_events):
yield yield
for n in range(len(input_events)): for n in range(len(input_events)):
yield dut.input[n].valid.eq(0) yield dut.input[n].valid.eq(0)
for i in range(6): for i in range(output_network.latency(LANE_COUNT)):
yield yield
for x in range(LANE_COUNT): for x in range(LANE_COUNT):
if (yield dut.output[x].valid): if (yield dut.output[x].valid):