시리즈: RISC V Hardware
verilog
23 줄
· 업데이트 2026-07-04
branch_unit.v
RISC_V_Hardware/verilog/rtl/branch_unit.v
// ============================================================
// branch_unit.v -- evaluate B-type conditions from funct3
// ============================================================
`timescale 1ns/1ps
module branch_unit (
input wire [31:0] rs1,
input wire [31:0] rs2,
input wire [2:0] funct3,
output reg taken
);
always @(*) begin
case (funct3)
3'b000: taken = (rs1 == rs2); // beq
3'b001: taken = (rs1 != rs2); // bne
3'b100: taken = ($signed(rs1) < $signed(rs2)); // blt
3'b101: taken = ($signed(rs1) >= $signed(rs2)); // bge
3'b110: taken = (rs1 < rs2); // bltu
3'b111: taken = (rs1 >= rs2); // bgeu
default: taken = 1'b0;
endcase
end
endmodule
관련 글
RISC V Hardware
bash
업데이트 2026-07-04
build.sh
build.sh — bash source code from the RISC V Hardware learning materials (RISC_V_Hardware/build.sh).
글 읽기 →
RISC V Hardware
latex
업데이트 2026-07-04
style.tex
style.tex — latex source code from the RISC V Hardware learning materials (RISC_V_Hardware/latex/common/style.tex).
글 읽기 →
RISC V Hardware
verilog
업데이트 2026-07-04
alu.v
alu.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/alu.v).
글 읽기 →
RISC V Hardware
verilog
업데이트 2026-07-04
control.v
control.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/control.v).
글 읽기 →
RISC V Hardware
verilog
업데이트 2026-07-04
dmem.v
dmem.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/dmem.v).
글 읽기 →
RISC V Hardware
verilog
업데이트 2026-07-04
imem.v
imem.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/imem.v).
글 읽기 →