How does LUT sharing work? — Parallax Forums

# How does LUT sharing work?

Posts: 4,890
OK, I get that we have to allocate an even/odd pair of COGs (call them cog #0 and cog #1) and that a COG that wants to receive writes has to issue SETLUTS #1. Let's say cog #0 does SETLUTS #1. Then:

(1) Do all wrlut calls in cog #1 result in writes to both the cog #1 and cog #0 LUT?
(2) Assuming the answer to (1) above is "yes", is there any way for cog #1 to write to its own LUT (only) and not to its partner's?
(3) Does SETQ2/RDLONG in cog #1 also write to both LUTs?

• Posts: 3,249
From my recollection only half the LUTRAM gets shared when enabled. So you get one half as your own, and the other half (top?) is shared between COG pair. I would hope that SETQ2 block moves from HUB to LUT still works with LUT sharing but you'd need to test or get Chip to answer that one.
• Posts: 1,716
edited 2019-12-10 00:59
ersmith wrote: »
OK, I get that we have to allocate an even/odd pair of COGs (call them cog #0 and cog #1) and that a COG that wants to receive writes has to issue SETLUTS #1. Let's say cog #0 does SETLUTS #1. Then:

(1) Do all wrlut calls in cog #1 result in writes to both the cog #1 and cog #0 LUT?
(2) Assuming the answer to (1) above is "yes", is there any way for cog #1 to write to its own LUT (only) and not to its partner's?
(3) Does SETQ2/RDLONG in cog #1 also write to both LUTs?

(1) Yes.
(2) No, apart from SETLUTS #0 in cog 0.
(3) Yes.

Whole LUT is shared, I believe. The half LUT behaviour is that reads/writes are not possible in upper half using immediate addressing. Note that either paired cog reading/writing top four longs in LUT can set selectable-event flags 1 to 4, therefore it might be better not to put fixed lookup tables at very top of LUT RAM if sharing is enabled.
• Posts: 10,950
My understanding is same as Tony's.

revA silicon has a design flaw on coinciding read and write at same address. revB is fixed.

If both cogs are sharing both ways, be careful not to have coinciding writes at same address. That doesn't work. Shouldn't be needed anyway, with only two parties.

• Posts: 13,588
Tony is right.
• Posts: 1,716
From the EVENTS section of the doc:
POLLSE1/WAITSE1 event flag

● Cleared on ‘SETSE1 D/#’, for which D/# selects the event:

%000_00_01AA = this cog writes LUT address %1111111AA
%000_00_11AA = odd/even companion cog writes LUT address %1111111AA

[Same applies to SE2/3/4.]
Is any of this dependent on SETLUTS #1?
• Posts: 17,729
TonyB_ wrote: »
From the EVENTS section of the doc:
POLLSE1/WAITSE1 event flag

● Cleared on ‘SETSE1 D/#’, for which D/# selects the event:

%000_00_01AA = this cog writes LUT address %1111111AA