From: Luke Kenneth Casson Leighton Date: Sat, 29 Aug 2020 13:18:41 +0000 (+0100) Subject: add wat to write out raw binary assembled programs X-Git-Tag: semi_working_ecp5~246 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=938d7041f117a1ce26d42b19342280c9c8f93da7;p=soc.git add wat to write out raw binary assembled programs --- diff --git a/src/soc/simulator/program.py b/src/soc/simulator/program.py index aeb33a23..17950cda 100644 --- a/src/soc/simulator/program.py +++ b/src/soc/simulator/program.py @@ -110,5 +110,20 @@ class Program: self.binfile.seek(curpos, 0) return size + def write_bin(self, fname): + self.reset() + data = self.binfile.read() + with open(fname, "wb") as f: + f.write(data) + def close(self): self.binfile.close() + +if __name__ == '__main__': + lst = ['addi 5, 0, 4660', + 'mtcrf 255, 5', + 'mfocrf 2, 1', + 'attn', + ] + with Program(lst, False) as p: + p.write_bin("/tmp/test.bin")