Introduction: FPGA Cyclone IV DueProLogic Controls Raspberry Pi Camera
Despite the FPGA DueProLogic is officially designed for Arduino, we are going to make the FPGA and Raspberry Pi 4B communicable.
Three tasks are implemented in this tutorial:
(A) Simultaneously press the two push buttons on FPGA to flip the angle of RPi camera.
(B) Raspberry Pi 4B controls the external LED circuit of FPGA.
(C) Live stream the Raspberry Pi Camera on Browser via WiFi
Step 1: Build Electronic Circuit
Step 2: Edit Verilog Code
When you buy the FPGA DueProLogic, you should receive a DVD. After you open "Projects_HDL", you should see the original HDL code file. After you set up the pin planner, add the highlighted code as shown in section 2A, 2B, 2C and 2D.
2A: To activate push buttons, you have to use this code
//Push Button Switches
input wire UBA,
input wire UBB
To communicate with Raspberry Pi, you need to add these.
reg sel_send; //activate Raspberry pi
reg rece; //received from raspberry pi
2B: To assigns values to the ports, you should edit the code accordingly
assign XIO_1 = start_stop_cntrl;
assign XIO_2 = rece; //output HIGH or LOW in LED circuit
assign XIO_2 = ~UBA; //push button
assign XIO_2 = UBB; //push button
assign XIO_2 = sel_send; // FPGA sends signal to raspberry pi
assign sel_read= XIO_5; //FPGA receives signal from raspberry pi
assign c_enable = XIO_5; //XIO_5 -- UB57 -- D17
assign LEDExt = XIO_5;
2C: If two push buttons are pressed simultaneously, the FPGA sends HIGH output to Raspberry Pi.
always @(sel_send or UBB or UBA) //send to RPi
if (UBB == 1'b0 && UBA == 1'b0)
sel_send = 1'b1;
sel_send = 1'b0;
2D: The FPGA reads signal from Raspberry Pi with the clock frequency of 66MHz. The port XIO_2 is linked to 'rece'.
always @(sel_read) //read pi
if (sel_read == 1'b1)
rece = 1'b0;
rece = 1'b1;
Step 3: Upload Verilog Code
Then upload the compiled pof file to the FPGA. If no hardware is detected automatically, click "Hardware Setup" to correct it manually
Step 4: Upload Raspberry Pi Code.
The highlighted lines allows the FPGA communicating with Raspberry Pi.
The full Raspberry Pi code for this project, https://roywchpi.blogspot.com/2020/06/12-fpga-cycl...
A = GPIO.input(pin) #read FPGA
camera.rotation = 0
GPIO.output(18,GPIO.LOW) #send to FPGA
camera.rotation = 180
GPIO.output(18,GPIO.HIGH) #send to FPGA
Step 5: Let's Try It!
Open your browser and type your IP address e.g. 192.168.xx.xxx:8000.
After all, the system should work!