Ejemplo n.º 1
0
 def compile(self, hart, *sources):
     binary_name = "%s_%s-%d" % (
             self.name,
             os.path.basename(os.path.splitext(sources[0])[0]),
             hart.xlen)
     if Target.isolate:
         self.temporary_binary = tempfile.NamedTemporaryFile(
                 prefix=binary_name + "_")
         binary_name = self.temporary_binary.name
         Target.temporary_files.append(self.temporary_binary)
     march = "rv%dima" % hart.xlen
     for letter in "fdc":
         if hart.extensionSupported(letter):
             march += letter
     testlib.compile(sources +
             ("programs/entry.S", "programs/init.c",
                 "-DNHARTS=%d" % len(self.harts),
                 "-I", "../env",
                 "-march=%s" % march,
                 "-T", hart.link_script_path,
                 "-nostartfiles",
                 "-mcmodel=medany",
                 "-DXLEN=%d" % hart.xlen,
                 "-o", binary_name),
             xlen=hart.xlen)
     return binary_name
Ejemplo n.º 2
0
 def compile(self, *sources):
     binary_name = "%s_%s-%d" % (self.name, os.path.basename(os.path.splitext(sources[0])[0]), self.xlen)
     if self.isolate:
         self.temporary_binary = tempfile.NamedTemporaryFile(prefix=binary_name + "_")
         binary_name = self.temporary_binary.name
         Target.temporary_files.append(self.temporary_binary)
     march = "rv%dima" % self.xlen
     if self.use_fpu:
         march += "fd"
     if self.extensionSupported("c"):
         march += "c"
     testlib.compile(
         sources
         + (
             "programs/entry.S",
             "programs/init.c",
             "-I",
             "../env",
             "-march=%s" % march,
             "-T",
             "targets/%s/link.lds" % (self.directory or self.name),
             "-nostartfiles",
             "-mcmodel=medany",
             "-DXLEN=%d" % self.xlen,
             "-o",
             binary_name,
         ),
         xlen=self.xlen,
     )
     return binary_name
Ejemplo n.º 3
0
    def compile(self, hart, *sources):
        binary_name = "%s_%s-%d" % (
            self.name, os.path.basename(os.path.splitext(
                sources[0])[0]), hart.xlen)
        if Target.isolate:
            self.temporary_binary = tempfile.NamedTemporaryFile(
                prefix=binary_name + "_")
            binary_name = self.temporary_binary.name
            Target.temporary_files.append(self.temporary_binary)

        args = list(sources) + [
            "programs/entry.S", "programs/init.c",
            "-DNHARTS=%d" % len(self.harts), "-I", "../env", "-T",
            hart.link_script_path, "-nostartfiles", "-mcmodel=medany",
            "-DXLEN=%d" % hart.xlen, "-o", binary_name
        ]

        if hart.extensionSupported('e'):
            args.append("-march=rv32e")
            args.append("-mabi=ilp32e")
            args.append("-DRV32E")
        else:
            march = "rv%dima" % hart.xlen
            for letter in "fdcv":
                if hart.extensionSupported(letter):
                    march += letter
            args.append("-march=%s" % march)
            if hart.xlen == 32:
                args.append("-mabi=ilp32")
            else:
                args.append("-mabi=lp%d" % hart.xlen)

        testlib.compile(args)
        return binary_name
Ejemplo n.º 4
0
 def compile(self, *sources):
     binary_name = "%s_%s" % (
         self.name, os.path.basename(os.path.splitext(sources[0])[0]))
     if parsed.isolate:
         self.temporary_binary = tempfile.NamedTemporaryFile(
             prefix=binary_name + "_")
         binary_name = self.temporary_binary.name
     testlib.compile(
         sources +
         ("programs/entry.S", "programs/init.c", "-I", "../env", "-T",
          "targets/%s/link.lds" % (self.directory or self.name),
          "-nostartfiles", "-mcmodel=medany", "-o", binary_name),
         xlen=self.xlen)
     return binary_name
Ejemplo n.º 5
0
 def setUp(self):
     self.binary = testlib.compile("debug.c")
     self.spike = testlib.Spike(self.binary, halted=False)
     self.gdb = testlib.Gdb()
     self.gdb.command("file %s" % self.binary)
     self.gdb.command("target extended-remote localhost:%d" %
                      self.spike.port)
Ejemplo n.º 6
0
    def setUp(self):
        length = 2**20
        fd = file("data.c", "w")
        fd.write("#include <stdint.h>\n")
        fd.write("uint32_t length = %d;\n" % length)
        fd.write("uint8_t d[%d] = {\n" % length)
        self.crc = 0
        for i in range(length / 16):
            fd.write("  /* 0x%04x */ " % (i * 16))
            for _ in range(16):
                value = random.randrange(1 << 8)
                fd.write("%d, " % value)
                self.crc = binascii.crc32("%c" % value, self.crc)
            fd.write("\n")
        fd.write("};\n")
        fd.write("uint8_t *data = &d[0];\n")
        fd.close()

        self.binary = testlib.compile("checksum.c", "data.c", "start.S",
                                      "-mcmodel=medany", "-T",
                                      "standalone.lds", "-nostartfiles")
        self.spike = testlib.Spike(None, halted=True)
        self.gdb = testlib.Gdb()
        self.gdb.command("file %s" % self.binary)
        self.gdb.command("target extended-remote localhost:%d" %
                         self.spike.port)
Ejemplo n.º 7
0
    def setUp(self):
        length = 2**20
        fd = file("data.c", "w")
        fd.write("#include <stdint.h>\n")
        fd.write("uint32_t length = %d;\n" % length)
        fd.write("uint8_t d[%d] = {\n" % length)
        self.crc = 0
        for i in range(length / 16):
            fd.write("  /* 0x%04x */ " % (i * 16));
            for _ in range(16):
                value = random.randrange(1<<8)
                fd.write("%d, " % value)
                self.crc = binascii.crc32("%c" % value, self.crc)
            fd.write("\n");
        fd.write("};\n");
        fd.write("uint8_t *data = &d[0];\n");
        fd.close()

        self.binary = testlib.compile("checksum.c", "data.c", "start.S",
                "-mcmodel=medany",
                "-T", "standalone.lds",
                "-nostartfiles"
                )
        self.spike = testlib.Spike(None, halted=True)
        self.gdb = testlib.Gdb()
        self.gdb.command("file %s" % self.binary)
        self.gdb.command("target extended-remote localhost:%d" % self.spike.port)
Ejemplo n.º 8
0
 def compile(self, *sources):
     binary_name = "%s_%s" % (
             self.name,
             os.path.basename(os.path.splitext(sources[0])[0]))
     if parsed.isolate:
         self.temporary_binary = tempfile.NamedTemporaryFile(
                 prefix=binary_name + "_")
         binary_name = self.temporary_binary.name
     testlib.compile(sources +
             ("programs/entry.S", "programs/init.c",
                 "-I", "../env",
                 "-T", "targets/%s/link.lds" % (self.directory or self.name),
                 "-nostartfiles",
                 "-mcmodel=medany",
                 "-o", binary_name),
             xlen=self.xlen)
     return binary_name
Ejemplo n.º 9
0
 def setUp(self):
     self.binary = testlib.compile("mprv.S", "-T", "standalone.lds",
             "-nostartfiles")
     self.spike = testlib.Spike(None, halted=True)
     self.gdb = testlib.Gdb()
     self.gdb.command("file %s" % self.binary)
     self.gdb.command("target extended-remote localhost:%d" % self.spike.port)
     self.gdb.command("load")
Ejemplo n.º 10
0
 def setUp(self):
     self.binary = testlib.compile("mprv.S", "-T", "standalone.lds",
                                   "-nostartfiles")
     self.spike = testlib.Spike(None, halted=True)
     self.gdb = testlib.Gdb()
     self.gdb.command("file %s" % self.binary)
     self.gdb.command("target extended-remote localhost:%d" %
                      self.spike.port)
     self.gdb.command("load")
Ejemplo n.º 11
0
 def compile(self, *sources):
     binary_name = "%s_%s-%d" % (
         self.name, os.path.basename(os.path.splitext(
             sources[0])[0]), self.xlen)
     if self.isolate:
         self.temporary_binary = tempfile.NamedTemporaryFile(
             prefix=binary_name + "_")
         binary_name = self.temporary_binary.name
         Target.temporary_files.append(self.temporary_binary)
     march = "rv%dima" % self.xlen
     if self.use_fpu:
         march += "fd"
     if self.extensionSupported("c"):
         march += "c"
     testlib.compile(
         sources +
         ("programs/entry.S", "programs/init.c", "-I", "../env",
          "-march=%s" % march, "-T", "targets/%s/link.lds" %
          (self.directory or self.name), "-nostartfiles", "-mcmodel=medany",
          "-DXLEN=%d" % self.xlen, "-o", binary_name),
         xlen=self.xlen)
     return binary_name
Ejemplo n.º 12
0
 def setUp(self):
     self.binary = testlib.compile("ebreak.s")
Ejemplo n.º 13
0
 def setUp(self):
     self.binary = testlib.compile("ebreak.s")
Ejemplo n.º 14
0
 def setUp(self):
     self.binary = testlib.compile("debug.c")
     self.spike = testlib.Spike(self.binary, halted=False)
     self.gdb = testlib.Gdb()
     self.gdb.command("file %s" % self.binary)
     self.gdb.command("target extended-remote localhost:%d" % self.spike.port)