Example: a one-channel DMA controller:
// Bus slave side, operand registers uint32 src, dest, length; bool busy, int_enable; uint32 status() { return (busy << 31) | (int_enable << 30); } | // Bus mastering side while(1) { waituntil(busy); while (length-- > 0) mem.write(dest++, mem.read(src++)); busy = 0; } |
Like to make interrupt output with an RTL-like continuous assignment:
interrupt = int_enable & !busy;But this will need a thread to run it