HARDWARE

- Open a terminal. Change the directory to the RTL folder. 

- Add the following to joypad_hw.tcl if it isn't already there:

set_module_assignment embeddedsw.dts.vendor "csee4840"
set_module_assignment embeddedsw.dts.name "joypad"
set_module_assignment embeddedsw.dts.group "game_boy"

- Run the following commands in order:

make qsys
make quartus
make rbf
embedded_command_shell.sh
make dtb

- At this point, you may get several "ERROR (phandle_references): Reference to non-existent node or label Main_PLL". Add the following to the soc_system.dts file under the "clocks" node (e.g. line 43):

Main_PLL: Main_PLL {
	compatible = "fixed-clock";
	#clock-cells = <0>;
	clock_frequency = <0>;	/* 0 Hz */
	clock-output-names = "Main_PLL-clk";
};

- In reality, the Main_PLL is not used by Linux, so the clock frequency is not important. This just prevents "make dtb" from complaining. 

make dtb

- Copy the .rbf file (in output_files folder) and .dtb file onto the boot partition of the DE1-SoC board. Reboot the board. 

------------------------------------------------------

SOFTWARE

- The joypad keys are configured on lines 23-31 in main.c. Change them as you please.

- Open a console. Change the directory to where software source files are. Run the following commands in order:

make user
make
insmod game_boy.ko

- Before you run the program, press Key0 and Key1 on the DE1-SoC board simultaneously to reset the soc_system. 

./main <ROM file name>

- After running the program, press Key2 and Key3 on the DE1-SoC board simultaneously to reset the Game Boy. 

- To exit the game and save data (if applicable), press ESC button. 

- Press SPACE key for double speed.

- To clean up:

make clean
rmmod game_boy
clear