Discrete Fast Fourier Transform

In Verilog

- Decompose frequency from sound

  1. Extracting frequencies from sound

  2. Uncertainty principle

  3. Riemann Zeta function and primes

  4. Differential equations

Part 1. Sampling

    /* 
    Part 1: Volume Sampling
        Sampling frequency; 20kHz
        Number of samples; 10000
        Period: 0.5 seconds
    */
    // initialisation of the array to 12'b0
    initial begin
        freq = 12'd0;
        for (c = 0; c < 14'd10000;c = c + 1) begin
            SAMPLE[c] = 12'd0;
        end
    end
    //sample volume at 20kHz frequency
    reg onecycle = 1'b0;
    always @(posedge MCLK) begin
        if (counter == 14'd9999) begin
        onecycle = 1'b1;
            if(onecycle == 1'b1) begin
                FREQ = (RESULT_1000>RESULT_2000 && RESULT_1000>RESULT_3000) ? 3'b001 : (RESULT_2000>RESULT_3000)? 3'b011:3'b111;
                counter <= 14'b00000000000000;
                onecycle <= 1'b0;
            end
        //reset counter value after the calculations are done
        end
        else begin
            counter <= counter + 1;    
            SAMPLE[counter] = mic_in;   //g(t)
            if(vart_1000==5'd20) begin
                    vart_1000<= 5'b00001;
                end
            else vart_1000 <= vart_1000 + 1'b1;
            if(vart_2000==5'd10) begin
                    vart_2000<= 5'b00001;
            end
            else vart_2000 <= vart_2000 + 1'b1;
            if(vart_3000==5'd7) begin
                    vart_3000<= 5'b00001;
            end
            else vart_3000 <= vart_3000 + 1'b1;
        end
        
    end
    

Part 2. Calculation

Functions Used

  • Look-Up Table Method

Example: Calculation for 1000Hz

Last updated