-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1198,12 +1198,12 @@ class DAC_Build15(DAC_Build8): | |
SRAM_WRITE_PKT_LEN = 256 | ||
SRAM_WRITE_DERPS = SRAM_LEN // SRAM_WRITE_PKT_LEN | ||
|
||
JUMP_TABLE_LEN = 528 | ||
JUMP_TABLE_PACKET_LEN = 528 | ||
NUM_COUNTERS = 4 | ||
COUNTER_BYTES = 4 | ||
IDLE_BITS = 15 | ||
JUMP_TABLE_ENTRY_BYTES = 8 | ||
JUMP_TABLE_COUNT = (JUMP_TABLE_LEN - (NUM_COUNTERS * COUNTER_BYTES) | ||
JUMP_TABLE_COUNT = (JUMP_TABLE_PACKET_LEN - (NUM_COUNTERS * COUNTER_BYTES) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
) / JUMP_TABLE_ENTRY_BYTES | ||
JT_FROM_ADDR_OFFSET = -2 | ||
JT_END_ADDR_OFFSET = JT_FROM_ADDR_OFFSET - 1 | ||
|
@@ -1516,6 +1516,10 @@ def make_jump_table(cls, jt_entries, counters=None, start_address_ns=0): | |
:rtype: jump_table.JumpTable | ||
""" | ||
|
||
if len(jt_entries) > cls.JUMP_TABLE_COUNT: | ||
This comment has been minimized.
Sorry, something went wrong.
maffoo
Contributor
|
||
raise ValueError("Jump table too long: {} > {}" | ||
.format(len(jt_entries), cls.JUMP_TABLE_COUNT)) | ||
|
||
# no two opcodes executed within JT_MIN_CLK_CYCLES_BETWEEN_OPCODES | ||
for k, jt_entry in enumerate(jt_entries): | ||
# first pass we check all increment cases | ||
|
@@ -1542,7 +1546,8 @@ def make_jump_table(cls, jt_entries, counters=None, start_address_ns=0): | |
return jump_table.JumpTable( | ||
start_addr=cls.convert_to_address(start_address_ns), | ||
jumps=jt_entries, | ||
counters=counters | ||
counters=counters, | ||
PACKET_LEN=cls.JUMP_TABLE_PACKET_LEN, | ||
) | ||
|
||
@classmethod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,22 +268,26 @@ class JumpTable(object): | |
TODO: make self.jumps a property with some checking on type and | ||
number. | ||
""" | ||
PACKET_LEN = 528 | ||
|
||
# TODO: Move these hardcoded FPGA values | ||
COUNTER_BITS = 32 # 32 bit register for counters | ||
COUNT_MAX = 2**COUNTER_BITS - 1 | ||
NUM_COUNTERS = 4 | ||
|
||
def __init__(self, start_addr=None, jumps=None, counters=None): | ||
def __init__(self, start_addr=None, jumps=None, counters=None, | ||
PACKET_LEN=528): | ||
This comment has been minimized.
Sorry, something went wrong.
maffoo
Contributor
|
||
""" | ||
:param start_addr: start address | ||
:param list[JumpEntry] jumps: the jump table entries | ||
:param list[int] counters: the counter values | ||
:param int PACKET_LEN: Number of packets in a JT write | ||
This comment has been minimized.
Sorry, something went wrong. |
||
""" | ||
self._startAddr = 0 | ||
self.counters = self._initialize_counters(counters=counters) | ||
self.start_addr = start_addr | ||
self.jumps = jumps | ||
self.PACKET_LEN = PACKET_LEN | ||
|
||
@classmethod | ||
def _initialize_counters(cls, counters=None): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""This is intended to test fpgalib/dac.py""" | ||
|
||
import pytest | ||
import numpy as np | ||
import fpgalib.dac as dac | ||
|
||
|
||
|
@@ -99,5 +100,16 @@ def test_nop_nop_min_clk_ok(self): | |
('END', [400]) | ||
]) | ||
|
||
def test_too_many_entry(self): | ||
This comment has been minimized.
Sorry, something went wrong. |
||
entry_sep = self.dac.JT_MIN_CLK_CYCLES_BETWEEN_OPCODES * 4 * 2 | ||
from_addr = (entry_sep * np.arange(self.dac.JUMP_TABLE_COUNT + 1) + | ||
entry_sep) | ||
entries = self.make_entries( | ||
[('NOP', [k]) for k in from_addr] + | ||
[('END', [from_addr[-1] + entry_sep])] | ||
This comment has been minimized.
Sorry, something went wrong.
maffoo
Contributor
|
||
) | ||
with pytest.raises(ValueError): | ||
self.dac.make_jump_table(entries) | ||
|
||
if __name__ == '__main__': | ||
pytest.main(['-v', __file__]) |
I'd suggest naming this
JT_MAX_ENTRIES
. Also, it seems to me it would be better to just put a constant number here, rather than computing it from things like the packet length. It's a quirk of the current communication protocol that the packet length and jump table length are the same; this may not be the case in the future. For example, we may be able to upload multiple jump tables in one sram write, or split a long jump table across multiple writes.