def _genRandomInstructions(self): for _ in range(RandomUtils.random32(100, 200)): if self.getGlobalState("AppRegisterWidth") == 32: instr = RV32_G_map.pick(self.genThread) else: instr = RV_G_map.pick(self.genThread) self.genInstruction(instr)
def generate(self, **kargs): for _ in range(RandomUtils.random32(250, 300)): if self.getGlobalState("AppRegisterWidth") == 32: instr = RV32_G_map.pick(self.genThread) else: instr = RV_G_map.pick(self.genThread) self.genInstruction(instr)
def generate(self, **kargs): for _ in range(RandomUtils.random32(5, 10)): if self.getGlobalState("AppRegisterWidth") == 32: instr = RV32_G_map.pick(self.genThread) else: instr = RV_G_map.pick(self.genThread) self.genInstruction(instr) self.genInstruction("MRET##RISCV", {"NoSkip": 1, "priv": 1}) for _ in range(RandomUtils.random32(5, 10)): if self.getGlobalState("AppRegisterWidth") == 32: instr = RV32_G_map.pick(self.genThread) else: instr = RV_G_map.pick(self.genThread) self.genInstruction(instr) target_addr = self.genVA(Size=4, Align=4, Type="I") self.genInstruction("SRET##RISCV", {"NoSkip": 1, "epc": target_addr, "priv": 0})
def generate(self, **kargs): if self.getThreadGroupId() == 0: # Thread Group 0 generates random integer data processing # instructions for _ in range(RandomUtils.random32(50, 100)): instr = ALU_Int64_map.pick(self.genThread) self.genInstruction(instr) elif self.getThreadGroupId() == 1: # Thread Group 1 generates random integer load/store instructions for _ in range(RandomUtils.random32(50, 100)): instr = LDST_Int_map.pick(self.genThread) # The NoPreamble flag avoids generating instructions to load a # value into the base register prior to generating the load or # store instruction self.genInstruction(instr, {"NoPreamble": 1}) elif self.getThreadGroupId() == 2: # Thread Group 2 randomly selects from a large collection of # instructions for _ in range(RandomUtils.random32(50, 100)): instr = RV_G_map.pick(self.genThread) self.genInstruction(instr) else: # The remaining thread groups generate load/store instructions # targeting a shared memory location. A thread locking context # permits only one thread at a time to execute until the executing # thread exits the context. This ensures only one thread generates # the shared physical address and the remaining threads use it. shared_phys_addr = 0 shared_phys_addr_name = "Shared PA" with self.threadLockingContext(): if not self.hasSharedThreadObject(shared_phys_addr_name): shared_phys_addr = self.genPA(Size=8, Align=8, Type="D", Shared=1) self.setSharedThreadObject(shared_phys_addr_name, shared_phys_addr) else: shared_phys_addr = self.getSharedThreadObject( shared_phys_addr_name) target_addr = self.genVAforPA(Size=8, Align=8, Type="D", PA=shared_phys_addr) for _ in range(RandomUtils.random32(10, 20)): instr = LDST_Int_map.pick(self.genThread) self.genInstruction(instr, {"LSTarget": target_addr})
def genRandomInstructions(self): for _ in range(RandomUtils.random32(5, 10)): instr = RV_G_map.pick(self.genThread) self.genInstruction(instr)
def _gen_group_2_instructions(self): for _ in range(RandomUtils.random32(50, 100)): instr = RV_G_map.pick(self.genThread) self.genInstruction(instr)
def generate(self, **kargs): for _ in range(RandomUtils.random32(250, 300)): instr = RV_G_map.pick(self.genThread) self.genInstruction(instr)