📄 nnarm.v
字号:
.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),
.io_DataBus(DataCacheBus),
//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
.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),
//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(LeftReadBus),
.in_ALURightReadBus(RightReadBus),
.in_ALUThirdReadBus(ThirdReadBus),
.in_ALUCPSRReadBus(out_CPSR),
.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
//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),
.clock(clock),
.reset(reset)
);
Decoder_ARM inst_Decoder_ARM( .in_ValidInstruction_IFID(Valid_Pipeline_IFID),
.in_PipelineRegister_IFID(Pipeline_IFID),
.in_AddressGoWithInstruction(out_AddressGoWithInstruction),
.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(RightReadBus), //extended 32bit immediate value ,go to right bus
.out_ALURightShiftType(out_ALURightShiftType),
.out_ALUSecondImmediateValue(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(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),
//can AUL go
.in_ALUCanGo(out_EXECanGo),
.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),
.clock(clock),
.reset(reset)
);
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)
);
InstructionCacheController inst_InstructionCacheController(
.InstructionOut(InstructionOut),
.InstructionWait(InstructionWait),
.InstructionAddress(PreFetchedAddress),
.InstructionRequest(PreFetchedRequest),
//below is the memory access
.MemoryBus(MemoryBus),
.MemoryAddress(InstructionAddress),
.MemoryRequest(MemoryRequest),
.nMemoryWait(nMemoryWait),
.clock(clock),
.reset(reset)
);
DataCacheController inst_DataCacheController( //signal between mem and DataCacheController
.in_DataCacheAddress(out_MEMAccessAddress), //data address
.io_DataCacheBus(DataCacheBus), //data value for write and read
.in_DataCacheAccessEnable(out_MEMAccessRequest), //enable access
.in_DataCacheBW(out_MEMAccessBW), //1 means byte,0 means word
.in_DataCacheRW(out_MEMAccessRW), //1 means read,0 means write
.out_DataCacheWait(out_DataCacheWait), //wait for free
//signal between DataCacheController and MemoryCotroller
.out_DataMemoryAddress(out_DataMemoryAddress), //address goto memory
.io_DataMemoryBus(DataMemoryBus), //data value for write to memory
.out_DataMemoryEnable(out_DataMemoryEnable), //enable accesss
.out_DataMemoryRW(out_DataMemoryRW), //1 means read, 0 means write
.in_DataMemoryWait(~nDataMemoryWait), //wait for memory
//signal for clock and reset
.clock(clock),
.reset(reset)
);
MemoryController inst_DataMemoryController(
.DataBus(DataMemoryBus), //data bus ,bidirection
.nWAIT(nDataMemoryWait), //wait for valid value,this signal can not be used directly by external device other than cpu,because after the CPU send out memory request ,the memory can disable this signal only after 1 cycle
.AddressBus(out_DataMemoryAddress), //address bus
.nRW(~out_DataMemoryRW), //0 is read,1 is write
.nBW(1'b1), //0 is read byte,1 is read word ,not support
.nMREQ(~out_DataMemoryEnable), //0 is memory request,1 is for other device(coprocessor)
.SEQ(1'b0), //1 is sequential access mode ,
.MCLK(clock), //main clock
.nRESET(reset)
);
MemoryController inst_MemoryController(
.DataBus(MemoryBus), //data bus ,bidirection
.nWAIT(nMemoryWait), //wait for valid value,this signal can not be used directly by external device other than cpu,because after the CPU send out memory request ,the memory can disable this signal only after 1 cycle
.AddressBus(InstructionAddress), //address bus
.nRW(1'b0), //0 is read,1 is write
.nBW(1'b1), //0 is read byte,1 is read word ,not support
.nMREQ(~MemoryRequest), //0 is memory request,1 is for other device(coprocessor)
.SEQ(1'b0), //1 is sequential access mode ,
.MCLK(clock), //main clock
.nRESET(reset)
);
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -