diff options
author | Snuffick <aleks.bae@gmail.com> | 2015-12-04 14:13:04 +0300 |
---|---|---|
committer | Snuffick <aleks.bae@gmail.com> | 2015-12-04 14:13:04 +0300 |
commit | 49f076385c73b738acb508c3806678f058d4ceb6 (patch) | |
tree | 9a32834291778a576494c5570b660a6bfa7f8597 /sw | |
parent | dc61e35246cfa66df78be782f9514f421db4bb9d (diff) | |
download | MIPSLabs-49f076385c73b738acb508c3806678f058d4ceb6.zip MIPSLabs-49f076385c73b738acb508c3806678f058d4ceb6.tar.gz MIPSLabs-49f076385c73b738acb508c3806678f058d4ceb6.tar.bz2 |
Исправлена ошибка, приводящая к невозможности синтеза проекта (файл hazard_unit.v).
Файл test.asm был скорректирован (код теперь соответствует комментариям).
Был добавлен скрипт convert.py, генерирующий файлы инициализации для памяти.
Для сборки спомощью makefile теперь необходимо установить python версии 2.7+ (наличие perl больше не требуется)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Makefile | 16 | ||||
-rw-r--r-- | sw/convert.py | 82 | ||||
-rw-r--r-- | sw/test.asm | 7 |
3 files changed, 91 insertions, 14 deletions
diff --git a/sw/Makefile b/sw/Makefile index 0c8b0db..0e3580e 100644 --- a/sw/Makefile +++ b/sw/Makefile @@ -1,12 +1,11 @@ CFLAGS = -O2 -Wall -c -s -GCC_MIPS = mips-sde-elf-gcc $(CFLAGS) -AS_MIPS = mips-sde-elf-as -LD_MIPS = mips-sde-elf-ld -DUMP_MIPS = mips-sde-elf-objdump -COPY_MIPS = mips-sde-elf-objcopy -CONVERT_TEXT = cat text.vh | perl -pe 's/([\dA-F]{2})\s+([\dA-F]{2})\s+([\dA-F]{2})\s+([\dA-F]{2})/$$1$$2$$3$$4/g;' > text.rom -CONVERT_DATA = cat data.vh | perl -pe 's/([\dA-F]{2})\s+([\dA-F]{2})\s+([\dA-F]{2})\s+([\dA-F]{2})/$$1$$2$$3$$4/g;' > data.rom +GCC_MIPS = mips-sde-elf-gcc $(CFLAGS) +AS_MIPS = mips-sde-elf-as +LD_MIPS = mips-sde-elf-ld +DUMP_MIPS = mips-sde-elf-objdump +COPY_MIPS = mips-sde-elf-objcopy +CONVERT = python convert.py 512 1024 LIBS = @@ -16,8 +15,7 @@ all: $(DUMP_MIPS) --disassemble test.axf > test.lst $(COPY_MIPS) -O verilog -R .text test.axf data.vh $(COPY_MIPS) -O verilog -R .data test.axf text.vh - $(CONVERT_TEXT) - $(CONVERT_DATA) + $(CONVERT) clean: rm -f *.o diff --git a/sw/convert.py b/sw/convert.py new file mode 100644 index 0000000..c96b83c --- /dev/null +++ b/sw/convert.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri Dec 04 13:10:20 2015 + +@author: bayevskihk +""" + +import sys + +def main(argv): + number = len(argv) + data_addr = 0 + last_addr = 0 + + if(number != 2): + return + else: + try: + data_addr = int(argv[0]) + last_addr = int(argv[1]) + except: + print "Wrong arguments" + return + + if(parse("text.vh", "text.rom", data_addr) < 0): + print "Wrong text file" + return + + if(parse("data.vh", "data.rom", last_addr - data_addr) < 0): + print "Wrong text file" + return + + print "Convertion was successfull" + + +def parse(file_name, rom_name, addr_last): + hex_file = open(file_name, 'r') + rom_file = open(rom_name, 'w') + rom_file.truncate() + + hex_parts = hex_file.readline() + + try: + hex_parts.index("@") + except: + return -1 + + attached = 0 + words = 0 + + rom_file.writelines("@00000000\n"); + + while(1): + hex_parts = hex_file.readline() + hex_parts = hex_parts.split(" "); + + if(len(hex_parts) == 1): + break + + for part in hex_parts: + + if(part == "\n"): + continue + + rom_file.write(part) + attached += 1 + + if(attached == 4): + attached = 0 + words += 1 + rom_file.write("\n") + + for i in range(addr_last - words): + rom_file.write("00000000\n") + + rom_file.close() + + return 0 + +if __name__ == '__main__': + main(sys.argv[1:]) +
\ No newline at end of file diff --git a/sw/test.asm b/sw/test.asm index 63ce753..eac3c7e 100644 --- a/sw/test.asm +++ b/sw/test.asm @@ -8,11 +8,8 @@ .ent entry entry: lw $t0, 0x200 /* t0 = 1*/ - sw $t0, 0x400 - lw $t1, 0x201 /* t1 = 1*/ - lw $t1, 0x200 /* t0 = 1*/ - add $t0, $t0, $t1 /* t0 = t0 + t1 = 2*/ - sw $t0, 0x400 + lw $t1, 0x201 /* t1 = 1*/ + add $t0, $t0, $t1 /* t0 = t0 + t1 = 2*/ add $t0, $t0, 0xB /* t0 = t0 + 0xB == 0xD*/ sub $t0, $t0, $t1 /* t0 = t0 - $t1 == 0xC*/ or $t0, $t0, 0x10 /* t0 = t0 | 0x10 == 0x1C*/ |