本文整理汇总了Python中memory.Memory.writeMemory方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.writeMemory方法的具体用法?Python Memory.writeMemory怎么用?Python Memory.writeMemory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory.Memory
的用法示例。
在下文中一共展示了Memory.writeMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Pipelinecpu
# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import writeMemory [as 别名]
#.........这里部分代码省略.........
self.tempinst = self.id_exe.inst
elif self.istransfer & (self.opcode == 12):
self.tempinst = self.id_exe.inst
else:
self.tempinst = 'stall'
## Instruction Execution Stage
def __cpuStageEXE(self):
self.exe_mem.inst = self.tempinst
self.exe_mem.signalisStore = self.id_exe.signalisStore
self.exe_mem.signalBtaken = self.id_exe.signalBtaken
self.exe_mem.signalADEPEN = self.id_exe.signalADEPEN
self.exe_mem.signalBDEPEN = self.id_exe.signalBDEPEN
self.exe_mem.signalAluOp = self.id_exe.signalAluOp
self.exe_mem.readData2 = self.id_exe.readData2
self.exe_mem.regD = self.id_exe.regD
self.exe_mem.signalWmem = self.id_exe.signalWmem
self.exe_mem.signalWreg = self.id_exe.signalWreg
self.exe_mem.signalSld = self.id_exe.signalSld
self.exe_mem.signalWz = self.id_exe.signalWz
# forwarding
if self.id_exe.signalADEPEN == 0:
self.aluA = self.id_exe.readData1
elif self.id_exe.signalADEPEN == 2:
self.aluA = self.exe_mem.aluResult
elif self.id_exe.signalADEPEN == 3:
self.aluA = self.regData
else:
print 'Error!'
if self.id_exe.signalBDEPEN == 0:
self.aluB = self.id_exe.readData2
elif self.id_exe.signalBDEPEN == 1:
self.aluB = self.id_exe.immediateValue
elif self.id_exe.signalBDEPEN == 2:
self.aluB = self.mem_wb.aluResult
elif self.id_exe.signalBDEPEN == 3:
self.aluB = self.regData
else:
print 'Error!'
'''
if self.exe_mem.signalQDEPEN == 0:
self.storeD = self.id_exe.readData2
elif self.exe_mem.signalQDEPEN == 1:
self.storeD = self.regData
else:
print 'Error!'
'''
self.exe_mem.signalQDEPEN = int(self.id_exe.signalQDEPEN)
#self.exe_mem.storeD = self.storeD
self.alu.compute(self.id_exe.signalAluOp, self.aluA, self.aluB)
## Sets EXE_MEM registers
self.exe_mem.aluResult = self.alu.getResults()
if self.id_exe.signalWz:
self.exe_mem.zeroResult = self.alu.getZero()
## Memory Stage
def __cpuStageMEM(self):
self.mem_wb.inst = self.exe_mem.inst
self.mem_wb.regD = self.exe_mem.regD
self.mem_wb.readData2 = self.exe_mem.readData2
self.mem_wb.aluResult = self.exe_mem.aluResult
self.mem_wb.signalSld = self.exe_mem.signalSld
self.mem_wb.signalWreg = self.exe_mem.signalWreg
self.mem_wb.signalWmem = self.exe_mem.signalWmem
if self.exe_mem.signalQDEPEN == 0:
self.storeD = self.exe_mem.readData2
elif self.exe_mem.signalQDEPEN == 1:
self.storeD = self.regData
else:
print 'Error!'
self.mem_wb.signalQDEPEN = self.exe_mem.signalQDEPEN
## Read from Memory
self.mem_wb.memReadData = self.memory.readMemory(self.exe_mem.aluResult)
## Write to Memory
if self.exe_mem.signalWmem:
self.memory.writeMemory(int_to_twos(self.exe_mem.aluResult), self.storeD)
## Write Back Stage
def __cpuStageWB(self):
self.inst = self.mem_wb.inst
self.signalWreg = self.mem_wb.signalWreg
self.signalSld = self.mem_wb.signalSld
if self.signalSld:
self.regData = self.mem_wb.memReadData
else:
self.regData = self.mem_wb.aluResult
if self.signalWreg:
self.register.writeRegister(self.mem_wb.regD, self.regData)
def atomicStep(self, bin_instruction, instruction):
self.__cpuStageWB()
self.__cpuStageMEM()
self.__cpuStageEXE()
self.__cpuStageID()
return self.__cpuStageIF(bin_instruction, instruction)