一、CPU核设计(RTL级实现)
1. 顶层模块架构
module cpu8_top(
input clk, rst,
output [7:0] dbg_regs [0:3], // 寄存器监控接口
// UART接口
input uart_rxd,
output uart_txd
);
// 主要功能模块
wire [7:0] data_bus;
reg [7:0] pc;
wire [7:0] ir;
wire [3:0] alu_op;
wire [7:0] alu_out;
wire cf, zf;
// 实例化各子模块
reg_file regs(.clk(clk), .bus(data_bus), ...);
alu_unit alu(.a(data_bus), .b(data_bus), .op(alu_op), .out(alu_out), .cf(cf), .zf(zf));
control_unit ctrl(.clk(clk), .ir(ir), .pc(pc), .alu_op(alu_op), ...);
uart uart0(.clk(clk), .rx(uart_rxd), .tx(uart_txd), .bus(data_bus), ...);
endmodule
2. 寄存器文件设计
module reg_file(