目录整理:RTL/上板/仿真分开存放,测试 ROM 镜像归入 testbench/rom

- rtl/:12 个可综合的处理器源文件(顶层 cpu21_riscv_redirect_int_bpb.v,其余为各功能单元)。
- board/:板级顶层 cpu21_board_top.v、引脚约束 cpu21_board_top.xdc、片内 ROM 初始化
  cpu21_board_rom.vh 与短延时版本 cpu21_board_rom_fast.vh。
- testbench/:保留三个测试平台;ROM 镜像统一放到 testbench/rom/,测试程序源码与期望值
  仍在 testbench/programs/(其中的 .hex 是 RARS 原始输出,与 rom/ 里改过显示方式的版本
  内容不同,两者都保留)。
- 同步更新:两个测试平台的 ROM 探测路径改为 testbench/rom/(并在头注释里补充说明:
  PowerShell 会把 -generic_top/--testplusarg 参数里的 "=" 拆开、Verilog 字符串中的
  路径要用正斜杠);tools/hex2vh.py 的用法示例指向 board/cpu21_board_top.v;
  说明文档新增“目录结构”一节并同步所有路径引用;.gitignore 补充 .Xil/。
- 清理:删除 *.hex.lst 中间文件与空的 .Xil/ 目录。
- 验证:isa_test 24/24、lui_test 4/4、mmio_test 5/5 三项回归通过;两个基线(5560 / 6003
  周期)与整理前一致;板级仿真(默认 ROM 首次写入 LED=0001、快速 ROM 跑马灯循环)正常;
  Vivado 工程源文件路径同步到 rtl/ 与 board/ 后综合通过(LUT 5276、23 个引脚,与整理前
  完全一致),因此已有 bit 文件仍然有效。
This commit is contained in:
2026-09-13 18:06:21 +08:00
parent 1ae6fe6ebe
commit 556fbe9530
29 changed files with 157 additions and 110 deletions
+49
View File
@@ -0,0 +1,49 @@
`timescale 1ns / 1ps
`default_nettype none
// -----------------------------------------------------------------------------
// EX 级存储数据对齐单元。
//
// 依据地址低两位生成写数据与字节写掩码:sw 输出全字 + 1111,sb 把数据的
// 低 8 位搬到对应的字节车道,并只置位对应的写掩码。
// -----------------------------------------------------------------------------
module cpu21_riscv_store_unit (
input wire [31:0] addr_i,
input wire [31:0] data_i,
input wire mem_write_i,
input wire mem_byte_i,
output reg [31:0] store_data_o,
output reg [ 3:0] store_wstrb_o
);
always @* begin
store_data_o = data_i;
store_wstrb_o = 4'b0;
if (mem_write_i) begin
if (mem_byte_i) begin
case (addr_i[1:0])
2'd0: begin
store_data_o = {24'b0, data_i[7:0]};
store_wstrb_o = 4'b0001;
end
2'd1: begin
store_data_o = {16'b0, data_i[7:0], 8'b0};
store_wstrb_o = 4'b0010;
end
2'd2: begin
store_data_o = {8'b0, data_i[7:0], 16'b0};
store_wstrb_o = 4'b0100;
end
default: begin
store_data_o = {data_i[7:0], 24'b0};
store_wstrb_o = 4'b1000;
end
endcase
end else begin
store_data_o = data_i;
store_wstrb_o = 4'b1111;
end
end
end
endmodule
`default_nettype wire