Exemplo n.º 1
0
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
Exemplo n.º 2
0
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 = sext( Bits( 8, data[a] ), 32 )

    asm_code.append( gen_ld_value_test( "lb", offset.int(), base.uint(), result.uint() ) )

  # Add the data to the end of the assembly code

  asm_code.append( gen_byte_data( data ) )
  return asm_code
Exemplo n.º 3
0
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
Exemplo n.º 4
0
 def logic():
     s.zout.next = zext(s.in_, 8)
     s.sout.next = sext(s.in_, 8)
Exemplo n.º 5
0
 def logic():
   s.zout.next = zext( s.in_, 8 )
   s.sout.next = sext( s.in_, 8 )