larpix / larpix-control

Control the LArPix chip
Other
4 stars 12 forks source link

Clean up network config files #214

Closed peter-madigan closed 4 years ago

peter-madigan commented 4 years ago

The network config files (under larpix/configs/controller/) used to describe the hydra network use three fields to specify the links between mosi/miso channels:

"miso_us_uart_map": [X,X,X,X],
"miso_ds_uart_map": [X,X,X,X],
"mosi_uart_map": [X,X,X,X]

The way these fields are translated to links between chips is non-trivial to understand and doesn't lend itself to a easily interpretable format. This should be reworked.

I propose to use:

"miso_uart_map": [X,X,X,X]
"mosi_uart_map": [X,X,X,X]
"usds_link_map": [X,X,X,X]

The index of each array is used to index the neighboring chips to the "active" chip, i.e. {0=up, 1=left, 2=down, 3=right}. The miso_uart_map specifies which miso uart is used to send data to the neighboring chip, i.e. {up=miso3, left=miso0, down=miso1, right=miso2}. The mosi_uart_map specifies the mosi uart that is used to receive data from the neighboring chip, i.e. {up=mosi0, left=mosi1, down=mosi2, right=mosi3}. Finally, usds_link_map is used to specify the position of the "active" chip relative to the neighboring chip, i.e. {up=neighbor down, left=neighbor right, down=neighbor up, right=neighbor left}. Putting these together (remembering that the index of the array corresponds to a particular direction from the "active" chip), we get a config:

"miso_uart_map": [3,0,1,2],
"mosi_uart_map": [0,1,2,3],
"usds_link_map": [2,3,0,1]

From this, it becomes easy to generate the uart channels for a downstream network that is complementary to the upstream network. The upstream miso uart for the active chip is simply miso_uart_map[chip_index] and the downstream miso uart for the neighbor chip then miso_uart_map[usds_link_map[chip_index]] (with the miso_uart_map specified by the neighboring chip's configuration).

You can then specify a complicated geometry relatively easily. For example, two chips connected via the "up" of chip A and the "left" of chip B could be specified by modifying the usds_link_map for the two chips: Globally:

"miso_uart_map": [3,0,1,2],
"mosi_uart_map": [0,1,2,3]

Chip A:

"usds_link_map" : [1,X,X,X]

Chip B:

"usds_link_map" : [X,0,X,X]

This seems simpler, but I have yet to work through a test case that also needs to modify the miso/mosi uart map to make sure this is still a reasonable format.