Skip to content

Commit 4fe069e

Browse files
working pong
1 parent d27654c commit 4fe069e

File tree

3 files changed

+450
-10
lines changed

3 files changed

+450
-10
lines changed

RISC-V-Scaffold-Basys3/RISC-V-Scaffold-Basys3.xpr

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- Copyright 1986-2022 Xilinx, Inc. All Rights Reserved. -->
55
<!-- Copyright 2022-2025 Advanced Micro Devices, Inc. All Rights Reserved. -->
66

7-
<Project Product="Vivado" Version="7" Minor="71" Path="/home/arya/Documents/Github/RISC-V/RISC-V-Scaffold-Basys3/RISC-V-Scaffold-Basys3.xpr">
7+
<Project Product="Vivado" Version="7" Minor="71" Path="C:/Users/outer/OneDrive/Desktop/RISC-V/RISC-V-Scaffold-Basys3/RISC-V-Scaffold-Basys3.xpr">
88
<DefaultLaunch Dir="$PRUNDIR"/>
99
<Configuration>
1010
<Option Name="Id" Val="5ccae5db352846dd96f73584352a58b3"/>
@@ -260,15 +260,12 @@
260260
<Simulator Name="Questa">
261261
<Option Name="Description" Val="Questa Advanced Simulator"/>
262262
</Simulator>
263-
<Simulator Name="Xcelium">
264-
<Option Name="Description" Val="Xcelium Parallel Simulator"/>
265-
</Simulator>
266-
<Simulator Name="VCS">
267-
<Option Name="Description" Val="Verilog Compiler Simulator (VCS)"/>
268-
</Simulator>
269263
<Simulator Name="Riviera">
270264
<Option Name="Description" Val="Riviera-PRO Simulator"/>
271265
</Simulator>
266+
<Simulator Name="ActiveHDL">
267+
<Option Name="Description" Val="Active-HDL Simulator"/>
268+
</Simulator>
272269
</Simulators>
273270
<Runs Version="1" Minor="22">
274271
<Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" AutoIncrementalCheckpoint="true" IncrementalCheckpoint="$PSRCDIR/utils_1/imports/synth_1/Top.dcp" WriteIncrSynthDcp="false" State="current" Dir="$PRUNDIR/synth_1" IncludeInArchive="true" IsChild="false" AutoIncrementalDir="$PSRCDIR/utils_1/imports/synth_1" AutoRQSDir="$PSRCDIR/utils_1/imports/synth_1" ParallelReportGen="true">

programs/hello.c

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ __attribute__((naked)) void _start(void) {
77

88
int main() {
99
volatile unsigned char* frame = (volatile unsigned char*)0x0;
10+
volatile unsigned char* btns = (volatile unsigned char*)0x4B000000;
11+
12+
int paddY1 = 120;
13+
int paddY2 = 120;
14+
1015
int ballX = 160;
1116
int ballY = 120;
1217
int dX = 1;
@@ -26,6 +31,34 @@ int main() {
2631
}
2732
}
2833

34+
for (int x = -2; x <= 2; x++) {
35+
for (int y = -20; y <= 20; y++) {
36+
frame[0x4000 * (320 * (paddY1 + y) + 20 + x)] = 0x00;
37+
}
38+
}
39+
40+
for (int x = -2; x <= 2; x++) {
41+
for (int y = -20; y <= 20; y++) {
42+
frame[0x4000 * (320 * (paddY2 + y) + 299 + x)] = 0x00;
43+
}
44+
}
45+
46+
if (*btns & 0b0001 && paddY1 < 239 - 21) {
47+
paddY1 += 1;
48+
}
49+
50+
if (*btns & 0b0010 && paddY1 > 21) {
51+
paddY1 -= 1;
52+
}
53+
54+
if (*btns & 0b0100 && paddY2 < 239 - 21) {
55+
paddY2 += 1;
56+
}
57+
58+
if (*btns & 0b1000 && paddY2 > 21) {
59+
paddY2 -= 1;
60+
}
61+
2962
ballX += dX;
3063
ballY += dY;
3164

@@ -45,13 +78,33 @@ int main() {
4578
dY = 1;
4679
}
4780

81+
if (ballX <= 25 && ballX >= 15 && ballY <= paddY1 + 25 && ballY >= paddY1 - 25) {
82+
dX = 1;
83+
}
84+
85+
if (ballX <= 304 && ballX >= 294 && ballY <= paddY2 + 25 && ballY >= paddY2 - 25) {
86+
dX = -1;
87+
}
88+
4889
for (int x = -2; x <= 2; x++) {
4990
for (int y = -2; y <= 2; y++) {
5091
frame[0x4000 * (320 * (ballY + y) + ballX + x)] = 0xFF;
5192
}
5293
}
5394

54-
for (int i = 0; i < 4000; i++) {
95+
for (int x = -2; x <= 2; x++) {
96+
for (int y = -20; y <= 20; y++) {
97+
frame[0x4000 * (320 * (paddY1 + y) + 20 + x)] = 0x03;
98+
}
99+
}
100+
101+
for (int x = -2; x <= 2; x++) {
102+
for (int y = -20; y <= 20; y++) {
103+
frame[0x4000 * (320 * (paddY2 + y) + 299 + x)] = 0xE0;
104+
}
105+
}
106+
107+
for (int i = 0; i < 8000; i++) {
55108
__asm__("nop");
56109
}
57110
}

0 commit comments

Comments
 (0)