An indexing module for looping over a plurality of indexes each corresponding to one of multiple dimensions of a tensor, the indexing module comprising: a counter unit comprising: a plurality of counter registers each storing a respective one of the plurality of indexes; and a plurality of size registers each corresponding to one of the counter registers; and an address unit, wherein: the counter unit updates the plurality of indexes stored in the counter registers by repeating a method to loop over the plurality of indexes, and the address unit generates, for each of the indexes stored in the counter registers, an address that is a polynomial of the respective index, wherein: the indexing module is driven by a clock, the counter unit further comprises an OVER register and a NEXT register, and the method comprising: resetting the counter registers and the size registers to 0; setting the OVER register to 1 and the NEXT register to 0; configuring the counter registers with a configuration input; configuring the size registers with the configuration input; setting the OVER register to 0 if any counter register contains a non-zero value; updating the NEXT register based on a counter register of a highest sequence of the counter registers that contains a non-zero value; decrementing the non-zero value of the counter register by 1 and updating counter registers having a higher sequence than specified by the NEXT register with the corresponding size registers; and repeating the updating the NEXT register, the decrementing the non-zero value and the updating the counter registers until each of the counter registers contains 0. a counter unit comprising: a plurality of counter registers each storing a respective one of the plurality of indexes; and a plurality of size registers each corresponding to one of the counter registers; and an address unit, wherein: a plurality of counter registers each storing a respective one of the plurality of indexes; and a plurality of size registers each corresponding to one of the counter registers; and an address unit, wherein: the counter unit updates the plurality of indexes stored in the counter registers by repeating a method to loop over the plurality of indexes, and the indexing module is driven by a clock, the counter unit further comprises an OVER register and a NEXT register, and the method comprising: resetting the counter registers and the size registers to 0; setting the OVER register to 1 and the NEXT register to 0; configuring the counter registers with a configuration input; configuring the size registers with the configuration input; setting the OVER register to 0 if any counter register contains a non-zero value; updating the NEXT register based on a counter register of a highest sequence of the counter registers that contains a non-zero value; decrementing the non-zero value of the counter register by 1 and updating counter registers having a higher sequence than specified by the NEXT register with the corresponding size registers; and repeating the updating the NEXT register, the decrementing the non-zero value and the updating the counter registers until each of the counter registers contains 0. resetting the counter registers and the size registers to 0; setting the OVER register to 1 and the NEXT register to 0; configuring the counter registers with a configuration input; configuring the size registers with the configuration input; setting the OVER register to 0 if any counter register contains a non-zero value; updating the NEXT register based on a counter register of a highest sequence of the counter registers that contains a non-zero value; decrementing the non-zero value of the counter register by 1 and updating counter registers having a higher sequence than specified by the NEXT register with the corresponding size registers; and repeating the updating the NEXT register, the decrementing the non-zero value and the updating the counter registers until each of the counter registers contains 0.