Skip to content

Commit 0a115f6

Browse files
committedJul 24, 2015
litepcie/frontend/dma: group loop index and count in loop_status register (avoid 2 register reads)
1 parent d73d750 commit 0a115f6

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed
 

Diff for: ‎misoclib/com/litepcie/frontend/dma/common.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ def __init__(self, depth):
2828
self._value = CSRStorage(aw+lw)
2929
self._we = CSR()
3030
self._loop_prog_n = CSRStorage()
31-
self._index = CSRStatus(log2_int(depth))
31+
self._loop_status = CSRStatus(32)
3232
self._level = CSRStatus(log2_int(depth))
33-
self._loop = CSRStatus(16)
3433
self._flush = CSR()
35-
3634
self.irq = Signal()
3735

3836
# # #
@@ -41,8 +39,8 @@ def __init__(self, depth):
4139
value = self._value.storage
4240
we = self._we.r & self._we.re
4341
loop_prog_n = self._loop_prog_n.storage
44-
index = self._index.status
45-
loop = self._loop.status
42+
loop_index = self._loop_status.status[:log2_int(depth)]
43+
loop_count = self._loop_status.status[16:]
4644
level = self._level.status
4745
flush = self._flush.r & self._flush.re
4846

@@ -83,19 +81,19 @@ def __init__(self, depth):
8381
source.length.eq(fifo.dout.length)
8482
]
8583

86-
# index
84+
# loop_index, loop_count
8785
# used by the software for synchronization in
8886
# "loop" mode
8987
self.sync += \
9088
If(flush,
91-
index.eq(0),
92-
loop.eq(0),
89+
loop_index.eq(0),
90+
loop_count.eq(0),
9391
).Elif(source.stb & source.ack,
9492
If(fifo.dout.start,
95-
index.eq(0),
96-
loop.eq(loop+1)
93+
loop_index.eq(0),
94+
loop_count.eq(loop_count+1)
9795
).Else(
98-
index.eq(index+1)
96+
loop_index.eq(loop_index+1)
9997
)
10098
)
10199

Diff for: ‎misoclib/com/litepcie/software/linux/kernel/flags.h

+3
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
/* dma */
55
#define DMA_LOOPBACK_ENABLE 0x1
66

7+
#define DMA_TABLE_LOOP_INDEX 1 << 0
8+
#define DMA_TABLE_LOOP_COUNT 1 << 16
9+
710
#endif /* __HW_FLAGS_H */

Diff for: ‎misoclib/com/litepcie/software/linux/kernel/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ static int litepcie_dma_wait(LitePCIeState *s, struct litepcie_ioctl_dma_wait *m
268268
for (;;) {
269269
/* set current buffer */
270270
if (s->tx_dma_started) {
271-
m->tx_buf_num = litepcie_readl(s, CSR_DMA_READER_TABLE_INDEX_ADDR);
271+
m->tx_buf_num = (litepcie_readl(s, CSR_DMA_READER_TABLE_LOOP_STATUS_ADDR) & 0xffff);
272272
} else {
273273
m->tx_buf_num = 0;
274274
}
275275
if (s->rx_dma_started) {
276-
m->rx_buf_num = litepcie_readl(s, CSR_DMA_WRITER_TABLE_INDEX_ADDR);
276+
m->rx_buf_num = (litepcie_readl(s, CSR_DMA_WRITER_TABLE_LOOP_STATUS_ADDR) & 0xfffff);
277277
} else {
278278
m->rx_buf_num = 0;
279279
}

0 commit comments

Comments
 (0)
Please sign in to comment.