etherbone: wishbone reads seems OK in simulation
This commit is contained in:
parent
4a4e82b5f6
commit
fca89e8b74
|
@ -124,8 +124,11 @@ class LiteEthEtherboneRecordSender(Module):
|
||||||
source.sop.eq(0),
|
source.sop.eq(0),
|
||||||
source.eop.eq(wr_buffer.source.eop),
|
source.eop.eq(wr_buffer.source.eop),
|
||||||
source.data.eq(wr_buffer.source.data),
|
source.data.eq(wr_buffer.source.data),
|
||||||
If(source.stb & source.eop & source.ack,
|
If(source.stb & source.ack,
|
||||||
NextState("IDLE")
|
wr_buffer.source.ack.eq(1),
|
||||||
|
If(source.eop,
|
||||||
|
NextState("IDLE")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -143,10 +146,26 @@ class LiteEthEtherboneRecord(Module):
|
||||||
receiver.sink.data.eq(reverse_bytes(depacketizer.source.data)) # clarify this
|
receiver.sink.data.eq(reverse_bytes(depacketizer.source.data)) # clarify this
|
||||||
]
|
]
|
||||||
|
|
||||||
|
last_ip_address = Signal(32) # XXX for test
|
||||||
|
last_src_port = Signal(16) # XXX for test
|
||||||
|
last_dst_port = Signal(16) # XXX for test
|
||||||
|
|
||||||
|
self.sync += [
|
||||||
|
If(sink.stb & sink.sop & sink.ack,
|
||||||
|
last_ip_address.eq(sink.ip_address),
|
||||||
|
last_src_port.eq(sink.src_port),
|
||||||
|
last_dst_port.eq(sink.dst_port)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
self.submodules.sender = sender = LiteEthEtherboneRecordSender()
|
self.submodules.sender = sender = LiteEthEtherboneRecordSender()
|
||||||
self.submodules.packetizer = packetizer = LiteEthEtherboneRecordPacketizer()
|
self.submodules.packetizer = packetizer = LiteEthEtherboneRecordPacketizer()
|
||||||
self.comb += [
|
self.comb += [
|
||||||
Record.connect(sender.source, packetizer.sink),
|
Record.connect(sender.source, packetizer.sink),
|
||||||
packetizer.sink.data.eq(reverse_bytes(sender.source.data)), # clarify this
|
packetizer.sink.data.eq(reverse_bytes(sender.source.data)), # clarify this
|
||||||
Record.connect(packetizer.source, source),
|
Record.connect(packetizer.source, source),
|
||||||
|
source.length.eq(sender.source.wcount*4 + 4),
|
||||||
|
source.ip_address.eq(last_ip_address),
|
||||||
|
source.src_port.eq(last_src_port),
|
||||||
|
source.dst_port.eq(last_dst_port)
|
||||||
]
|
]
|
||||||
|
|
|
@ -58,7 +58,8 @@ class LiteEthEtherboneWishboneMaster(Module):
|
||||||
wr_source.addr.eq(rd_sink.addr),
|
wr_source.addr.eq(rd_sink.addr),
|
||||||
wr_source.count.eq(rd_sink.count),
|
wr_source.count.eq(rd_sink.count),
|
||||||
wr_source.be.eq(rd_sink.be),
|
wr_source.be.eq(rd_sink.be),
|
||||||
wr_source.data.eq(data.q),
|
#wr_source.data.eq(data.q),
|
||||||
|
wr_source.data.eq(0x12345678), # XXX
|
||||||
If(wr_source.stb & wr_source.ack,
|
If(wr_source.stb & wr_source.ack,
|
||||||
rd_sink.ack.eq(1),
|
rd_sink.ack.eq(1),
|
||||||
If(wr_source.eop,
|
If(wr_source.eop,
|
||||||
|
|
|
@ -50,35 +50,70 @@ class TB(Module):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
test_probe = False
|
||||||
|
test_writes = False
|
||||||
|
test_reads = True
|
||||||
|
|
||||||
# test probe
|
# test probe
|
||||||
#packet = etherbone.EtherbonePacket()
|
if test_probe:
|
||||||
#packet.pf = 1
|
packet = etherbone.EtherbonePacket()
|
||||||
#self.etherbone_model.send(packet)
|
packet.pf = 1
|
||||||
|
self.etherbone_model.send(packet)
|
||||||
|
|
||||||
|
for i in range(1024):
|
||||||
|
yield
|
||||||
|
|
||||||
# test writes
|
# test writes
|
||||||
writes = etherbone.EtherboneWrites(base_addr=0x1000)
|
if test_writes:
|
||||||
for i in range(16):
|
writes = etherbone.EtherboneWrites(base_addr=0x1000)
|
||||||
writes.add(etherbone.EtherboneWrite(i))
|
for i in range(16):
|
||||||
record = etherbone.EtherboneRecord()
|
writes.add(etherbone.EtherboneWrite(i))
|
||||||
record.writes = writes
|
record = etherbone.EtherboneRecord()
|
||||||
record.reads = None
|
record.writes = writes
|
||||||
record.bca = 0
|
record.reads = None
|
||||||
record.rca = 0
|
record.bca = 0
|
||||||
record.rff = 0
|
record.rca = 0
|
||||||
record.cyc = 0
|
record.rff = 0
|
||||||
record.wca = 0
|
record.cyc = 0
|
||||||
record.wff = 0
|
record.wca = 0
|
||||||
record.byte_enable = 0
|
record.wff = 0
|
||||||
record.wcount = 16
|
record.byte_enable = 0
|
||||||
record.rcount = 0
|
record.wcount = 16
|
||||||
|
record.rcount = 0
|
||||||
|
|
||||||
packet = etherbone.EtherbonePacket()
|
packet = etherbone.EtherbonePacket()
|
||||||
packet.records = [record]
|
packet.records = [record]
|
||||||
print(packet)
|
print(packet)
|
||||||
|
self.etherbone_model.send(packet)
|
||||||
|
|
||||||
self.etherbone_model.send(packet)
|
for i in range(1024):
|
||||||
|
yield
|
||||||
|
|
||||||
|
# test reads
|
||||||
|
if test_reads:
|
||||||
|
reads = etherbone.EtherboneReads(base_ret_addr=0x2000)
|
||||||
|
for i in range(16):
|
||||||
|
reads.add(etherbone.EtherboneRead(i))
|
||||||
|
record = etherbone.EtherboneRecord()
|
||||||
|
record.writes = None
|
||||||
|
record.reads = reads
|
||||||
|
record.bca = 0
|
||||||
|
record.rca = 0
|
||||||
|
record.rff = 0
|
||||||
|
record.cyc = 0
|
||||||
|
record.wca = 0
|
||||||
|
record.wff = 0
|
||||||
|
record.byte_enable = 0
|
||||||
|
record.wcount = 0
|
||||||
|
record.rcount = 16
|
||||||
|
|
||||||
|
packet = etherbone.EtherbonePacket()
|
||||||
|
packet.records = [record]
|
||||||
|
print(packet)
|
||||||
|
self.etherbone_model.send(packet)
|
||||||
|
|
||||||
|
for i in range(1024):
|
||||||
|
yield
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run_simulation(TB(), ncycles=1024, vcd_name="my.vcd", keep_files=True)
|
run_simulation(TB(), ncycles=4096, vcd_name="my.vcd", keep_files=True)
|
|
@ -143,9 +143,11 @@ class EtherboneRecord(Packet):
|
||||||
for k, v in sorted(etherbone_record_header.items()):
|
for k, v in sorted(etherbone_record_header.items()):
|
||||||
setattr(self, k, get_field_data(v, header))
|
setattr(self, k, get_field_data(v, header))
|
||||||
self.writes = self.get_writes()
|
self.writes = self.get_writes()
|
||||||
self.writes.decode()
|
if self.writes is not None:
|
||||||
|
self.writes.decode()
|
||||||
self.reads = self.get_reads()
|
self.reads = self.get_reads()
|
||||||
self.reads.decode()
|
if self.reads is not None:
|
||||||
|
self.reads.decode()
|
||||||
self.encoded = False
|
self.encoded = False
|
||||||
|
|
||||||
def set_writes(self, writes):
|
def set_writes(self, writes):
|
||||||
|
|
Loading…
Reference in New Issue