当前位置:网站首页>Two person game based on bevy game engine and FPGA
Two person game based on bevy game engine and FPGA
2022-07-07 05:21:00 【biyezuopinvip】
Resource download address :https://download.csdn.net/download/sheziqiong/85931377
Resource download address :https://download.csdn.net/download/sheziqiong/85931377
Interface technology
The experiment purpose
- be familiar with MIPSfpga Software and hardware collaborative development
- Learn how to debug hardware
Experimental environment
operating system :Windows 10
development environment :
- Hardware development :Vivado 2018.2
- Software compilation :MIPS Tool chain
- GUI Realization :Bevy The game engine
Language :
- MIPSfpga Software :C
- GUI Realization :Rust
- Project design and implementation
- Overall design and implementation
- Design : adopt FPGA Serial port function on , And X86 The host communicates information , And then realize the movement control of game characters .
Realization : Provided by the school FPGA The experimental platform has UART Serial port module , Transfer through serial port USB Line can realize and X86 Host information sending and receiving , This has been done in previous experiments . So how to receive serial port information in the program ? Many programming languages have implemented serial programming support libraries , We just need to call API That's it .
Hardware implementation
The hardware implementation mainly includes two parts ,GPIO and UART modular .
First, in the vivado Add... To the project GPIO modular :
And connect the interrupt source to the interrupt controller 7 Port no. :
Then add UART Module and connected to AXI On the bus :
Modify the constraint file , take SWITCH Relevant constraint comments are removed :
Finally, we synthesize , Generate a bit stream and burn it on the board .
Software implementation
The software implementation is divided into two parts , The first part is C Language program , This part of the program will be cross compiled into MIPS The binary file of the instruction set is burned to FPGA The memory of the , Then run on the board .
Based on the original experiment 4 code , In interrupt handling function _mips_handle_irq Add right GPIO Judgment of interruption source , If the confirmation is from GPIO The interrupt source of , from GPIO Read value inside , And then through UART Send it to the host .
Code :
void _mips_handle_irq(void* ctx, int reason) {
volatile unsigned int period;
volatile unsigned int rxData;
*WRITE_IO(IO_LEDR) = 0xF00F; // Display 0xF00F on LEDs to indicate enter the interrupt
data_received = 0x0;
if(reason & IS_UART_INTR && !(reason & IS_TIME_INTR)) {
/* Read an input value from the console. */
rxData = *READ_IO(UART_BASE + rbr);
data_received = 0x1;
}
else if(reason & IS_PWM_INTR) {
// Set up pwm The value is 0
*WRITE_IO(PWM_BASE) = 0 * 110000;
}
else if(reason & IS_TIME_INTR) {
asm volatile ("mtc0 $0, $11");
asm volatile ("li $9, 0x1");
asm volatile ("mtc0 $9, $9");
}
else if(reason & IS_GPIO_INTR) {
volatile unsigned int sw = 0;
sw = *READ_IO(SW_LEDR);
uart_outbyte((char)sw);
}
else {
uart_print("Other interrupts occurred!\n\r");
uart_print(my_itoa(reason));
}
return;
}
then GUI The program uses Rust Language writing , be based on Rust Language development Bevy The game engine , We have realized a two person shooting game , The two characters use the keyboard and FPGA Board for control . The key question here is how we can Rust Received in the program by FPGA What about the message sent ?Rust There is a well implemented open source serial port programming library in the community , We call this library API It is convenient to realize the serial communication function . This library GitHub The address is here :. And then use Rust Language implementation of small game code GitHub The address is here :.
The effect of the combination of software and hardware is , Stir up FPGA Upper switch Key , An external interrupt will be generated , This interruption is in C Interrupt handling function in the program _mips_handle_irq Caught in , Then send information to the host through the serial port , The host will parse the information after receiving it , Then the character moves accordingly . In this way, we can pass FPGA The board controls the character to move and play .
Results of system operation
Hardware connection :
The result of the game :
Resource download address :https://download.csdn.net/download/sheziqiong/85931377
Resource download address :https://download.csdn.net/download/sheziqiong/85931377
边栏推荐
猜你喜欢
随机推荐
阿里云的神龙架构是怎么工作的 | 科普图解
Is PMP really useful?
AOSP ~binder communication principle (I) - Overview
ScheduledExecutorService定时器
利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
Error: No named parameter with the name ‘foregroundColor‘
批量归一化(标准化)处理
Timer create timer
做自媒体,有哪些免费下载视频剪辑素材的网站?
DBSync新增对MongoDB、ES的支持
JHOK-ZBL1漏电继电器
K6EL-100漏电继电器
Creation and use of thread pool
As we media, what websites are there to download video clips for free?
Safe landing practice of software supply chain under salesforce containerized ISV scenario
记录一次压测经验总结
Batch normalization (Standardization) processing
磁盘监控相关命令
数字化创新驱动指南
qt 简单布局 盒子模型 加弹簧