For this lab we will program the FPGA on the Nexys 4 DDR board to generate a wailing audio siren using a digital-to-analog (DAC) converter called Pmod Inter-IC Sound (I2S) with a headphone or speaker connected to the top pins of the Pmod port JA (In order to actually output the sound signal)
This code is necessary in order to properly utilize the digital to analog converter we will be using to output our signal.
In this code the SREG is used to serially shift data out to DAC, MSBit first. Left data is loaded into SREG on falling edge of SCLK when L_start is active. Right data is loaded into SREG on falling edge of SCLK when R_start is active. At other times, falling edge of SCLK causes REG to logically shift one bit left Serial data to DAC is MSBit of SREG.
In this code the process sets up a 20 bit binary counter clocked at 50MHz. This is used to generate all necessary timing signals. dac_load_L and dac_load_R are pulses sent to dac_if to load parallel data into shift register for serial clocking out to DAC