当前位置:网站首页>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
边栏推荐
猜你喜欢

使用知云阅读器翻译统计遗传学书籍

Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.

Torch optimizer small parsing

Analysis -- MySQL statement execution process & MySQL architecture

pytest测试框架——数据驱动

c语言神经网络基本代码大全及其含义
![[question] Compilation Principle](/img/ce/71f8409ba2cebd497bed0210290895.png)
[question] Compilation Principle

U++ game learning notes

数字化创新驱动指南

PMP证书有没有必要续期?
随机推荐
DFS, BFS and traversal search of Graphs
LinkedBlockingQueue源码分析-初始化
Wonderful express | Tencent cloud database June issue
U++ metadata specifier learning notes
照片选择器CollectionView
Annotation初体验
Torch optimizer small parsing
SQL injection HTTP header injection
背包问题(01背包,完全背包,动态规划)
Weebly mobile website editor mobile browsing New Era
与利润无关的背包问题(深度优先搜索)
10 distributed databases that take you to the galaxy
CentOS 7.9安装Oracle 21c历险记
Knapsack problem unrelated to profit (depth first search)
EGR-20USCM接地故障继电器
LabVIEW在打开一个新的引用,提示内存已满
The execution order of return in JS' try catch finally
DBSync新增对MongoDB、ES的支持
漏电继电器LLJ-100FS
Understand common network i/o models