mirror of
https://github.com/handsomezhuzhu/2025-yatcpu.git
synced 2026-02-20 20:10:14 +00:00
实验一的取指&译码
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
9
.idea/2025-fall-yatcpu-repo.iml
generated
Normal file
9
.idea/2025-fall-yatcpu-repo.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/2025-fall-yatcpu-repo.iml" filepath="$PROJECT_DIR$/.idea/2025-fall-yatcpu-repo.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -52,8 +52,6 @@ class Execute extends Module {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// lab1(Execute) end
|
||||
|
||||
io.mem_alu_result := alu.io.result
|
||||
|
||||
@@ -178,13 +178,25 @@ class InstructionDecode extends Module {
|
||||
)
|
||||
|
||||
// lab1(InstructionDecode)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
io.ex_aluop2_source := Mux(opcode === InstructionTypes.RM,
|
||||
ALUOp2Source.Register,
|
||||
ALUOp2Source.Immediate
|
||||
)
|
||||
// 仅当指令是 Load 类型时,才使能内存读。
|
||||
io.memory_read_enable := opcode === InstructionTypes.L
|
||||
// 仅当指令是 Store 类型时,才使能内存写。
|
||||
io.memory_write_enable := opcode === InstructionTypes.S
|
||||
// 根据指令类型,选择写回寄存器的数据来源。
|
||||
io.wb_reg_write_source := MuxLookup(
|
||||
opcode,
|
||||
RegWriteSource.ALUResult // 默认来源是ALU计算结果
|
||||
)( // 使用新的 MuxLookup 语法
|
||||
IndexedSeq(
|
||||
InstructionTypes.L -> RegWriteSource.Memory, // Load 指令来源是内存
|
||||
Instructions.jal -> RegWriteSource.NextInstructionAddress, // jal/jalr 来源是下一条指令地址 (PC+4)
|
||||
Instructions.jalr -> RegWriteSource.NextInstructionAddress
|
||||
)
|
||||
)
|
||||
// lab1(InstructionDecode) end
|
||||
io.reg_write_enable := (opcode === InstructionTypes.RM) || (opcode === InstructionTypes.I) ||
|
||||
(opcode === InstructionTypes.L) || (opcode === Instructions.auipc) || (opcode === Instructions.lui) ||
|
||||
|
||||
@@ -37,6 +37,12 @@ class InstructionFetch extends Module {
|
||||
io.instruction := io.instruction_read_data
|
||||
// lab1(InstructionFetch)
|
||||
|
||||
when(io.jump_flag_id) {
|
||||
pc := io.jump_address_id
|
||||
}.otherwise {
|
||||
pc := pc + 4.U
|
||||
}
|
||||
|
||||
|
||||
|
||||
// la1(InstructionFetch) end
|
||||
|
||||
Reference in New Issue
Block a user