Skip to content

Commit

Permalink
Format indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
khkim6040 committed May 12, 2024
1 parent 4b90399 commit ea9d589
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 130 deletions.
2 changes: 1 addition & 1 deletion lab4-2/ALU.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module ALU (
input [1:0] jump_signal,
output reg [31:0] alu_result,
output reg [1:0] alu_bcond
);
);

always @(*) begin
alu_result = 32'b0;
Expand Down
2 changes: 1 addition & 1 deletion lab4-2/ALUControlUnit.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ALUControlUnit (
input [2:0] funct3,
input [1:0] alu_op,
output reg [3:0] alu_ctrl_out
);
);

always @(*) begin
case(alu_op)
Expand Down
8 changes: 5 additions & 3 deletions lab4-2/Adder.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Adder(input [31:0] x0,
input [31:0] x1,
output reg [31:0] sum);
module Adder(
input [31:0] x0,
input [31:0] x1,
output reg [31:0] sum
);

always@(*) begin
sum = x0 + x1;
Expand Down
21 changes: 11 additions & 10 deletions lab4-2/ControlUnit.v
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
`include "opcodes.v"

module ControlUnit (input [6:0] part_of_inst,
output reg mem_read,
output reg [1:0] mem_to_reg,
output reg mem_write,
output reg alu_src,
output reg reg_write,
output reg [1:0] alu_op,
output reg is_ecall,
output reg [1:0] jump_signal
);
module ControlUnit (
input [6:0] part_of_inst,
output reg mem_read,
output reg [1:0] mem_to_reg,
output reg mem_write,
output reg alu_src,
output reg reg_write,
output reg [1:0] alu_op,
output reg is_ecall,
output reg [1:0] jump_signal
);


always @(*) begin
Expand Down
17 changes: 10 additions & 7 deletions lab4-2/DataMemory.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module DataMemory #(parameter MEM_DEPTH = 16384) (input reset,
input clk,
input [31:0] addr, // address of the data memory
input [31:0] din, // data to be written
input mem_read, // is read signal driven?
input mem_write, // is write signal driven?
output [31:0] dout); // output of the data memory at addr
module DataMemory #(parameter MEM_DEPTH = 16384) (
input reset,
input clk,
input [31:0] addr, // address of the data memory
input [31:0] din, // data to be written
input mem_read, // is read signal driven?
input mem_write, // is write signal driven?
output [31:0] dout // output of the data memory at addr
);

integer i;
// Data memory
reg [31:0] mem[0: MEM_DEPTH - 1];
Expand Down
3 changes: 2 additions & 1 deletion lab4-2/ForwardingUnit.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module ForwardingUnit(
input alu_src,
output reg [1:0] forwardA,
output reg [1:0] forwardB,
output reg [1:0] forwardC);
output reg [1:0] forwardC
);

always @(*) begin
if ((EX_rs1_index != 0) && (EX_rs1_index == MEM_reg_rd) && MEM_reg_write)
Expand Down
15 changes: 8 additions & 7 deletions lab4-2/GShare.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
`include "opcodes.v"

module GShare(
input clk,
input reset,
input [31:0] pc,
input [1:0] bcond,
input [31:0] EX_correct_next_pc,
input [31:0] EX_pc,
output reg [31:0] next_pc);
input clk,
input reset,
input [31:0] pc,
input [1:0] bcond,
input [31:0] EX_correct_next_pc,
input [31:0] EX_pc,
output reg [31:0] next_pc
);

reg [56:0] BTB [31:0];
reg [4:0] BHSR;
Expand Down
5 changes: 3 additions & 2 deletions lab4-2/HaltDetector.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module HaltDetector(
input is_ecall,
input[31:0] rs1_data,
output reg is_halted);
input [31:0] rs1_data,
output reg is_halted
);

always @(*) begin
is_halted = is_ecall && (rs1_data == 10);
Expand Down
38 changes: 20 additions & 18 deletions lab4-2/HazardDetector.v
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
`include "opcodes.v"

module HazardDetector (input clk,
input reset,
input [31:0] instruction,
input [4:0] rs1,
input [4:0] EX_rd,
input [4:0] MEM_rd,
input mem_read,
input is_ecall,
input [1:0] bcond,
input [31:0] ID_PC,
input [31:0] EX_PC,
input [31:0] target_pc,
output reg PC_write,
output reg IF_ID_write,
output reg ID_EX_nop_signal,
output reg IF_ID_nop_signal,
output reg [31:0] EX_correct_next_pc,
output reg EX_PCSrc);
module HazardDetector (
input clk,
input reset,
input [31:0] instruction,
input [4:0] rs1,
input [4:0] EX_rd,
input [4:0] MEM_rd,
input mem_read,
input is_ecall,
input [1:0] bcond,
input [31:0] ID_PC,
input [31:0] EX_PC,
input [31:0] target_pc,
output reg PC_write,
output reg IF_ID_write,
output reg ID_EX_nop_signal,
output reg IF_ID_nop_signal,
output reg [31:0] EX_correct_next_pc,
output reg EX_PCSrc
);

reg [4:0] rs2;
reg [6:0] opcode;
Expand Down
2 changes: 1 addition & 1 deletion lab4-2/ImmediateGenerator.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module ImmediateGenerator (
input [31:0] part_of_inst,
output reg [31:0] imm_gen_out
);
);

wire [6:0] opcode;
wire [2:0] funct3;
Expand Down
11 changes: 7 additions & 4 deletions lab4-2/InstMemory.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module InstMemory #(parameter MEM_DEPTH = 1024) (input reset,
input clk,
input [31:0] addr, // address of the instruction memory
output [31:0] dout); // instruction at addr
module InstMemory #(parameter MEM_DEPTH = 1024) (
input reset,
input clk,
input [31:0] addr, // address of the instruction memory
output [31:0] dout // instruction at addr
);

integer i;
// Instruction memory
reg [31:0] mem[0:MEM_DEPTH - 1];
Expand Down
3 changes: 2 additions & 1 deletion lab4-2/Mux_2_to_1.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Mux_2_to_1 #(parameter WIDTH = 32) (
input [WIDTH-1:0] x0,
input [WIDTH-1:0] x1,
input swch,
output reg [WIDTH-1:0] out);
output reg [WIDTH-1:0] out
);

always @(*) begin
if (swch == 1'b0) begin
Expand Down
14 changes: 8 additions & 6 deletions lab4-2/Mux_4_to_1.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module Mux_4_to_1 (input [31:0] x0,
input [31:0] x1,
input [31:0] x2,
input [31:0] x3,
input [1:0] swch,
output reg [31:0] out);
module Mux_4_to_1 (
input [31:0] x0,
input [31:0] x1,
input [31:0] x2,
input [31:0] x3,
input [1:0] swch,
output reg [31:0] out
);

always @(*) begin
case (swch)
Expand Down
2 changes: 1 addition & 1 deletion lab4-2/PC.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module PC(
input [31:0] next_pc,
input pc_write_signal,
output reg [31:0] current_pc
);
);

always @(posedge clk) begin
if (reset) begin
Expand Down
23 changes: 13 additions & 10 deletions lab4-2/RegisterFile.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
module RegisterFile(input reset,
input clk,
input [4:0] rs1, // source register 1
input [4:0] rs2, // source register 2
input [4:0] rd, // destination register
input [31:0] rd_din, // input data for rd
input write_enable, // RegWrite signal
output [31:0] rs1_dout, // output of rs 1
output [31:0] rs2_dout,
output [31:0] print_reg[0:31]); // output of rs 2
module RegisterFile(
input reset,
input clk,
input [4:0] rs1, // source register 1
input [4:0] rs2, // source register 2
input [4:0] rd, // destination register
input [31:0] rd_din, // input data for rd
input write_enable, // RegWrite signal
output [31:0] rs1_dout, // output of rs 1
output [31:0] rs2_dout,
output [31:0] print_reg[0:31] // output of rs 2
);

integer i;
// Register file
reg [31:0] rf[0:31];
Expand Down
Loading

0 comments on commit ea9d589

Please sign in to comment.