RISC-V_Verilog/rtl/risc_v_cpu.v

96 lines
2.3 KiB
Coq
Raw Normal View History

2023-10-23 05:15:21 +00:00
module risc_v_cpu (input clock, reset,
output [31:0] out);
2023-10-23 02:47:43 +00:00
wire [31:0] instruction;
wire [31:0] imm;
2023-10-23 02:24:09 +00:00
2023-10-23 02:32:25 +00:00
wire reg_we;
2023-10-23 02:24:09 +00:00
wire [1:0] reg_sel_data_in;
wire [4:0] reg_sel_out_a, reg_sel_out_b, reg_sel_in;
wire [31:0] reg_data_out_a, reg_data_out_b;
2023-10-21 13:57:58 +00:00
2023-10-23 02:47:43 +00:00
wire alu_src, alu_not;
wire [3:0] alu_func;
wire [31:0] alu_out;
2023-10-23 02:24:09 +00:00
wire mem_we;
wire [1:0] mem_func_in;
wire [2:0] mem_func_out;
2023-10-23 02:32:25 +00:00
wire [31:0] mem_out;
2023-10-23 02:24:09 +00:00
2023-10-23 02:47:43 +00:00
wire pc_is_jmp;
wire [1:0] pc_is_branch;
wire [31:0] pc_addr;
2023-10-21 13:57:58 +00:00
decoder decoder (
.instruction(instruction),
2023-10-23 02:24:09 +00:00
.imm(imm),
.reg_we(reg_we),
.reg_sel_data_in(reg_sel_data_in),
.reg_sel_out_a(reg_sel_out_a),
.reg_sel_out_b(reg_sel_out_b),
.reg_sel_in(reg_sel_in),
.alu_src(alu_src),
.alu_func(alu_func),
2023-10-21 13:57:58 +00:00
.mem_we(mem_we),
.mem_func_in(mem_func_in),
.mem_func_out(mem_func_out),
2023-10-23 02:47:43 +00:00
.pc_is_branch(pc_is_branch),
.pc_is_jmp(pc_is_jmp),
2023-10-21 13:57:58 +00:00
.alu_not(alu_not)
);
module_registers_bank module_registers_bank (
2023-10-21 13:57:58 +00:00
.clock(clock),
.reset(reset),
2023-10-23 02:24:09 +00:00
.we(reg_we),
.sel_data_in(reg_sel_data_in),
2023-10-23 02:24:09 +00:00
.sel_in(reg_sel_in),
.sel_out_a(reg_sel_out_a),
.sel_out_b(reg_sel_out_b),
.alu_out(alu_out),
.mem_out(mem_out),
.pc_addr(pc_addr),
2023-10-23 02:32:25 +00:00
.data_out_a(reg_data_out_a),
.data_out_b(reg_data_out_b)
2023-10-21 13:57:58 +00:00
);
module_alu module_alu (
.src(alu_src),
2023-10-24 10:39:42 +00:00
.func(alu_func),
.reg_in_a(reg_data_out_a),
.reg_in_b(reg_data_out_b),
.imm(imm),
2023-10-21 13:57:58 +00:00
.out(alu_out)
);
module_program_counter module_program_counter (
2023-10-21 13:57:58 +00:00
.clock(clock),
2023-10-22 13:41:39 +00:00
.reset(reset),
.is_jmp(pc_is_jmp),
.is_branch(pc_is_branch),
.alu_not(alu_not),
.alu_out(alu_out),
.imm(imm),
.addr(pc_addr)
2023-10-21 13:57:58 +00:00
);
instruction uut_instruction (
2023-10-23 02:24:09 +00:00
.address(pc_addr),
2023-10-21 13:57:58 +00:00
.instruction(instruction)
);
memory memory (
.clock(clock),
.reset(reset),
.we(mem_we),
.func_in(mem_func_in),
.func_out(mem_func_out),
2023-10-21 13:57:58 +00:00
.address(alu_out),
2023-10-23 02:32:25 +00:00
.data_in(reg_data_out_b),
.data_out(mem_out)
2023-10-21 13:57:58 +00:00
);
endmodule