当前位置:网站首页>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
边栏推荐
- 高压漏电继电器BLD-20
- Phenomenon analysis when Autowired annotation is used for list
- [opencv] image morphological operation opencv marks the positions of different connected domains
- 想要选择一些部门优先使用 OKR, 应该如何选择试点部门?
- JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
- Leetcode (417) -- Pacific Atlantic current problem
- 最长公共子序列(LCS)(动态规划,递归)
- 高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
- Dbsync adds support for mongodb and ES
- torch optimizer小解析
猜你喜欢
随机推荐
最长不下降子序列(LIS)(动态规划)
Pytest testing framework -- data driven
CentOS 7.9安装Oracle 21c历险记
batch size设置技巧
Leetcode(46)——全排列
K6EL-100漏电继电器
Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
Leetcode(417)——太平洋大西洋水流问题
ThinkPHP关联预载入with
The sooner you understand the four rules of life, the more blessed you will be
pmp真的有用吗?
sublime使用技巧
AOSP ~Binder 通信原理 (一) - 概要
Creation and use of thread pool
Auto. JS get all app names of mobile phones
磁盘监控相关命令
高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
How can professional people find background music materials when doing we media video clips?
【opencv】图像形态学操作-opencv标记不同连通域的位置
一个酷酷的“幽灵”控制台工具









