Create a State Machine that interprets the commands from the CPU as follows:
command 1: START.
The START command creates an ultrasonic chirp with the following characteristics: 20 pulses varing in frequency from 39KHz to 41KHz.
after the chirp is sent, the system shall start capturing the received sounds in a memory bank. The memory shall be 100 bytes deep. Sound samples are to be stored every 200 microseconds. At the end of the 100 samples the storing shall stop and assert an external interrupt line low to notify the CPU.
Command #2: READ
the READ command is used to transfer the content of the memory to the CPU, after the command is issued the system will automatically retreive and send to the CPU the content of the memory starting at location 0 until the memory is exaused or the CPU terminates the transaction.
Command #3: SET GAIN 1
The SET GAIN 1 command transfers the gain value from the SPI bus to the chirp generator gain register. The register presents its outputs to external circuitry through FPGA pins.
Command #4: SET GAIN 2
Identical to the previous command, but for the receiver.