Great! Let’s walk through a concrete example of a student submission workflow using a GitHub assignment repository. I’ll lay it out step by step and illustrate folder usage and branches.
1. Repository Structure
Suppose the instructor creates an assignment repo like this:
ACOT-Assignment1/
├── README.md # Assignment instructions
├── exercise/ # Starter code for the student
│ ├── main.c
│ └── utils.c
├── tests/ # Automated test scripts
│ └── test_main.sh
├── reference/ # Instructor reference solutions
│ ├── main.c
│ └── utils.c
└── docs/ # Additional guidance or resources
Key Points:
-
Students work in
exercise/. -
tests/can be run locally to verify solutions. -
reference/is usually hidden from students until grading.
2. Student Workflow
Step 1: Clone the repository
git clone https://github.com/ACOT-Classroom/ACOT-Assignment1.git
cd ACOT-Assignment1
Step 2: Create a working branch
git checkout -b my_solution
-
Keeps the
mainbranch clean. -
Helps instructors track submissions per student branch.
Step 3: Implement the solution
-
Edit files in
exercise/(e.g.,main.c). -
Write new functions or modify starter code.
Step 4: Run tests locally
./tests/test_main.sh
-
Verify correctness before committing.
Step 5: Commit changes
git add exercise/main.c exercise/utils.c
git commit -m "Completed Assignment 1"
Step 6: Push to GitHub
git push origin my_solution
3. Instructor/Auto-Grading Workflow
-
Instructor sees all student branches in the repo.
-
Pulls each branch to run tests automatically:
git fetch origin
git checkout student_branch
./tests/test_main.sh
-
Grades are recorded, and feedback may be added as comments.
4. Optional: Using GitHub Classroom Automation
-
GitHub Classroom can auto-create individual assignment repos for each student.
-
Starter code, tests, and instructions are preloaded.
-
Students only push to their own private repo, avoiding conflicts.
-
CI/CD pipelines can automatically run tests and give instant feedback.
✅ Summary:
-
Assignment repos separate exercise, tests, and reference solutions.
-
Students work in their branch or fork.
-
Instructor can track submissions and run automated grading efficiently.
If you want, I can draw a visual diagram showing the relationship between the instructor repo, student forks, branches, and CI tests—it makes the workflow much easier to grasp.
Do you want me to do that?
1. RISC-V Assembly: Fibonacci (Iterative)
# fib_riscv.s
# Compute the first N Fibonacci numbers
# Store them in an array in memory
# Input: a0 = N (number of Fibonacci numbers)
# Output: array in memory at fib_array
.data
fib_array: .space 400 # Reserve space for 100 integers (4 bytes each)
.text
.globl _start
_start:
li t0, 0 # t0 = index i
li t1, 0 # t1 = fib[0]
li t2, 1 # t2 = fib[1]
la t3, fib_array # t3 = pointer to array
mv t4, a0 # t4 = N
fib_loop:
beq t0, zero, first0 # store fib[0]
beq t0, 1, first1 # store fib[1]
# fib[i] = fib[i-1] + fib[i-2]
add t5, t1, t2
sw t5, 0(t3) # store in array
mv t1, t2
mv t2, t5
addi t3, t3, 4
addi t0, t0, 1
blt t0, t4, fib_loop
j done
first0:
sw t1, 0(t3)
addi t3, t3, 4
addi t0, t0, 1
j fib_loop
first1:
sw t2, 0(t3)
addi t3, t3, 4
addi t0, t0, 1
j fib_loop
done:
# Exit program (for simulators like Spike)
li a7, 10
ecall
2. Assignment Repository Structure
Here’s an example GitHub assignment repo for this Fibonacci assignment:
Fibonacci-Assignment/
├── README.md
├── exercise/
│ └── fib_riscv.s # Starter file for student
├── tests/
│ └── test_fib.sh # Script to run the program and check output
├── reference/
│ └── fib_riscv.s # Instructor solution
└── docs/
└── RISCV-setup.md # Instructions for compiling and running
README.md Example
# Fibonacci Sequence Assignment
## Objective
Write a RISC-V assembly program to compute the first N Fibonacci numbers and store them in memory.
## Instructions
- Use the `exercise/fib_riscv.s` file as your working file.
- Implement the iterative Fibonacci algorithm.
- Use `tests/test_fib.sh` to verify your program.
## Submission
- Commit your solution to a branch called `my_solution`.
- Push your branch to GitHub.
3. Student Workflow Example
git clone https://github.com/ACOT-Classroom/Fibonacci-Assignment.git
cd Fibonacci-Assignment
git checkout -b my_solution
# Edit exercise/fib_riscv.s
# Run tests
./tests/test_fib.sh
# Commit and push
git add exercise/fib_riscv.s
git commit -m "Completed Fibonacci assignment"
git push origin my_solution
I can also write a ready-to-run test_fib.sh script that simulates and checks the Fibonacci sequence automatically in Spike or Venus if you want.
Do you want me to do that?
あなた:
ChatGPT:
Perfect! Here’s an example of a test_fib.sh script for a RISC-V assignment repo. This will assemble, run, and check the Fibonacci program automatically.
tests/test_fib.sh
#!/bin/bash
# Test script for Fibonacci RISC-V assignment
# Check if N is provided
N=${1:-10} # default: compute first 10 Fibonacci numbers
# Paths
EXERCISE_FILE="../exercise/fib_riscv.s"
OUTPUT_FILE="fib_output.txt"
# Compile the RISC-V assembly (assuming riscv64-unknown-elf-gcc + spike)
riscv64-unknown-elf-as $EXERCISE_FILE -o fib.o
riscv64-unknown-elf-ld fib.o -o fib.elf
if [ $? -ne 0 ]; then
echo "Compilation failed!"
exit 1
fi
# Run on Spike simulator
# This assumes your program prints Fibonacci numbers using ecall 1 (print int)
spike pk fib.elf > $OUTPUT_FILE
# Reference Fibonacci (Python)
ref_fib=$(python3 -c "
N=$N
a,b=0,1
res=[]
for _ in range(N):
res.append(str(a))
a,b=b,a+b
print(' '.join(res))
")
# Capture student's output (space-separated numbers)
student_output=$(cat $OUTPUT_FILE | tr '\n' ' ' | sed 's/ $//')
# Compare
if [ "$student_output" == "$ref_fib" ]; then
echo "✅ Test passed! Output is correct."
else
echo "❌ Test failed!"
echo "Expected: $ref_fib"
echo "Got: $student_output"
fi
Notes:
-
This script assumes:
-
Spike simulator is installed.
-
The student program uses
ecallto print Fibonacci numbers. If not, the script can be adapted to read memory instead.
-
-
Default N = 10 can be changed:
./tests/test_fib.sh 15
-
The script compares student output with reference Python Fibonacci output.
If you want, I can update the RISC-V assembly code so it prints Fibonacci numbers automatically so that this test_fib.sh works perfectly out of the box.
Do you want me to do that?