X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Fdecoder%2Ftest%2Ftest_decoder_gas.py;fp=src%2Fsoc%2Fdecoder%2Ftest%2Ftest_decoder_gas.py;h=52ae79775723565bc62d38a2fe44549c773cc8b9;hb=8ea4e3893d0b5631a5f65736ff9ca9ec035a07d2;hp=315225100b2149b90a37e66d519646706809f0b5;hpb=d0f39649c494ad5bf5dcf9b1e10609a43f58818f;p=soc.git diff --git a/src/soc/decoder/test/test_decoder_gas.py b/src/soc/decoder/test/test_decoder_gas.py index 31522510..52ae7977 100644 --- a/src/soc/decoder/test/test_decoder_gas.py +++ b/src/soc/decoder/test/test_decoder_gas.py @@ -379,9 +379,16 @@ class BranchRel: class DecoderTestCase(FHDLTestCase): - def get_assembled_instruction(self, instruction): + def get_assembled_instruction(self, instruction, bigendian=False): + if bigendian: + endian_fmt = "elf64-big" + obj_fmt = "-be" + else: + endian_fmt = "elf64-little" + obj_fmt = "-le" with tempfile.NamedTemporaryFile(suffix=".o") as outfile: args = ["powerpc64-linux-gnu-as", + obj_fmt, "-o", outfile.name] p = subprocess.Popen(args, stdin=subprocess.PIPE) @@ -390,6 +397,7 @@ class DecoderTestCase(FHDLTestCase): with tempfile.NamedTemporaryFile(suffix=".bin") as binfile: args = ["powerpc64-linux-gnu-objcopy", + "-I", endian_fmt, "-O", "binary", outfile.name, binfile.name] @@ -405,24 +413,26 @@ class DecoderTestCase(FHDLTestCase): pdecode = create_pdecode() m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode) - comb += pdecode2.dec.opcode_in.eq(instruction) - + comb += pdecode2.dec.raw_opcode_in.eq(instruction) sim = Simulator(m) def process(): for i in range(20): checker = kls() - instruction_str = checker.generate_instruction() print("instr", instruction_str.strip()) - instruction_bin = self.get_assembled_instruction( - instruction_str) - print("code", hex(instruction_bin), bin(instruction_bin)) + for endian in [0, 1]: + + instruction_bin = self.get_assembled_instruction( + instruction_str, endian) + print("code", endian, hex(instruction_bin), + bin(instruction_bin)) - yield instruction.eq(instruction_bin) - yield Delay(1e-6) + yield pdecode2.dec.bigendian.eq(endian) + yield instruction.eq(instruction_bin) + yield Delay(1e-6) - yield from checker.check_results(pdecode2) + yield from checker.check_results(pdecode2) sim.add_process(process) with sim.write_vcd("%s.vcd" % name, "%s.gtkw" % name,