def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits( 32, random.randint(0,0xffffffff) ) src1 = Bits( 32, random.randint(0,0xffffffff) ) # Python rounds to negative infinity even for negative values, so we # need to do something a little more complicated. This was inspired # from this post: # # http://stackoverflow.com/questions/19919387 # a = src0.int() b = src1.int() A = -a if (a < 0) else a B = -b if (b < 0) else b c = -(A // B) if (a < 0) ^ (b < 0) else (A // B) dest = Bits( 32, c ) asm_code.append( gen_rr_value_test( "div", src0.uint(), src1.uint(), dest.uint() ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits(32, random.randint(0, 0xffffffff)) src1 = Bits(32, random.randint(0, 0xffffffff)) # Python rounds to negative infinity even for negative values, so we # need to do something a little more complicated. This was inspired # from this post: # # http://stackoverflow.com/questions/19919387 # a = src0.int() b = src1.int() A = -a if (a < 0) else a B = -b if (b < 0) else b c = -(A // B) if (a < 0) ^ (b < 0) else (A // B) dest = Bits(32, c) asm_code.append( gen_rr_value_test("div", src0.uint(), src1.uint(), dest.uint())) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits( 32, random.randint(0,0xffffffff) ) src1 = Bits( 32, random.randint(0,0xffffffff) ) dest = Bits( 32, src0.int() < src1.int() ) asm_code.append( gen_rr_value_test( "slt", src0.uint(), src1.uint(), dest.uint() ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits(32, random.randint(0, 0xffffffff)) src1 = Bits(32, random.randint(0, 0xffffffff)) dest = Bits(32, src0.int() < src1.int()) asm_code.append( gen_rr_value_test("slt", src0.uint(), src1.uint(), dest.uint())) return asm_code
def gen_random_test(): # Generate some random data data = [] for i in xrange(128): data.append( random.randint(0,0xff) ) # Generate random accesses to this data asm_code = [] for i in xrange(100): a = random.randint(0,127) b = random.randint(0,127) base = Bits( 32, 0x2000 + b ) offset = Bits( 16, a - b ) result = data[a] asm_code.append( gen_ld_value_test( "lbu", offset.int(), base.uint(), result ) ) # Add the data to the end of the assembly code asm_code.append( gen_byte_data( data ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(25): src = Bits(32, random.randint(0, 0xffffffff)) taken = (src.int() >= 0) asm_code.append(gen_br1_value_test("bgez", src.uint(), taken)) return asm_code
def gen_random_test(): # Generate some random data data = [] for i in xrange(128): data.append( random.randint(0,0xffff) ) # Generate random accesses to this data asm_code = [] for i in xrange(100): a = random.randint(0,127) b = random.randint(0,127) base = Bits( 32, 0x2000 + (2*b) ) offset = Bits( 16, (2*(a - b)) ) result = Bits( 32, data[a] ) asm_code.append( gen_st_random_test( "sh", "lhu", result.uint(), offset.int(), base.uint() ) ) # Generate some random data to initialize memory initial_data = [] for i in xrange(128): initial_data.append( random.randint(0,0xffff) ) # Add the data to the end of the assembly code asm_code.append( gen_hword_data( initial_data ) ) return asm_code
def gen_random_test(): # Generate some random data data = [] for i in xrange(128): data.append( random.randint(0,0xffffffff) ) # Generate random accesses to this data asm_code = [] for i in xrange(100): a = random.randint(0,127) b = random.randint(0,127) base = Bits( 32, 0x2000 + (4*b) ) offset = Bits( 16, (4*(a - b)) ) result = data[a] asm_code.append( gen_st_value_test( "sw", result, offset.int(), base.uint(), result ) ) # Generate some random data to initialize memory initial_data = [] for i in xrange(128): initial_data.append( random.randint(0,0xffffffff) ) # Add the data to the end of the assembly code asm_code.append( gen_word_data( initial_data ) ) return asm_code
def gen_random_test(): # Generate some random data data = [] for i in xrange(128): data.append(random.randint(0, 0xffff)) # Generate random accesses to this data asm_code = [] for i in xrange(100): a = random.randint(0, 127) b = random.randint(0, 127) base = Bits(32, 0x2000 + (2 * b)) offset = Bits(16, (2 * (a - b))) result = sext(Bits(16, data[a]), 32) asm_code.append( gen_ld_value_test("lh", offset.int(), base.uint(), result.uint())) # Add the data to the end of the assembly code asm_code.append(gen_hword_data(data)) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(25): src = Bits( 32, random.randint(0,0xffffffff) ) taken = ( src.int() > 0 ) asm_code.append( gen_br1_value_test( "bgtz", src.uint(), taken ) ) return asm_code
def gen_random_test(): # Generate some random data data = [] for i in xrange(128): data.append(random.randint(0, 0xFFFF)) # Generate random accesses to this data asm_code = [] for i in xrange(100): a = random.randint(0, 127) b = random.randint(0, 127) base = Bits(32, 0x2000 + (2 * b)) offset = Bits(16, (2 * (a - b))) result = sext(Bits(16, data[a]), 32) asm_code.append(gen_ld_value_test("lh", offset.int(), base.uint(), result.uint())) # Add the data to the end of the assembly code asm_code.append(gen_hword_data(data)) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src = Bits( 32, random.randint(0,0xffffffff) ) imm = Bits( 5, random.randint(0,31) ) dest = Bits( 32, src.int() >> imm.uint() ) asm_code.append( gen_rimm_value_test( "sra", src.uint(), imm.uint(), dest.uint() ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src = Bits( 32, random.randint(0,0xffffffff) ) imm = Bits( 16, random.randint(0,0xffff) ) dest = Bits( 32, src.int() < sext(imm,32).int() ) asm_code.append( gen_rimm_value_test( "slti", src.uint(), imm.uint(), dest.uint() ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits( 32, random.randint(0,0xffffffff) ) src1 = Bits( 32, random.randint(0,0xffffffff) ) a = src0.int() b = src1.int() A = -a if (a < 0) else a B = -b if (b < 0) else b c = -(A % B) if (a < 0) else (A % B) dest = Bits( 32, c ) asm_code.append( gen_rr_value_test( "rem", src0.uint(), src1.uint(), dest.uint() ) ) return asm_code
def gen_random_test(): asm_code = [] for i in xrange(100): src0 = Bits(32, random.randint(0, 0xffffffff)) src1 = Bits(32, random.randint(0, 0xffffffff)) a = src0.int() b = src1.int() A = -a if (a < 0) else a B = -b if (b < 0) else b c = -(A % B) if (a < 0) else (A % B) dest = Bits(32, c) asm_code.append( gen_rr_value_test("rem", src0.uint(), src1.uint(), dest.uint())) return asm_code