Skip to content

Commit 8ada228

Browse files
committed
Added everything
1 parent 023256f commit 8ada228

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6604
-3
lines changed

README.md

+52-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
1-
fpg8
2-
====
1+
# FPG-8
2+
FPG-8 is an implementation of Chip-8/S-Chip language for FPGAs using Verilog.
33

4-
Chip-8/S-Chip implementation in Verilog
4+
It was developed as a project for the [ECE-574] course at [Worcester Polytechnic Institute].
5+
6+
It definitelly is not the fastest or more optimized implementation, but it works pretty well.
7+
8+
It was written for the [Nexys 3] board, but should work well on other boards.
9+
10+
All the interaction with the system is done through the USB serial port and the game output is shown on a VGA display. Sound is generated using the [Digilent DA1 Module] connected to pins 1-6 of the PmodA port of the Nexys 3.
11+
12+
### Binaries
13+
If you don't care about all the nerdy stuff in the following sections, you can simply download the [binaries]. The binary distribution contains the Java application compiled in a JAR file and a bit file to program your board using, for example, [Adept].
14+
15+
### Verilog and C code
16+
The complete Verilog code is available under the **verilog** folder. It was developed using the ISE tools from Xilinx. It uses some cores from the IP Core Generator, specially the [Microblaze] microcontroller that handles the serial communication.
17+
18+
The Microblaze is programmed in C and the source is available under the **c** folder. [Here]'s an excelent tutorial about how to merge the C code into the bit file before programming the FPGA.
19+
20+
### Java code
21+
It's impossible to play games typing commands to a serial port, so I wrote a Java application that uses the serial port to load the games, capture user input and also control the debugger. The complete code is under the **java** folder. It uses Maven to handle dependencies, except for the [SteelCheckbox], that is not available on the Maven Repository.
22+
23+
The application searches for games under the **games** folder on the application's directory. Games are stored in a ZIP file containing a `rom.ch8` file that is the Chip-8 ROM, a `logo.png` file that contains a 80x80 picture that is shown on the menu on the left, a `screenshot.png` file that contains a 510x253 picture that is shown on the center when the came is selected and a `description.json` file that contains some information about the game in [JSON] format. The `slowdown` should not be greater than 65535, because it's a 16-bit number. The `mapping` parameter maps the Chip-8 keyboard to your keyboard. Any letter is valid and also the special values `arrow-up`, `arrow-down`, `arrow-left`, `arrow-right`, `ctrl`, `alt`, `shift`, `enter` and `space`.
24+
25+
After days of Verilog development, I really wanted to play some games, so this application was written very fastly. It can't handle board disconnections, permission errors or any other thing your evil mind can think of.
26+
27+
### ASM code
28+
I included the source for a simple application I wrote to test some opcodes of my implementation. It's available under the **asm** folder. It can be assembled by the [Mochi8 Assembler].
29+
30+
There is also a program that writes "Thank You!" on the screen, that I used in the end of the project presentation.
31+
32+
### Docs
33+
Under the **docs** folder there are the slides I used for the presentation of this project.
34+
35+
In a few days I'll upload the report that describes the implementation and can also be used as a complete documentation for the Chip-8/S-Chip language.
36+
37+
### Miscelaneous
38+
Under the **misc** folder you can find a OpenOffice Calc spreadsheet that I created to help me drawing the font for the "Thank You" program.
39+
40+
### Acknowledgements
41+
I'd like to thank **Professor R. James Duckworth** for the great VHDL/Verilog course and the opportunity to develop this project and **Boyang Li** for being a great TA.
42+
43+
[binaries]: https://github.com/guimeira/fpg8/releases
44+
[Adept]: http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,69&Prod=ADEPT&CFID=6114451&CFTOKEN=b4315c79c33731b4-0CDF65D2-5056-0201-0284F3BE6330CA60
45+
[ECE-574]: http://ece.wpi.edu/~rjduck/ece574.htm
46+
[Worcester Polytechnic Institute]: http://www.wpi.edu
47+
[Nexys 3]: http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,400,897&Prod=NEXYS3
48+
[Digilent DA1 Module]: http://www.digilentinc.com/Products/Detail.cfm?Prod=PMOD-DA1
49+
[Microblaze]: http://www.xilinx.com/tools/microblaze.htm
50+
[Here]: http://ece.wpi.edu/~rjduck/Microblaze%20MCS%20Tutorial%20v5.pdf
51+
[SteelCheckbox]: http://harmoniccode.blogspot.com/2010/11/friday-fun-component-iii.html
52+
[JSON]: http://json.org/
53+
[Mochi8 Assembler]: http://mochi8.weebly.com/

asm/testfixture.asm

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
;This program is written in the Chip-8 assembly language and is used to test ;
3+
;the Verilog implementation through a test fixture. ;
4+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5+
6+
;==Test the clear screen function==
7+
CLS
8+
9+
;==Test the function calls, jumps and returns==
10+
CALL TEST_CALL
11+
JP TEST_JMP
12+
JMP_RETURN: JP CONTINUE_TEST
13+
14+
TEST_CALL: RET
15+
16+
TEST_JMP: JP JMP_RETURN
17+
18+
CONTINUE_TEST:
19+
;==Test skip functions==
20+
LD V1,10
21+
SE V1,10
22+
LD V2,5 ;should be skipped
23+
SE V1,20
24+
LD V2,50 ;should be executed
25+
SNE V2,0
26+
LD V3,4 ;should be skipped
27+
SNE V2,50
28+
LD V3,65 ;should be executed
29+
LD V8,0
30+
LD V9,0
31+
SE V8,V9
32+
LD V8,29 ;should be skipped
33+
SE V8,V1
34+
LD V8,10 ;should be executed
35+
SNE V8,V1
36+
LD V8,23 ;should be skipped
37+
SNE V8,V1
38+
LD V8,90 ;should be executed
39+
40+
;==Test arithmetic==
41+
LD V1,0
42+
ADD V1,209
43+
LD V2,53
44+
OR V1,V2
45+
AND V1,V2
46+
XOR V1,V2
47+
LD V1,50
48+
LD V2,60
49+
ADD V1,V2 ;add without carry
50+
LD V1,200
51+
LD V2,100
52+
ADD V1,V2 ;add with carry
53+
LD V1,100
54+
LD V2,40
55+
SUB V1,V2 ;sub without borrow
56+
LD V1,40
57+
LD V2,100
58+
SUB V2,V1 ;sub with borrow
59+
LD V1,100
60+
LD V2,40
61+
SUBN V1,V2 ;subn with borrow
62+
LD V1,40
63+
LD V2,100
64+
SUBN V1,V2 ;subn without borrow
65+
LD V1,2
66+
SHR V1
67+
SHR V1
68+
SHL V1
69+
SHL V1
70+
71+
;==Test data transfer between regs==
72+
LD V1,100
73+
LD V0,20
74+
LD V1,V0
75+
LD I,123
76+
ADD I,V1
77+
LD V1,5
78+
LD F,V1
79+
80+
;==Test data transfer to memory and BCD function==
81+
LD V1,200
82+
LD I,200
83+
ADD I,V1
84+
LD V1,124
85+
LD B,V1
86+
LD V2,[I] ;read BCD results to V0,V1,V2
87+
LD [I],VF ;store all registers
88+
LD V0,0
89+
LD V1,0
90+
LD V2,0
91+
LD V3,0
92+
LD V4,0
93+
LD V5,0
94+
LD V6,0
95+
LD V7,0
96+
LD V8,0
97+
LD V9,0
98+
LD VA,0
99+
LD VB,0
100+
LD VC,0
101+
LD VD,0
102+
LD VE,0
103+
LD VF,0
104+
LD VF,[I] ;restore all registers from memory
105+
106+
;==Invoke screen scrolling functions==
107+
SCD 3
108+
SCR
109+
SCL
110+
111+
;==Change screen mode==
112+
HIGH
113+
LOW
114+
115+
;==Exit==
116+
EXT

asm/thankyou.asm

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
;This little program writes "thank you" on the screen.
2+
3+
HIGH
4+
LD V0,24
5+
LD V1,16
6+
LD I,LETTER_T
7+
DRW V0,V1,0
8+
ADD V0,16
9+
10+
LD I,LETTER_H
11+
DRW V0,V1,0
12+
ADD V0,16
13+
14+
LD I,LETTER_A
15+
DRW V0,V1,0
16+
ADD V0,16
17+
18+
LD I,LETTER_N
19+
DRW V0,V1,0
20+
ADD V0,16
21+
22+
LD I,LETTER_K
23+
DRW V0,V1,0
24+
ADD V0,16
25+
26+
ADD V1,20
27+
LD V0,32
28+
29+
LD I,LETTER_Y
30+
DRW V0,V1,0
31+
ADD V0,16
32+
33+
LD I,LETTER_O
34+
DRW V0,V1,0
35+
ADD V0,16
36+
37+
LD I,LETTER_U
38+
DRW V0,V1,0
39+
ADD V0,16
40+
41+
LD I,EXCLAMATION_POINT
42+
DRW V0,V1,0
43+
ADD V0,16
44+
45+
LOOP: JP LOOP
46+
47+
LETTER_T:
48+
DB $01111111, $11111110
49+
DB $01111111, $11111110
50+
DB $01100011, $11000110
51+
DB $01000011, $11000010
52+
DB $00000011, $11000000
53+
DB $00000011, $11000000
54+
DB $00000011, $11000000
55+
DB $00000011, $11000000
56+
DB $00000011, $11000000
57+
DB $00000011, $11000000
58+
DB $00000011, $11000000
59+
DB $00000011, $11000000
60+
DB $00000011, $11000000
61+
DB $00000011, $11000000
62+
DB $00000011, $11000000
63+
DB $00001111, $11110000
64+
65+
LETTER_H:
66+
DB $01111100, $00111110
67+
DB $00111000, $00011100
68+
DB $00111000, $00011100
69+
DB $00111000, $00011100
70+
DB $00111000, $00011100
71+
DB $00111000, $00011100
72+
DB $00111111, $11111100
73+
DB $00111111, $11111100
74+
DB $00111111, $11111100
75+
DB $00111000, $00011100
76+
DB $00111000, $00011100
77+
DB $00111000, $00011100
78+
DB $00111000, $00011100
79+
DB $00111000, $00011100
80+
DB $00111000, $00011100
81+
DB $01111100, $00111110
82+
83+
LETTER_A:
84+
DB $00000011, $11000000
85+
DB $00000111, $11100000
86+
DB $00001110, $01110000
87+
DB $00011100, $00111000
88+
DB $00111000, $00011100
89+
DB $00111000, $00011100
90+
DB $00111000, $00011100
91+
DB $00111000, $00011100
92+
DB $00111111, $11111100
93+
DB $00111111, $11111100
94+
DB $00111000, $00011100
95+
DB $00111000, $00011100
96+
DB $00111000, $00011100
97+
DB $00111000, $00011100
98+
DB $00111000, $00011100
99+
DB $01111100, $00111110
100+
101+
LETTER_N:
102+
DB $01111000, $00111110
103+
DB $00111000, $00011100
104+
DB $00111100, $00011100
105+
DB $00111110, $00011100
106+
DB $00111110, $00011100
107+
DB $00111011, $00011100
108+
DB $00111011, $00011100
109+
DB $00111001, $10011100
110+
DB $00111001, $10011100
111+
DB $00111000, $11011100
112+
DB $00111000, $11011100
113+
DB $00111000, $01111100
114+
DB $00111000, $01111100
115+
DB $00111000, $00111100
116+
DB $00111000, $00111100
117+
DB $01111100, $00011110
118+
119+
LETTER_K:
120+
DB $01111100, $00011110
121+
DB $00111000, $00001100
122+
DB $00111000, $00011100
123+
DB $00111000, $00111000
124+
DB $00111000, $01110000
125+
DB $00111000, $11100000
126+
DB $00111011, $11000000
127+
DB $00111111, $10000000
128+
DB $00111111, $00000000
129+
DB $00111111, $10000000
130+
DB $00111011, $11000000
131+
DB $00111000, $11100000
132+
DB $00111000, $01110000
133+
DB $00111000, $00111000
134+
DB $00111000, $00011000
135+
DB $01111100, $00111100
136+
137+
LETTER_Y:
138+
DB $01111100, $00111110
139+
DB $00111000, $00011100
140+
DB $00111000, $00011100
141+
DB $00111000, $00011100
142+
DB $00111000, $00011100
143+
DB $00011100, $00111000
144+
DB $00001110, $01110000
145+
DB $00000111, $11100000
146+
DB $00000011, $11000000
147+
DB $00000011, $11000000
148+
DB $00000011, $11000000
149+
DB $00000011, $11000000
150+
DB $00000011, $11000000
151+
DB $00000011, $11000000
152+
DB $00000011, $11000000
153+
DB $00000111, $11100000
154+
155+
LETTER_O:
156+
DB $00000011, $11000000
157+
DB $00001111, $11110000
158+
DB $00111111, $11111100
159+
DB $01111000, $00011110
160+
DB $01110000, $00001110
161+
DB $01110000, $00001110
162+
DB $01110000, $00001110
163+
DB $01110000, $00001110
164+
DB $01110000, $00001110
165+
DB $01110000, $00001110
166+
DB $01110000, $00001110
167+
DB $01110000, $00001110
168+
DB $01111000, $00011110
169+
DB $00111111, $11111100
170+
DB $00001111, $11110000
171+
DB $00000011, $11000000
172+
173+
LETTER_U:
174+
DB $01111100, $00111110
175+
DB $00111000, $00011100
176+
DB $00111000, $00011100
177+
DB $00111000, $00011100
178+
DB $00111000, $00011100
179+
DB $00111000, $00011100
180+
DB $00111000, $00011100
181+
DB $00111000, $00011100
182+
DB $00111000, $00011100
183+
DB $00111000, $00011100
184+
DB $00111000, $00011100
185+
DB $00111000, $00011100
186+
DB $00111000, $00011100
187+
DB $00011100, $00111000
188+
DB $00001111, $11110000
189+
DB $00000111, $11100000
190+
191+
EXCLAMATION_POINT:
192+
DB $00000011, $11000000
193+
DB $00000111, $11100000
194+
DB $00001111, $11110000
195+
DB $00011111, $11111000
196+
DB $00001111, $11110000
197+
DB $00001111, $11110000
198+
DB $00000111, $11100000
199+
DB $00000111, $11100000
200+
DB $00000011, $11000000
201+
DB $00000011, $11000000
202+
DB $00000001, $10000000
203+
DB $00000001, $10000000
204+
DB $00000000, $00000000
205+
DB $00000001, $10000000
206+
DB $00000011, $11000000
207+
DB $00000001, $10000000

0 commit comments

Comments
 (0)