Research Article

Simulating Neural Network Processors

Algorithm 1

The procedure of launching one microcoded kernel.
Input: Two loop extents, ext0, ext1; the ID of the kernel to be launched, kId
(1)kernel = get the kernel with ID kId
(2)for var0 = 0; var0 < ext0; var0 + + do
(3)  for var1 = 0; var1 < ext1; var1 + + do
(4)for all insn in instructions of kernel do
(5)   while there is no free slot in output queue do
(6)   end this cycle
(7)   end while
(8)    write opcode of insn to output
(9)    for all arg in arguments of insn do
(10)if arg is immediate argument then
(11)argval = arg
(12)else if arg is composite argument then
(13)argval = arg.coef0var0 + arg.coef1var1 +  arg.addend + localregs[arg.reg]
(14)end if
(15)write argval to output
(16)end for
(17)end this cycle
(18)end for
(19)end for
(20)end for