#!/bin/bash
|
#!/bin/bash
|
#
|
#
|
# Compile a test for the M1 and build the memory.hex file.
|
# Compile a test for the M1 and build the memory.hex file.
|
#
|
#
|
# Parameter is test name without extension (e.g. to compile
|
# Parameter is test name without extension (e.g. to compile
|
# $M1_ROOT/tests/hello.c) run "compile_test hello".
|
# $M1_ROOT/tests/hello.c) run "compile_test hello".
|
#
|
#
|
# Requires mipsel-linux-gcc (see Download section on srisc.com).
|
# Requires mipsel-linux-gcc (see Download section on srisc.com).
|
|
|
if [ -z "$M1_ROOT" ]; then echo "***ERROR***: M1_ROOT variable is undefined, please set it and run 'source sourceme'."; exit 1; fi
|
if [ -z "$M1_ROOT" ]; then echo "***ERROR***: M1_ROOT variable is undefined, please set it and run 'source sourceme'."; exit 1; fi
|
if ! [ -d "$M1_ROOT" ]; then echo "***ERROR***: directory '$M1_ROOT' does not exist, please check it and run 'source sourceme' again."; exit 1; fi
|
if ! [ -d "$M1_ROOT" ]; then echo "***ERROR***: directory '$M1_ROOT' does not exist, please check it and run 'source sourceme' again."; exit 1; fi
|
|
|
cd $M1_ROOT/tests
|
cd $M1_ROOT/tests
|
rm -f *.o *~ *.bin # Make clean
|
rm -f *.o *~ *.bin # Make clean
|
if ( test $# != 1 ) then
|
if ( test $# != 1 ) then
|
echo ""
|
echo ""
|
echo "compile_test - Script to compile a test for the M1 Core"
|
echo "compile_test - Script to compile a test for the M1 Core"
|
echo ""
|
echo ""
|
echo "(C)2008 Simply RISC"
|
echo "(C)2008 Simply RISC"
|
echo ""
|
echo ""
|
echo "Usage:"
|
echo "Usage:"
|
echo ""
|
echo ""
|
echo " compile_test "
|
echo " compile_test "
|
echo ""
|
echo ""
|
echo "where parameter is the test name without extension (e.g. 'hello')."
|
echo "where parameter is the test name without extension (e.g. 'hello')."
|
echo ""
|
echo ""
|
exit 1
|
exit 1
|
fi
|
fi
|
if ( ! test -e $1.c ) then
|
if ( ! test -e $1.c ) then
|
echo "ERROR: Test $1.c does not exist into the tests directory!"
|
echo "ERROR: Test $1.c does not exist into the tests directory!"
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
mipsel-linux-gcc -c -O0 -msoft-float -mips1 $M1_ROOT/tests/boot/boot.s
|
mipsel-linux-gcc -c -O0 -msoft-float -mips1 $M1_ROOT/tests/boot/boot.s
|
mipsel-linux-gcc -c -O0 -msoft-float -mips1 $1.c
|
mipsel-linux-gcc -c -O0 -msoft-float -mips1 $1.c
|
mipsel-linux-ld -Ur -EL -O0 -G 0 -o $1.bin boot.o $1.o
|
mipsel-linux-ld -Ur -EL -O0 -G 0 -o $1.bin boot.o $1.o
|
mipsel-linux-objdump -d -EL -w -z --disassembler-options=no-aliases,reg-names=numeric $1.bin > $1.dump
|
mipsel-linux-objdump -d -EL -w -z --disassembler-options=no-aliases,reg-names=numeric $1.bin > $1.dump
|
cat $1.dump | dump2vlog.php -q > $M1_ROOT/hdl/rtl/m1_core/m1_mmu_initial.vh
|
cat $1.dump | dump2vlog.php -q > $M1_ROOT/hdl/rtl/m1_core/m1_mmu_initial.vh
|
|
|
echo "The initial content of the instruction memory has been updated successfully!"
|
echo "The initial content of the instruction memory has been updated successfully!"
|
echo "Now you should run 'build_icarus' script again."
|
echo "Now you should run 'build_icarus' script again."
|
|
|
rm -f *.o *~ *.bin # Make clean
|
rm -f *.o *~ *.bin # Make clean
|
|
|
|
|