If you have any old cassette tapes lying around and an FPGA, there now exists a project that allows for you to record data to them and also read data from those tapes. You could opt to use cassettes for your FPGA's mass storage device even! (Assuming your project doesn't have any high-speed data transfer requirements...)
Self-proclaimed occasional hobby developer Zoltan Pekic created this project in dedication to his friend, Zoran Modli. Using a Mercury FPGA development board with the Mercury baseboard, the system implements an intuitively clever design that converts the data to audio to record to the tapes.
The ADC on the Mercury baseboard connects to the microphone input of the tape recorder to send the analog audio waveform to the tape recorder while the DAC reads in the tape recorder's speaker output. A USB to UART PMOD module enables a PC to input hex data to the FPGA to write to the tape and also display the data read from the tape via a serial terminal.
By implementing a scheme of frequency shift keying known as binary frequency shift keying (FSK2), the FPGA writes a logical "0" to the cassette at a particular frequency and a logical "1" to the cassette at double the frequency of the frequency representing logic "0". With three different frequency sets, three different data rates (in bits per second or bps) are achieved:
As a quick summary, a tape recorder works by using a small electromagnet to apply a varying magnetic field to the tape in the cassette which causes the ferromagnetic oxide material of the tape to change magnetically. When the current is reversed across the electromagnet, it then produces a varying electronic signal based upon the varying magnetic field is it seeing as the tape moves past it. Amplifier circuitry is then used to create the signal strong enough to driver the speaker output of the tape recorder. The microphone input of the tape recorder takes the input audio signal and conditions it to drive the electromagnet to write to the tape.
This is why the frequency sets for the FSK2 must be within the spectrum of audio frequencies (20Hz - 20kHz). Also regardless of the data rate/baudrate of the data being recorded, the difference in the period of the signals between a "1" and "0" must always be 2:1. For instance, each "1" is 8 cycles of its given period (fmark) and each "0" is 4 cycles of its given period. This is due to the fact that the frequencies chosen for the FSK2 scheme use a frequency for "1" that's double that of the frequency for "0". Following the 2:1 rule means the tape recorder will have the same amount of time to record both frequency values.
A multiplexer in the VHDL of the design in the FPGA handles writing one frequency to the left audio channel and the other frequency to the right audio channel for stereo tape recorders, or if the tape recorder is mono the data is still readable since either one of the frequencies will just be a blank space on the tape.
This project is a really awesome example of retro hacking used to bring life back into old technology, while also being educational at the same time.