Laboratory 4
Laboratory Report 4
This laboratory focused on inter-board communication using GPIO over the Blackboard FPGA's PMOD interface. The objective was to simulate traffic light behavior shared across two boards using message passing through GPIO signals. A switch determined whether the board acted as the North/South (N/S) controller or East/West (E/W) follower. The project involved configuring PMOD GPIO pins as outputs and inputs, establishing a signaling protocol between the boards, and synchronizing light sequences. This lab reinforced low-level hardware control, timing synchronization, and communication protocol design between microprocessors.
| Symbol/Abbreviation | Description |
|---|---|
| GPIO | General Purpose Input Output |
| FPGA | Field Programmable Gate Array |
| PMOD | Peripheral Module Interface |
| NS | North/South Board (Controller) |
| EW | East/West Board (Follower) |
This lab introduced GPIO-based message passing between two Blackboard FPGA systems. Using a simple signaling protocol, one board (N/S) controlled the traffic light sequence while the other board (E/W) mirrored its state based on received signals. Synchronization was achieved through memory-mapped register control of PMOD GPIO pins. The goal was to simulate a coordinated traffic light system across two processors.
The hardware used for this lab includes the blackboard development board, PMODC GPIO pins, tricolor LEDS, PMOD communication wiring, and switches. The components are connected and controlled using memory-mapped registers.
Implemented in C using memory-mapped registers for both input and output control. The software determines the board's role using Switch_Data, sets GPIO directions accordingly, and performs timed light state changes.
Switch_Data = *((uint32_t *)0x41220000)Bank0_Dir, Bank0_Enable, Bank0_Output control the onboard LED.Bank2_Dir, Bank2_Enable, Bank2_Output used to signal to the other board.Bank2_Input is used to receive signals from the controller (in follower mode).This lab demonstrated the fundamentals of inter-processor communication using GPIO. The traffic light simulation required precise control of memory-mapped registers, accurate timing, and synchronization between boards. The design showcased how GPIO can be used for simple and effective message passing in multi-processor systems. This experiment laid a foundation for more advanced communication strategies in embedded systems.
TrafficLight.c
/* traffic light */ #include <unistd.h> #include <stdint.h> #define Switch_Data *((uint32_t *)0x41220000) // switches are the lower 12 bits // Defines for Bank 0 (Bank 0 controal on-board stuff) #define Bank0_Dir *((uint32_t *)0xE000A204) //set each pin as input (0) or output(1) #define Bank0_Enable *((uint32_t *)0xE000A208) // Enable output driver (has to be 1 to drive pin) #define bank0_Input *((uint32_t *)0xE000A060) //Read current pin state #define Bank0_Output *((uint32_t *)0xE000A040) //write output vaues // Defines for Bank 2 (Bank 2 is connted to PMOD headers pin connector used to connect boards so they can talk to each other) #define Bank2_Dir *((uint32_t *)0xE000A284) //set each pin as input (0) or output(1) #define Bank2_Enable *((uint32_t *)0xE000A288) // Enable output driver (has to be 1 to drive pin) #define Bank2_Input *((uint32_t *)0xE000A068) //Read current pin state #define Bank2_Output *((uint32_t *)0xE000A048) //write output vaues /* PMODC pin 1 0x8000 PMODC pin 2 0x10000 PMODC pin 3 0x20000 PMODC pin 4 0x40000 PMODC pin 7 0x80000 PMODC pin 8 0x100000 PMODC pin 9 0x200000 PMODC pin 10 0x400000 ***Color Coding For LEDS*** Blue LED --> 0x10000 Red LED --> 0x20000 Green LED --> 0x40000 Yellow LED --> 0x20000 | 0x40000 (Green LED | RED LED) */ int main(void) { uint32_t signal; Bank0_Dir = 0x70000; //0x 70000 = 0b 0111 0000 0000 0000 0000 set bit/pins 16, 17, 18 to an output I want to drive this bit myself Bank0_Enable = 0x70000; // enables us to drive bits we just set to outputs Bank2_Dir = 0x70000; //0x 70000 = 0b 0111 0000 0000 0000 0000 set bit/pins 16, 17, 18 to an output I want to drive this bit myself Bank2_Enable = 0x70000; // enables us to drive bits we just set to outputs while(1) { uint32_t tempSwitch = Switch_Data; if((tempSwitch &= 0x1 )) { // turns master red for 2 seconds Bank0_Output = 0x20000; sleep(2); //turns master green for two seconds and signals to slave stay red Bank0_Output = 0x40000; Bank2_Output = 0x20000; sleep(2); //turns master yellow for one second and signals to slave stay red Bank0_Output = 0x20000 | 0x40000; Bank2_Output = 0x20000; sleep(1); //turns master red for two seconds and signals to slave to stay red Bank0_Output = 0x20000; Bank2_Output = 0x20000; sleep(2); //keeps master red for two seconds and signals to turn green Bank0_Output = 0x20000; Bank2_Output = 0x40000; sleep(2); //keeps master red for two seconds and signals slave to turn yellow Bank0_Output = 0x20000; Bank2_Output = 0x20000 | 0x40000; sleep(2); //keeps master red for two seconds and signals slave to turn red Bank0_Output = 0x20000; Bank2_Output = 0x20000; sleep(2); } else { signal = Bank2_Input; // ANDS the signal its getting from the master with 0x70000 (0x70000 = 0b 0111 0000 0000 0000 0000) to see what color it needs to be if((signal & 0x700000) == 0x20000) { Bank0_Dir = 0x20000 ; Bank0_Enable = 0x20000; Bank0_Output = 0x20000; } // ANDS the signal its getting from the master with 0x70000 (0x70000 = 0b 0111 0000 0000 0000 0000) to see what color it needs to be else if((signal & (0x700000)) == 0x40000) { Bank0_Dir = 0x40000 ; Bank0_Enable = 0x40000; Bank0_Output = 0x40000; } // ANDS the signal its getting from the master with 0x70000 (0x70000 = 0b 0111 0000 0000 0000 0000) to see what color it needs to be else if((signal & (0x700000)) == (0x20000 | 0x40000)) { Bank0_Dir = 0x20000 | 0x40000 ; Bank0_Enable = 0x20000 | 0x40000; Bank0_Output = 0x20000 | 0x40000; } // ANDS the signal its getting from the master with 0x70000 (0x70000 = 0b 0111 0000 0000 0000 0000) to see what color it needs to be else { Bank0_Dir = 0x20000 ; Bank0_Enable = 0x20000; Bank0_Output = 0x20000; } } } return 1; }
In this laboratory you will be using two microprocessors cooperating to create a simulation of a message being passed between the microprocessors.