GithubHelp home page GithubHelp logo

riscv's People

Contributors

undefined01 avatar uytfvbnj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

uytfvbnj

riscv's Issues

优化Core模块的测试流程

目前( f84fd39 )的测试使用ModelSimtestbench进行驱动。

使用的工具链

RISC-V 在线仿真

RISC-V Toolchain on Windows

现状

编写了Makefile脚本以及bin2hexfile工具,能够从汇编自动编译并生成初始化 RAM 需要的hex文件(为readmemh所需格式,非Quartus中的Hexadecimal (Intel Format) File格式)。

需要手动向riscv-test.vt中加载测试用例、手动设置执行步数以及设置assert断言。

需要手动向riscv-test.vt中加载测试用例,可以自动执行直到程序退出,然后手动设置断言。

To Do

  • 针对指令本身功能编写更多测试用例

  • 针对可能出现的时序问题编写更完善的测试用例

  • 移植官方测试用例( https://github.com/riscv/riscv-tests

  • 配置更自动化的测试脚本

  • 一键回归测试(可能是在想 Peach)

  • 自动通过测试用例(汇编文件)生成REF输出(可能是在想 Peach)

对内存的访问必须四字节对齐,且只支持一次读写四字节

由于暂时没有设计好如何让内存模块在一次读写中支持不同的长度,为了快速开发出原型进行验证和迭代,暂时放弃对非对齐地址以及非四字节读写的支持。

硬编码代码位置

id.v 两处

riscv/fpga/src/core/id.v

Lines 104 to 115 in f84fd39

// 从内存读取数据到寄存器
`INSTRGROUP_L: begin
// 读取地址为 rs1 + offset 处共 funct3 byte 到 rd 寄存器中
src2_o = I_imm;
gprs_waddr_o = rd;
rtltype_o = `RTLTYPE_RMEM;
rtlop_o = `RTLOP_ADD;
// TODO: 需要更多补充信息来指示读取的长度。此处默认全部为4byte
end

riscv/fpga/src/core/id.v

Lines 117 to 127 in f84fd39

// 写入数据到内存
`INSTRGROUP_S: begin
// 将 rs2 寄存器的值写入到地址为 rs1 + offset 处共 funct3 byte
src1_o = src1_o + S_imm;
rtltype_o = `RTLTYPE_WMEM;
rtlop_o = `RTLOP_ADD;
// TODO: 需要更多补充信息来指示读取的长度。此处默认全部为4byte
end

后续可能需要在IDEXMEM阶段之间额外传递内存访问长度,对流水线接口进行破坏性更改。

Core的实例化

always @(posedge clk) begin
ram_if_data <= ram[ram_if_addr[31:2]];
if (ram_mem_rw == `MEM_READ)
ram_mem_rdata <= ram[ram_mem_addr[31:2]];
else
ram[ram_mem_addr[31:2]] <= ram_mem_wdata;
end

可能的解决方案

仍旧沿用32位宽的 RAM 模块。读取时读取所在 4 Byte 的区块再进行分发。
但是写入时不能影响区块的其他数据,而写入必须在一个周期内完成。可能需要同时使用上升沿和下降沿:上升沿进行读取,组合电路修改,再在下降沿写回。

这样可能造成时序不稳定。

流水线的时序设计有优化空间

f84fd39

使用的流水线大致如图

EX到ID的转发
MEM到ID的转发

在实现过程中有部分修改。

有部分流水线可以利用组合电路缩短周期。但是否适合缩短需要等待时序分析并设计时序约束后再进一步优化。

目前计划中的优化

  • IF逻辑独立成一个模块(或IF模块和IF_ID衔接模块)

  • IF获取pc对应指令的逻辑进行简化

  • IDEXMEMWB流水线中指令信号传递的优化
    包括但不限于传递给下一个流水线的数据,流水线模块间的交互逻辑,全局信号由哪个模块驱动

不那么重要的优化

  • 分支预测

  • 时序约束

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.