Skip to content

Mikura-Kyouka/ego-cpu-env-mips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPU 设计开发模板

简介

本仓库包含在 EGO 开发板上进行 CPU 设计实验所需要的环境和测试工具。

环境

  • AMD Vivado 2025.2
  • EGO 开发板

目录结构

.
├── func                      测试程序
│   ├── convert.c
│   ├── include
│   ├── main.S
│   ├── Makefile
│   └── obj                   测试程序的编译产物(已经编译好)
├── myCPU                     你的 CPU 的代码
├── README.md                 本文档
└── soc_verify
    └── soc_hs_bram                  类 SRAM 接口的 SoC 工程
        ├── rtl
        ├── run_vivado
        │   ├── constraints
        │   └── create_project.tcl   使用该脚本创建工程
        └── testbench

使用方法

设计 CPU

你需要设计一个支持 MIPS32 中部分指令的 CPU,需要实现的指令如下:

addu
addiu
lui
ori
lw
sw
bne
b

准备源文件

将你的 CPU 代码(所有 .v 文件)放入 ego_cpu_env/myCPU/ 中。

你的顶层模块必须名为 mycpu_top,接口定义如下:

module mycpu_top(
    input  wire        clk,
    input  wire        resetn,
    // inst sram interface
    output wire inst_sram_req,
    output wire inst_sram_wr,
    output wire [1:0]inst_sram_size,
    output wire [3:0]inst_sram_wstrb,
    output wire [31:0]inst_sram_addr,
    output wire [31:0]inst_sram_wdata,
    input wire inst_sram_data_ok,
    input wire inst_sram_addr_ok,
    input wire [31:0]inst_sram_rdata,
    // data sram interface
    output wire data_sram_req,
    output wire data_sram_wr,
    output wire [1:0]data_sram_size,
    output wire [3:0]data_sram_wstrb,
    output wire [31:0]data_sram_addr,
    output wire [31:0]data_sram_wdata,
    input wire data_sram_data_ok,
    input wire data_sram_addr_ok,
    input wire [31:0]data_sram_rdata
);

创建工程

打开 AMD Vivado 2025.2,点击上方 Window -> Tcl Console 来调出 Tcl Console,并使用如下命令创建工程:

cd /path/to/ego_cpu_env/soc_verify/soc_hs_bram/run_vivado/
source create_project.tcl

Vivado 将会自动创建并打开工程。

仿真

点击左侧 Run Simulation -> Run Behavioral Simulation 开始仿真。

综合

点击左侧 Run Synthesis 进行综合。

实现

点击左侧 Run Implementation 进行实现。

生成比特流

点击左侧 Generate Bitstream 来生成比特流。

上板

观察开发板中间偏右位置的跳线,确保跳线帽插在 JTAG 位置上。

用附带线缆将开发板上 USB-JTAG 接口与电脑的 USB 接口连接,将开关拨到 ON 位置,给开发板上电。

点击 Vivado 的 Open Hardware Manager,再点击上面绿色背景区域的 Open target -> Auto Connect,它会自动搜索并连接开发板。

连接成功后,点击 Program device,并 Program。如果一切正常,应该观察到左下方 D1~D4 四个 LED 为“亮灭亮灭”,可参考下图。否则说明测试未通过。

success

注意事项

  • 本模板为 CPU 提供的时钟频率非常低,仅为 2 MHz,常见多周期设计可以正常跑过,如仍时序违例,请考虑自己的设计问题,如关键路径是否过长。

This project includes third-party code from Loongson Technology Corporation, licensed under a BSD-style license. See THIRD_PARTY_LICENSES/loongson.txt.

About

No description, website, or topics provided.

Resources

License

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors