`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: nope
// Engineer: Jose
// 
// Create Date: 02/20/2026 09:21:52 AM
// Design Name: EX/ME register
// Module Name: ex_me
// Project Name: riscv-ac
// Target Devices: Artix 7
// Tool Versions: 2025.2
// Description: Register between EX/ME stages
// 
// Dependencies: 
// 
// Revision: 1.0
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module ex_me (
    input clk, rst,
    input we_reg_in, we_mem_in, mem_to_reg_in,
    output reg we_reg_out, we_mem_out, mem_to_reg_out,
    input [31:0] alu_in, regB_in, pc4_in,
    input [4:0] rd_in,
    output reg [31:0] alu_out, regB_out, pc4_out,
    output reg [4:0] rd_out
);

    always @(posedge clk or posedge rst) begin
        if (rst) begin
            we_reg_out <= 0; we_mem_out <= 0; mem_to_reg_out <= 0;
            alu_out <= 0; regB_out <= 0; pc4_out <= 0; rd_out <= 0;
        end else begin
            we_reg_out <= we_reg_in; we_mem_out <= we_mem_in; mem_to_reg_out <= mem_to_reg_in;
            alu_out <= alu_in; regB_out <= regB_in; pc4_out <= pc4_in; rd_out <= rd_in;
        end
    end
endmodule