📄 nnarmcore.v
字号:
.in_SPSR(out_ALUSPSR2MEM),
.in_IfChangeState(out_IfChangeState2MEM),
.in_ChangeStateAction(out_ChangeStateAction2MEM),
.in_MEMStoreDelayBranchTarget(out_MEMStoreDelayBranchTarget2MEM),
.in_MEMDelayBranch(out_MEMDelayBranch2MEM),
.in_MemAccessUserBankRegister2MEM(out_MemAccessUserBankRegister2MEM),
//signal come from alu that origin come from decoder
.in_MEMType(out_MEMType2MEM),
.in_MEMTargetRegister(out_MEMTargetRegister2MEM),
.in_SimpleMEMType(out_SimpleMEMType2MEM),
.in_SimpleMEMTargetRegister(out_SimpleMEMTargetRegister2MEM),
.in_MEMPSRType(out_MEMPSRType2MEM),
.in_IsLoadToPC(out_IsLoadToPC),
//signal goto wb
.out_MEMWriteEnable(out_MEMWriteEnable),
.out_MEMWriteResult(out_MEMWriteResult),
.out_MEMTargetRegister(out_MEMTargetRegister2WB),
.out_SimpleMEMResult(out_SimpleMEMResult2WB),
.out_SimpleMEMTargetRegister(out_SimpleMEMTargetRegister2WB),
.out_MEMPSRType2WB(out_MEMPSRType2WB),
.out_CPSR2WB(out_CPSR2WB),
.out_SPSR2WB(out_SPSR2WB),
.out_IfChangeState(out_IfChangeState2WB),
.out_ChangeStateAction(out_ChangeStateAction2WB),
.out_MemAccessUserBankRegister2WB(out_MemAccessUserBankRegister2WB),
//the first and third write bus
.out_WriteBus(WriteBus),
.out_WriteRegisterEnable(WriteRegisterEnable),
.out_WriteRegisterNumber(WriteRegisterNumber),
.out_ThirdWriteBus(ThirdWriteBus),
.out_ThirdWriteRegisterEnable(ThirdWriteRegisterEnable),
.out_ThirdWriteRegisterNumber(ThirdWriteRegisterNumber),
.out_CPSR2PSR(out_CPSRWriteValue),
.out_CPSRWriteEnable(out_CPSRWriteEnable),
.out_SPSR2PSR(out_SPSRWriteValue),
.out_SPSRWriteEnable(out_SPSRWriteEnable),
//can MEM go?
.out_MEMOwnCanGo(out_MEMOwnCanGo),
.in_EXECanGo(out_EXECanGo),
//signal relate to load/store
.out_MEMAccessAddress(out_MEMAccessAddress),
.out_MEMAccessRequest(out_MEMAccessRequest),
.out_MEMAccessRW(out_MEMAccessRW),
.out_MEMAccessBW(out_MEMAccessBW),
.in_DataCacheWait(out_DataCacheWait),
.in_DataBus(DataBus_r),
.out_DataBus(DataBus_f),
//signal relate to change pc
.out_MEMChangePC(out_MEMChangePC),
.out_MEMNewPC(out_MEMNewPC),
//other signal
.clock(clock),
.reset(reset)
);
ALUComb inst_ALUComb(.ALUCombResult(ALUCombResult),
.out_Carry(Carry),
.out_Zero(Zero),
.out_Neg(Neg),
.out_Overflow(Overflow),
.ALUComb_ALUType(ALUComb_ALUType),
.ALUComb_LeftOperand(ALUComb_LeftOperand),
.ALUComb_RightOperand(ALUComb_RightOperand),
.ALUComb_ThirdOperand(ALUComb_ThirdOperand),
.ALUComb_RightOperandShiftType(ALUComb_RightOperandShiftType),
.ALUComb_RightOperandShiftCount(ALUComb_RightOperandShiftCount),
.ALUComb_ShiftCountInReg(ALUComb_ShiftCountInReg), //shift count in register
.ALUComb_ShiftCountHigh3Bit(ALUComb_ShiftCountHigh3Bit), //the [7:5] bit of shoft count when shift count is in register
.ALUComb_Operand2IsReg(ALUComb_Operand2IsReg),
.in_Carry(ALUComb_Carry),
.in_Overflow(ALUComb_Overflow),
.in_Neg(ALUComb_Neg),
.in_Zero(ALUComb_Zero)
);
ALUShell inst_ALUShell(.out_ALUWriteEnable(out_ALUWriteEnable),
.out_ALUWriteBus(out_ALUWriteBus), //write result
.out_CPSR(out_ALUCPSR2MEM),
.out_SPSR(out_ALUSPSR2MEM),
.out_ALUTargetRegister(out_ALUTargetRegister2MEM), //write to which register
.out_SimpleALUResult(out_SimpleALUResult2MEM),
.out_SimpleALUTargetRegister(out_SimpleALUTargetRegister2MEM),
.out_MEMType(out_MEMType2MEM),
.out_MEMTargetRegister(out_MEMTargetRegister2MEM),
.out_SimpleMEMType(out_SimpleMEMType2MEM),
.out_SimpleMEMTargetRegister(out_SimpleMEMTargetRegister2MEM),
.out_StoredValue(out_StoredValue),
.out_ALUPSRType(out_ALUPSRType2MEM),
.out_MEMPSRType(out_MEMPSRType2MEM),
.out_IsLoadToPC(out_IsLoadToPC),
.out_IfChangeState(out_IfChangeState2MEM),
.out_ChangeStateAction(out_ChangeStateAction2MEM),
.out_MEMStoreDelayBranchTarget(out_MEMStoreDelayBranchTarget2MEM),
.out_MEMDelayBranch(out_MEMDelayBranch2MEM),
.out_MemAccessUserBankRegister(out_MemAccessUserBankRegister2MEM),
//above is signal relate to write
//below is signal relate to new operation come from decoder
.in_ALUEnable(out_ALUEnable),
.in_ALUType(out_ALUType),
.in_ALULeftRegister(out_ALULeftRegister),
.in_ALURightRegister(out_ALURightRegister),
.in_ALUThirdRegister(out_ALUThirdRegister),
.in_ALULeftFromImm(out_ALULeftFromImm),
.in_ALURightFromImm(out_ALURightFromImm),
.in_ALUThirdFromImm(out_ALUThirdFromImm),
.in_CPSRFromImm(out_CPSRFromImm),
.in_SPSRFromImm(out_SPSRFromImm),
.in_ALURightShiftType(out_ALURightShiftType),
.in_ALULeftReadBus(mux_LeftReadBus),
.in_ALURightReadBus(mux_RightReadBus),
.in_ALUThirdReadBus(mux_ThirdReadBus),
.in_ALUCPSRReadBus(out_CPSR), //this must use value from status register file, it will deal with fresh itself
.in_ALUSPSRReadBus(out_SPSR),
.in_ALUTargetRegister(out_ALUTargetRegister),
.in_SimpleALUType(out_SimpleALUType),
.in_SimpleALUTargetRegister(out_SimpleALUTargetRegister),
.in_ALUMisc(out_ALUMisc), //some special signal
.in_ALUPSRType(out_ALUPSRType),
.in_NextAddressGoWithInstruction2ALU(out_NextAddressGoWithInstruction2ALU),
//pass to mem stage for this instruction's mem operation
.in_MEMEnable(out_MEMEnable),
.in_MEMType(out_MEMType),
.in_MEMTargetRegister(out_MEMTargetRegister),
.in_SimpleMEMType(out_SimpleMEMType),
.in_SimpleMEMTargetRegister(out_SimpleMEMTargetRegister),
.in_MEMPSRType(out_MEMPSRType),
//below is signal relate to forward operand from mem stage
.in_MEMWriteEnable(out_MEMWriteEnable),
.in_MEMWriteResult(out_MEMWriteResult),
.in_MEMTargetRegister2WB(out_MEMTargetRegister2WB),
.in_SimpleMEMResult(out_SimpleMEMResult2WB),
.in_SimpleMEMTargetRegister2WB(out_SimpleMEMTargetRegister2WB),
.in_MEMPSRType2WB(out_MEMPSRType2WB),
.in_MEMCPSR2WB(out_CPSR2WB),
.in_MEMSPSR2WB(out_SPSR2WB),
//below is signal relate to ALUComb connection
.ALUCombResult(ALUCombResult),
.in_Carry(Carry),
.in_Zero(Zero),
.in_Neg(Neg),
.in_Overflow(Overflow),
.ALUComb_ALUType(ALUComb_ALUType),
.ALUComb_LeftOperand(ALUComb_LeftOperand),
.ALUComb_RightOperand(ALUComb_RightOperand),
.ALUComb_ThirdOperand(ALUComb_ThirdOperand),
.ALUComb_RightOperandShiftType(ALUComb_RightOperandShiftType),
.ALUComb_RightOperandShiftCount(ALUComb_RightOperandShiftCount),
.ALUComb_ShiftCountInReg(ALUComb_ShiftCountInReg), //shift count in register
.ALUComb_ShiftCountHigh3Bit(ALUComb_ShiftCountHigh3Bit), //the [7:5] bit of shoft count when shift count is in register
.ALUComb_Operand2IsReg(ALUComb_Operand2IsReg),
//origin CPSR flag
.ALUComb_Carry(ALUComb_Carry),
.ALUComb_Neg(ALUComb_Neg),
.ALUComb_Overflow(ALUComb_Overflow),
.ALUComb_Zero(ALUComb_Zero),
//signal relate to pc change in branch instruction
.out_ChangePC(out_ChangePC),
.out_NewPC(out_NewPC),
//can alu go
.out_ALUOwnCanGo(out_EXEOwnCanGo),
//can mem go
.in_MEMCanGo(out_MEMCanGo),
//mem stage tell you to clear next operation
.in_MEMChangePC(out_MEMChangePC),
//thumb state
.in_ThumbState(out_CPSR_Fresh[`ThumbPos]),
.clock(clock),
.reset(reset)
);
assign mux_LeftReadBus=(out_ALULeftFromImm==1'b1)?dec_LeftReadBus:reg_LeftReadBus;
assign mux_RightReadBus=(out_ALURightFromImm==1'b1)?dec_RightReadBus:reg_RightReadBus;
assign mux_ThirdReadBus=(out_ALUThirdFromImm==1'b1)?dec_ThirdReadBus:reg_ThirdReadBus;
Decoder_ARM inst_Decoder_ARM( .in_ValidInstruction_IFID(Valid_Pipeline_IFID),
.in_PipelineRegister_IFID(out_nnARMInstruction),
.in_AddressGoWithInstruction(out_NewAddressGoWithInstruction),
.in_NextInstructionAddress(out_NextInstructionAddress),
.out_IDOwnCanGo(out_IDOwnCanGo),
//signal for register file
.out_LeftReadRegisterEnable(out_LeftReadRegisterEnable),
.out_LeftReadRegisterNumber(out_LeftReadRegisterNumber),
.out_RightReadRegisterEnable(out_RightReadRegisterEnable),
.out_RightReadRegisterNumber(out_RightReadRegisterNumber),
//use to read the shift count stored in register
.out_ThirdReadRegisterEnable(out_ThirdReadRegisterEnable),
.out_ThirdReadRegisterNumber(out_ThirdReadRegisterNumber),
//signal for register file
//signal for ALU
.out_ALUEnable(out_ALUEnable),
.out_ALUType(out_ALUType),
.out_ALULeftRegister(out_ALULeftRegister),
.out_ALURightRegister(out_ALURightRegister),
.out_ALUThirdRegister(out_ALUThirdRegister),
.out_ALULeftFromImm(out_ALULeftFromImm),
.out_ALURightFromImm(out_ALURightFromImm),
.out_ALUThirdFromImm(out_ALUThirdFromImm),
.out_CPSRFromImm(out_CPSRFromImm),
.out_SPSRFromImm(out_SPSRFromImm),
.out_ALUTargetRegister(out_ALUTargetRegister),
.out_ALUExtendedImmediateValue(dec_RightReadBus), //extended 32bit immediate value ,go to right bus
.out_ALURightShiftType(out_ALURightShiftType),
.out_ALUSecondImmediateValue(dec_ThirdReadBus), //serve as the shift count
.out_SimpleALUType(out_SimpleALUType), //serve for the pre index mode of load/store
.out_SimpleALUTargetRegister(out_SimpleALUTargetRegister),
.out_ALUMisc(out_ALUMisc), //some special signal
.out_ALUPSRType(out_ALUPSRType),
.out_AddressGoWithInstruction2ALU(dec_LeftReadBus), //pc go on the left read bus
.out_NextAddressGoWithInstruction2ALU(out_NextAddressGoWithInstruction2ALU),
//signal for mem stage
.out_MEMEnable(out_MEMEnable),
.out_MEMType(out_MEMType),
.out_MEMTargetRegister(out_MEMTargetRegister),
.out_SimpleMEMType(out_SimpleMEMType),
.out_SimpleMEMTargetRegister(out_SimpleMEMTargetRegister),
.out_MEMPSRType(out_MEMPSRType),
//Thumb state
.in_ThumbState(out_CPSR_Fresh[`ThumbPos]),
.in_IsInPrivilegedMode(out_IsInPrivilegedMode),
//interrupt signal
.in_TrueFiq(TrueFiq),
.in_TrueIrq(TrueIrq),
//can AUL go
.in_ALUCanGo(out_EXECanGo),
//clear internal state
.in_ChangePC(out_ChangePC),
.in_MEMChangePC(out_MEMChangePC),
.clock(clock),
.reset(reset)
);
ThumbDecoderWarper inst_ThumbDecoderWarper(//input
.in_ValidInstruction_IFID(Valid_Pipeline_IFID),
.in_PipelineRegister_IFID(Pipeline_IFID),
.in_AddressGoWithInstruction(out_AddressGoWithInstruction),
.in_ThumbState(out_CPSR_Fresh[`ThumbPos]),
//output
.out_NewAddressGoWithInstruction(out_NewAddressGoWithInstruction),
.out_nnARMInstruction(out_nnARMInstruction),
//clear internal state
.in_ChangePC(out_ChangePC),
.in_MEMChangePC(out_MEMChangePC),
.clock(clock),
.reset(reset)
);
IF inst_IF(.in_Instruction(Instruction), //input from instruction prefetched buffer
.in_InstructionWait(Wait), //wait for the prefetch buffer
.out_InstructionAddress(out_InstructionAddress), //output to instruction prefetched buffer
//above is for Instruction fetch
//use to read pc
.out_FourthReadRegisterEnable(out_FourthReadRegisterEnable),
.out_FourthReadRegisterNumber(out_FourthReadRegisterNumber),
.in_FourthReadBus(FourthReadBus),
//use to write pc
.out_SecondWriteRegisterEnable(out_SecondWriteRegisterEnable),
.out_SecondWriteRegisterNumber(out_SecondWriteRegisterNumber),
.out_SecondWriteBus(SecondWriteBus),
//can decoder go
.in_IDCanGo(out_IDCanGo),
//fetched instruction
.out_Instruction(Pipeline_IFID),
.out_ValidInstruction(Valid_Pipeline_IFID),
.out_AddressGoWithInstruction(out_AddressGoWithInstruction),
.out_NextInstructionAddress(out_NextInstructionAddress),
//signal relate to pc change in branch instruction
.in_ChangePC(out_ChangePC),
.in_NewPC(out_NewPC),
//signal send out by mem that declare to update pc
.in_MEMChangePC(out_MEMChangePC),
.in_MEMNewPC(out_MEMNewPC),
//thumb state
.in_ThumbState(out_CPSR_Fresh[`ThumbPos]),
.clock(clock),
.reset(reset)
);
//no InstructionPreFetch anymore
//InstructionPreFetch inst_InstructionPreFetch(
// .Instruction(Instruction),
// .Wait(Wait),
// .Address(out_InstructionAddress),
//above is the fetched instruction go to pipeline
//below is the prefetched instruction come from cache or memory
// .PreFetchedInstructions(InstructionOut),
// .PreFetchedWait(InstructionWait),
// .PreFetchedAddress(PreFetchedAddress),
// .PreFetchedRequest(PreFetchedRequest),
// .clock(clock),
// .reset(reset)
// );
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -