Skip to content

Commit

Permalink
Move organization, documentation of jump table op codes
Browse files Browse the repository at this point in the history
and how they modify indicies to class level.
  • Loading branch information
JulianSKelly committed Feb 26, 2016
1 parent 895683c commit c8be93a
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions fpgalib/dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,23 @@ class DAC_Build15(DAC_Build8):
19 d[1]
...
33 d[15]
Table documenting how each op code can move the sram, jump table index
OP | BEHAVIOR
------------------------------------------------------------------------
IDLE | increment sram_idx and increment jt_idx
NOP | increment sram_idx and increment jt_idx
CHECK | move sram_idx and jt_idx OR increment sram_idx and jt_idx
JUMP | move sram_idx and jt_idx
CYCLE | move sram_idx and jt_idx OR increment sram_idx and jt_idx
END | no next entry
Attributes:
increment_ops (list[jump_table.Operation]): Jump table op codes that can
increment the sram index, jump table index
jump_ops (list[jump_table.Operation]): Jump table op codes that can
jump the sram index, jump table index
"""

HAS_JUMP_TABLE = True
Expand Down Expand Up @@ -1205,6 +1222,15 @@ class DAC_Build15(DAC_Build8):
MONITOR_0 = 5
MONITOR_1 = 10

increment_ops = (
jump_table.IDLE, jump_table.NOP, jump_table.CHECK,
jump_table.CYCLE
)

jump_ops = (
jump_table.CHECK, jump_table.JUMP, jump_table.CYCLE
)

@classmethod
def convert_from_address(cls, x_ns):
""" Convert a from address from ns to SRAM index.
Expand Down Expand Up @@ -1480,17 +1506,8 @@ def make_jump_table(cls, jt_entries, counters=None, start_address_ns=0):
We verify that jump table commands are not executed too frequently. We
check when our current command executes, and compare to execution of
the next command. The next command depends on the specifics of the
current command, arguments and conditions. We document all commands
below.
OP | BEHAVIOR
------------------------------------------------------------------------
IDLE | increment sram_idx and increment jt_idx
NOP | increment sram_idx and increment jt_idx
CHECK | move sram_idx and jt_idx OR increment sram_idx and jt_idx
JUMP | move sram_idx and jt_idx
CYCLE | move sram_idx and jt_idx OR increment sram_idx and jt_idx
END | no next entry
current command, arguments and conditions. See attributes increment_ops,
jump_ops.
:param list[jump_table.JumpEntry] jt_entries: JT entries
:param list[int] counters: counter values, or None for all 0s
Expand All @@ -1499,21 +1516,10 @@ def make_jump_table(cls, jt_entries, counters=None, start_address_ns=0):
:rtype: jump_table.JumpTable
"""

# these entries can increment both idx
increment_idx = (
jump_table.IDLE, jump_table.NOP, jump_table.CHECK,
jump_table.CYCLE
)

# these entries can move both idx
jump_idx = (
jump_table.CHECK, jump_table.JUMP, jump_table.CYCLE
)

# 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
if type(jt_entry.operation) in increment_idx:
if isinstance(jt_entry.operation, cls.increment_ops):
sram_idx = jt_entry.from_addr
next_jt_idx = k + 1
next_from_addr = jt_entries[next_jt_idx].from_addr
Expand All @@ -1523,7 +1529,7 @@ def make_jump_table(cls, jt_entries, counters=None, start_address_ns=0):
"executed too closely in time"
.format(jt_entry))
# second pass we check all jump cases
if type(jt_entry.operation) in jump_idx:
if isinstance(jt_entry.operation, cls.jump_ops):
sram_idx = jt_entry.to_addr
# take off 1 as first entry is always NOP (self.toString)
next_jt_idx = jt_entry.operation.jump_index - 1
Expand Down

0 comments on commit c8be93a

Please sign in to comment.