-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
5hayanB
committed
Nov 2, 2023
1 parent
c8c090f
commit 41d3a37
Showing
9 changed files
with
206 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FetchUnit( | ||
input clock, | ||
reset, | ||
input [31:0] io_imm, | ||
io_rs1, | ||
input io_stall_en, | ||
io_jalr_en, | ||
io_jal_en, | ||
output [31:0] io_pc | ||
); | ||
reg [31:0] pc; | ||
always @(posedge clock) begin | ||
if (reset) | ||
pc <= 32'h0; | ||
else if (io_stall_en) begin | ||
end | ||
else if (io_jalr_en) | ||
pc <= io_rs1 + io_imm; | ||
else if (io_jal_en) | ||
pc <= pc + io_imm; | ||
else | ||
pc <= pc + 32'h4; | ||
end | ||
assign io_pc = pc; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FetchUnit( | ||
input clock, | ||
reset, | ||
input [31:0] io_imm, | ||
io_rs1, | ||
input io_stall_en, | ||
io_jalr_en, | ||
io_jal_en, | ||
output [31:0] io_pc | ||
); | ||
reg [31:0] pc; | ||
always @(posedge clock) begin | ||
if (reset) | ||
pc <= 32'h0; | ||
else if (io_jalr_en) | ||
pc <= io_rs1 + io_imm; | ||
else if (io_stall_en) begin | ||
end | ||
else if (io_jal_en) | ||
pc <= pc + io_imm; | ||
else | ||
pc <= pc + 32'h4; | ||
end | ||
assign io_pc = pc; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FetchUnit( | ||
input clock, | ||
reset, | ||
input [31:0] io_imm, | ||
io_rs1, | ||
input io_stall_en, | ||
io_jalr_en, | ||
io_jal_en, | ||
output [31:0] io_pc | ||
); | ||
reg [31:0] pc; | ||
always @(posedge clock) begin | ||
if (reset) | ||
pc <= 32'h0; | ||
else if (io_jal_en) | ||
pc <= pc + io_imm; | ||
else if (io_stall_en) begin | ||
end | ||
else if (io_jalr_en) | ||
pc <= io_rs1 + io_imm; | ||
else | ||
pc <= pc + 32'h4; | ||
end | ||
assign io_pc = pc; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FetchUnit( | ||
input clock, | ||
reset, | ||
input [31:0] io_imm, | ||
io_rs1, | ||
input io_stall_en, | ||
io_jalr_en, | ||
io_jal_en, | ||
output [31:0] io_pc | ||
); | ||
reg [31:0] pc; | ||
always @(posedge clock) begin | ||
if (reset) | ||
pc <= 32'h0; | ||
else if (io_jal_en) | ||
pc <= pc + io_imm; | ||
else if (io_jalr_en) | ||
pc <= io_rs1 + io_imm; | ||
else if (io_stall_en) begin | ||
end | ||
else | ||
pc <= pc + 32'h4; | ||
end | ||
assign io_pc = pc; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fetch_unit | ||
|
||
import circt.stage.ChiselStage, | ||
chisel3._, | ||
chisel3.util._ | ||
|
||
|
||
class FetchUnit18 extends Module { | ||
//noinspection TypeAnnotation | ||
val io = IO(new Bundle { | ||
val imm : SInt = Input(SInt(32.W)) | ||
val rs1 : SInt = Input(SInt(32.W)) | ||
val stall_en: Bool = Input(Bool()) | ||
val jalr_en : Bool = Input(Bool()) | ||
val jal_en : Bool = Input(Bool()) | ||
|
||
val pc: UInt = Output(UInt(32.W)) | ||
}) | ||
|
||
val pc: UInt = RegInit(0.U(32.W)) | ||
|
||
pc := MuxCase(pc + 4.U, Seq( | ||
io.jalr_en -> (io.rs1 + io.imm).asUInt, | ||
io.stall_en -> pc, | ||
io.jal_en -> (pc + io.imm.asUInt) | ||
)) | ||
io.pc := pc | ||
} | ||
|
||
|
||
object VerilogMain18 extends App { | ||
ChiselStage.emitSystemVerilogFile(new FetchUnit18) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fetch_unit | ||
|
||
import circt.stage.ChiselStage, | ||
chisel3._, | ||
chisel3.util._ | ||
|
||
|
||
class FetchUnit19 extends Module { | ||
//noinspection TypeAnnotation | ||
val io = IO(new Bundle { | ||
val imm : SInt = Input(SInt(32.W)) | ||
val rs1 : SInt = Input(SInt(32.W)) | ||
val stall_en: Bool = Input(Bool()) | ||
val jalr_en : Bool = Input(Bool()) | ||
val jal_en : Bool = Input(Bool()) | ||
|
||
val pc: UInt = Output(UInt(32.W)) | ||
}) | ||
|
||
val pc: UInt = RegInit(0.U(32.W)) | ||
|
||
pc := MuxCase(pc + 4.U, Seq( | ||
io.jal_en -> (pc + io.imm.asUInt), | ||
io.stall_en -> pc, | ||
io.jalr_en -> (io.rs1 + io.imm).asUInt | ||
)) | ||
io.pc := pc | ||
} | ||
|
||
|
||
object VerilogMain19 extends App { | ||
ChiselStage.emitSystemVerilogFile(new FetchUnit19) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fetch_unit | ||
|
||
import circt.stage.ChiselStage, | ||
chisel3._, | ||
chisel3.util._ | ||
|
||
|
||
class FetchUnit20 extends Module { | ||
//noinspection TypeAnnotation | ||
val io = IO(new Bundle { | ||
val imm : SInt = Input(SInt(32.W)) | ||
val rs1 : SInt = Input(SInt(32.W)) | ||
val stall_en: Bool = Input(Bool()) | ||
val jalr_en : Bool = Input(Bool()) | ||
val jal_en : Bool = Input(Bool()) | ||
|
||
val pc: UInt = Output(UInt(32.W)) | ||
}) | ||
|
||
val pc: UInt = RegInit(0.U(32.W)) | ||
|
||
pc := MuxCase(pc + 4.U, Seq( | ||
io.jal_en -> (pc + io.imm.asUInt), | ||
io.jalr_en -> (io.rs1 + io.imm).asUInt, | ||
io.stall_en -> pc, | ||
)) | ||
io.pc := pc | ||
} | ||
|
||
|
||
object VerilogMain20 extends App { | ||
ChiselStage.emitSystemVerilogFile(new FetchUnit20) | ||
} |