diff --git a/README.md b/README.md index 7db4f79..691d591 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ learning, I want the source code commentary to be as educational as possible. Special thanks to [Georg Sauthoff](https://gms.tf/riscv-vector.html) whose writing really helped me begin this exercise! +Special thanks also to [Hanna Kruppe](https://github.com/hanna-kruppe) who took the time to read through the source code and counsel me on the RISC-V ISA vector extension. + ## Running As of this writing, the Vector ISA is not standardized so you will need an @@ -36,6 +38,10 @@ Execute the `build-caesar.sh` script. Execute the `run-caesar.sh` script. +## Debugging + +Execute the `debug-caesar.sh` script. + ## Comments/Issues Please submit comments and bug reports using Github Issues. Remember, this diff --git a/caesar.S b/caesar.S index 76f63f9..24a2308 100644 --- a/caesar.S +++ b/caesar.S @@ -92,14 +92,19 @@ main: # 4. Set t0 to min(a1, VLEN/SEW). vsetvli t0, a1, e8, m1 - # load t0 bytes (bytes are SEW bits in this case) of plaintext into v0 + # At this point t0 and vl are equal. vl is the control register that + # tells the vector processor how many elements are in each vector + # register. + + # load vl (aka t0) bytes (bytes are SEW bits in this case) of plaintext + # into v0 vlbu.v v0, (a4) - # load t0 bytes of key into 1th vector. This is safe because there are - # 4 bytes of key and t0 is never more than 4. + # load vl (aka t0) bytes of key into 1th vector. This is safe because + # there are 4 bytes of key and t0 is never more than 4. vlbu.v v1, (a5) - # encrypt t0 bytes + # encrypt vl (aka t0) bytes vadd.vv v0, v0, v1 - # store t0 bytes of encrypted text into memory + # store vl (aka t0) bytes of encrypted text into memory vsb.v v0, (a3) # plaintext -= slurped_amt diff --git a/debug-caesar.sh b/debug-caesar.sh new file mode 100755 index 0000000..7b0280e --- /dev/null +++ b/debug-caesar.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source directories.sh + +# Debug the Caesar Cipher application using Spike and PK +$SPIKE_INSTALL_DIR/bin/spike -d --isa=RV64gcV $PK_INSTALL_DIR/riscv64-unknown-elf/bin/pk caesar.out + +# Debug Spike as it emulates PK running the Caesar Cipher application +#gdb --args $SPIKE_INSTALL_DIR/bin/spike -d --isa=RV64gcV $PK_INSTALL_DIR/riscv64-unknown-elf/bin/pk caesar.out diff --git a/run-caesar.sh b/run-caesar.sh index e674d4c..38eb68c 100755 --- a/run-caesar.sh +++ b/run-caesar.sh @@ -4,9 +4,3 @@ source directories.sh # Emulate the Caesar Cipher application using Spike and PK $SPIKE_INSTALL_DIR/bin/spike --isa=RV64gcV $PK_INSTALL_DIR/riscv64-unknown-elf/bin/pk caesar.out - -# Debug the Caesar Cipher application using Spike and PK -#$SPIKE_INSTALL_DIR/bin/spike -d --isa=RV64gcV $PK_INSTALL_DIR/riscv64-unknown-elf/bin/pk caesar.out - -# Debug Spike as it emulates PK running the Caesar Cipher application -#gdb --args $SPIKE_INSTALL_DIR/bin/spike -d --isa=RV64gcV $PK_INSTALL_DIR/riscv64-unknown-elf/bin/pk caesar.out