-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f7a0fe4
Showing
7 changed files
with
6,894 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
 | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.