Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowyCoder committed Jan 12, 2021
0 parents commit f7a0fe4
Show file tree
Hide file tree
Showing 7 changed files with 6,894 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Pong RISCV
A (very) simple 32-bit RISCV processor with a loaded Pong game to show it off
![Video of processor in function](pong_riscv.gif)

This has been done for the exam "Architettura dei Calcolatori" at UniMoRe.

### Notes
Even if the GIF is slowed down the circuit isn't optimized, and it seems to run
at ~100Hz on my computer.

To create the code to load in the logisim ROM you can use the script `compile_program.sh`, you need to have
[RARS](https://github.com/TheThirdOne/rars) installed for it to work.
16 changes: 16 additions & 0 deletions compile_program.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if (( $# < 2 )); then
echo "Usage ./compile.sh <file> <output>"
exit 1
fi

tmp=".tmpcompilefile_plsdontuseme.hex"

rars a dump .text HexText "$tmp" "$1"

echo "v2.0 raw" > "$2"
cat "$tmp" >> "$2"

rm "$tmp"

43 changes: 43 additions & 0 deletions imgcvt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@


import PIL
from PIL import Image
from bitstring import BitString

# CLI
import climax


def bitlist_parse(bits):
res = BitString(bits)
for x in bits:
res <<= 1
res += bits[x]
return res



def print_img(path):
image = Image.open("logo.png")

data = image.getdata()

pixels = data.pixel_access()
binimg = [BitString([pixels[x, y][0] == 0 for x in range(32)]) for y in range(32)]

for index, row in enumerate(binimg):
if row.all(False):
print('\tsw\tzero,{}(x3)'.format(index * 4))
else:
print('\tli\tt0,0x{}'.format(row.hex))
print('\tsw\tt0,{}(x3)'.format(index * 4))


@climax.command()
@climax.argument('path', type=str, help='Path to the image file')
def main(path):
print_img(path)


if __name__ == '__main__':
main()
Loading

0 comments on commit f7a0fe4

Please sign in to comment.