Severson-Group / AMDC-Firmware

Embedded system code (C and Verilog) which runs the AMDC Hardware
http://docs.amdc.dev/firmware
BSD 3-Clause "New" or "Revised" License
30 stars 5 forks source link

FPGA vs CPU Timing Analysis #316

Closed abhipriyabansal closed 8 months ago

abhipriyabansal commented 11 months ago

This PR addresses the difference in time taken by the FPGA and CPU to run a similar code and compute an arithmetic operation on REV E AMDC.

Changes to Overall Design

This PR adds an IP core called my_custom_adder that implements the adder on the FPGA and a user app to test the timing of adder in the FPGA versus the CPU (app file and command files added to run the operation and analyze timing).

Observations

A variety of tests were run using different number of operations and inputs. Their result can be seen below where each line represents time taken to compute the output for a set of inputs at multiple number of operations (for both FPGA and CPU) - line_graph_cpu line_graph_fpga

Results

The main running code is :

            // Compute result using CPU
            out = 8*in1 + in2/4 - 10203;

            // Compute result using FPGA
            base_addr[0] = in1;
            dmb();
            base_addr[1] = in2;
            dmb();
            out = base_addr[2];
            dmb();

In conclusion, the FPGA doesn't work accurately as an accelerator in this case, specifically because it is quite a simple command for the C code to run faster. If either it were a complex operation or the AXI transaction could be faster, the FPGA would accelerate it.

npetersen2 commented 11 months ago

@abhipriyabansal Looking good! Please fix the formatting issues, then I will review. Thanks

npetersen2 commented 8 months ago

Closing this PR since it is a practice exercise for new contributor onboarding.