diff options
-rw-r--r-- | .gitignore | 30 | ||||
-rw-r--r-- | GPU/hdl/GPU_IF.v | 139 | ||||
-rw-r--r-- | pong3.pin | 28 | ||||
-rw-r--r-- | pong3.qsf | 15 | ||||
-rw-r--r-- | pong3.v | 2 | ||||
-rw-r--r-- | software/Makefile | 60 | ||||
-rw-r--r-- | software/pong3/.cproject | 60 | ||||
-rw-r--r-- | software/pong3/pong3.c | 141 | ||||
-rw-r--r-- | software/pong3_bsp/.cproject | 48 | ||||
-rw-r--r-- | software/pong3_bsp/settings.bsp | 4 | ||||
-rwxr-xr-x | software/wrap.sh | 11 |
11 files changed, 340 insertions, 198 deletions
@@ -1,2 +1,32 @@ db pong3.qws +*.rpt +*.bak +*.pof +*.sof +incremental_db +my_sys.sopcinfo +*.done +*.fit.summary +*.jdi +*.map.summary +*.sta.summary +script/ +software/.metadata/ +software/pong3/obj/ +*~ +*.elf +*.map +*.objdump +HAL/ +alt_sys_init.c +drivers/ +libhal_bsp.a +linker.h +linker.x +mem_init.mk +memory.gdb +obj/ +public.mk +summary.html +system.h diff --git a/GPU/hdl/GPU_IF.v b/GPU/hdl/GPU_IF.v index f32de1e..16c234d 100644 --- a/GPU/hdl/GPU_IF.v +++ b/GPU/hdl/GPU_IF.v @@ -27,10 +27,10 @@ module gpuv2 #( ); - reg [9:0] ball_x; - reg [8:0] ball_y; - reg [8:0] bat0_y; - reg [8:0] bat1_y; + reg [9:0] sprite_x; + reg [9:0] sprite_y; + reg [9:0] bat0_y; + reg [9:0] bat1_y; reg [15:0] sprite[0:15]; @@ -38,18 +38,24 @@ module gpuv2 #( assign reg_addr = address[6:2]; + wire [9:0] offset; + + assign offset = 10'h80; reg [2:0] sprite_red; reg [2:0] sprite_green; reg [2:0] sprite_blue; + reg blanking; + always @(posedge clk or negedge rst_n) begin if (rst_n == 0) begin - ball_x <= 10'd127; - ball_y <= 10'd127; - bat0_y <= 10'd100; - bat1_y <= 10'd200; + blanking <= 0; + sprite_x <= 10'd127+offset; + sprite_y <= 10'd127+offset; + bat0_y <= 10'd100+offset; + bat1_y <= 10'd200+offset; sprite[0]=16'b1111111111111111; sprite[1]=16'b1000000000000001; @@ -77,15 +83,17 @@ module gpuv2 #( sprite[reg_addr[3:0]]<=data[15:0]; end else begin case (reg_addr[2:0]) - 3'b000: - ball_x <= data[9:0]; - 3'b001: - ball_y <= data[8:0]; - 3'b010: - bat0_y <= data[8:0]; - 3'b011: - bat1_y <= data[8:0]; - 3'b100: + 3'd0: + blanking <= data[0]; + 3'd1: + sprite_x <= data[9:0]; + 3'd2: + sprite_y <= data[9:0]; + 3'd3: + bat0_y <= data[9:0]; + 3'd4: + bat1_y <= data[9:0]; + 3'd5: begin sprite_red <= data[8:6]; sprite_green <= data[5:3]; @@ -110,13 +118,13 @@ module gpuv2 #( always @ (posedge vga_clk or negedge rst_n) begin if(!rst_n) - vector_x <= 10'd0; + vector_x <= offset; else if(trig_25M) begin - if(vector_x != 10'd799) - vector_x <= vector_x + 1'b1; + if(vector_x != (10'd799 + offset)) + vector_x <= vector_x + 1'b1; else - vector_x <= 10'd0; + vector_x <= offset; end end @@ -124,15 +132,15 @@ module gpuv2 #( always @ (posedge vga_clk or negedge rst_n) begin if(!rst_n) - vector_y <= 10'd0; + vector_y <= offset; else if(trig_25M) begin - if(vector_x == 10'd799) + if(vector_x == (10'd799 + offset)) begin - if(vector_y != 10'd524) + if(vector_y != (10'd524 + offset)) vector_y <= vector_y + 1'b1; else - vector_y <= 10'd0; + vector_y <= offset; end end end @@ -143,7 +151,7 @@ module gpuv2 #( vga_hs <= 1'b0; else if(trig_25M) begin - if(vector_x >= 10'd656 && vector_x < 10'd752) + if(vector_x >= (10'd656 + offset) && vector_x < (10'd752+offset)) vga_hs <= 1'b0; else vga_hs <= 1'b1; @@ -156,7 +164,7 @@ module gpuv2 #( vga_vs <= 1'b0; else if(trig_25M) begin - if(vector_y >= 10'd490 && vector_y < 10'd492) + if(vector_y >= (10'd490+offset) && vector_y < (10'd492+offset)) vga_vs <= 1'b0; else vga_vs <= 1'b1; @@ -165,52 +173,67 @@ module gpuv2 #( - reg [2:0] index; + reg px_bat; + reg px_net; + reg px_sprite; + reg px_blank; + always @ (posedge vga_clk or negedge rst_n) begin - if(!rst_n) - index <= 3'b000; - else if(trig_25M) - begin - if(vector_x < 10'd640 && vector_y < 10'd480) - if(vector_x >= (ball_x - 8 )&& vector_x <=( ball_x + 7 ) - && vector_y >= (ball_y - 8) && vector_y <= (ball_y + 7)) begin - if (sprite[(vector_y - (ball_y - 8)) & 15 ][(vector_x - (ball_x -8))& 15 ]) - index <= 3'b001; - else - index <= 3'b000; - end else if (vector_x < 10'd4) - if (vector_y >=( bat0_y - 20 ) && vector_y <= (bat0_y + 20) ) - index <= 3'b111; - else - index <= 3'b000; - else if (vector_x >= 10'd318 && vector_x < 10'd322) - index <= {3{vector_y[3]}}; - else if (vector_x >= 10'd636 && vector_x < 10'd640) - if (vector_y >=( bat1_y - 20 ) && vector_y <= (bat1_y + 20) ) - index <= 3'b111; - else - index <= 3'b000; - else - index <= 3'b000; - else - index <= 3'b000; + if(!rst_n) begin + px_bat <= 0; + px_net <= 0; + px_sprite <= 0; + px_blank <= 1; + end else if(trig_25M) begin + if(vector_x>= offset && vector_x < (10'd640+offset) && vector_y >= offset && vector_y < (10'd480+offset)) + px_blank<= blanking; + else + px_blank<=1; + + if(vector_x >= (sprite_x - 8 )&& vector_x <=( sprite_x + 7 ) + && vector_y >= (sprite_y - 8) && vector_y <= (sprite_y + 7)) + px_sprite <= sprite[(vector_y - (sprite_y - 8)) & 15 ][(vector_x - (sprite_x -8))& 15 ]; + else + px_sprite <= 0; + + if (vector_x < (10'd4+offset) && vector_y >=( bat0_y - 20 ) && vector_y <= (bat0_y + 20) ) + px_bat <= 1; + else if (vector_x >= (10'd636 + offset) && vector_y >=( bat1_y - 20 ) && vector_y <= (bat1_y + 20) ) + px_bat <=1 ; + else + px_bat <=0; + + + if (vector_x >= (10'd318 +offset) && vector_x < (10'd322+offset)) + px_net <= {3{vector_y[3]}}; + else + px_net <= 0; + end end always begin - if (index == 3'b000) begin + if (px_blank) begin vga_red = 3'b000; vga_green = 3'b000; vga_blue = 3'b000; - end else if (index == 3'b001) begin + end else if (px_bat) begin + vga_red= 3'b111; + vga_green=3'b111; + vga_blue=3'b111; + end else if (px_sprite) begin vga_red = sprite_red; vga_green= sprite_green; vga_blue = sprite_blue; - end else begin + end else if (px_net) begin vga_red= 3'b111; vga_green=3'b111; vga_blue=3'b111; + end else begin + vga_red = 3'b000; + vga_green = 3'b000; + vga_blue = 3'b000; end @@ -97,17 +97,17 @@ GND* : 30 : : : GND* : 31 : : : : 1 : VCCINT : 32 : power : : 1.2V : : GND* : 33 : : : : 1 : -GND* : 34 : : : : 1 : -seven_seg[2] : 35 : output : 3.3-V LVTTL : : 1 : N +seven_seg[0] : 34 : output : 3.3-V LVTTL : : 1 : Y +seven_seg[1] : 35 : output : 3.3-V LVTTL : : 1 : Y GND : 36 : gnd : : : : -GND* : 37 : : : : 1 : +seven_seg[5] : 37 : output : 3.3-V LVTTL : : 1 : Y GND : 38 : gnd : : : : -GND* : 39 : : : : 1 : -GND* : 40 : : : : 1 : +seven_seg[2] : 39 : output : 3.3-V LVTTL : : 1 : Y +seven_seg[6] : 40 : output : 3.3-V LVTTL : : 1 : Y GND* : 41 : : : : 1 : VCCIO1 : 42 : power : : 3.3V : 1 : -GND* : 43 : : : : 1 : -seven_seg[3] : 44 : output : 3.3-V LVTTL : : 1 : N +seven_seg[4] : 43 : output : 3.3-V LVTTL : : 1 : Y +seven_seg[3] : 44 : output : 3.3-V LVTTL : : 1 : Y sdram_cs_n : 45 : output : 3.3-V LVTTL : : 1 : Y sdram_cke : 46 : output : 3.3-V LVTTL : : 1 : Y sdram_clk : 47 : output : 3.3-V LVTTL : : 1 : Y @@ -169,11 +169,11 @@ sdram_dq[9] : 102 : bidir : 3.3-V LVTTL : sdram_dq[8] : 103 : bidir : 3.3-V LVTTL : : 4 : Y sdram_dqm[1] : 104 : output : 3.3-V LVTTL : : 4 : Y GND* : 105 : : : : 3 : -seven_seg[6] : 106 : output : 3.3-V LVTTL : : 3 : N -seven_seg[0] : 107 : output : 3.3-V LVTTL : : 3 : N +GND* : 106 : : : : 3 : +GND* : 107 : : : : 3 : vga_red[0] : 108 : output : 3.3-V LVTTL : : 3 : Y VCCIO3 : 109 : power : : 3.3V : 3 : -seven_seg[5] : 110 : output : 3.3-V LVTTL : : 3 : N +GND* : 110 : : : : 3 : GND : 111 : gnd : : : : vga_red[2] : 112 : output : 3.3-V LVTTL : : 3 : Y vga_red[1] : 113 : output : 3.3-V LVTTL : : 3 : Y @@ -236,7 +236,7 @@ GND* : 169 : : : GND* : 170 : : : : 2 : GND* : 171 : : : : 2 : VCCIO2 : 172 : power : : 3.3V : 2 : -GND* : 173 : : : : 2 : +seven_seg[7] : 173 : output : 3.3-V LVTTL : : 2 : N GND : 174 : gnd : : : : GND* : 175 : : : : 2 : GND* : 176 : : : : 2 : @@ -258,17 +258,17 @@ GND* : 191 : : : GND* : 192 : : : : 2 : GND* : 193 : : : : 2 : VCCIO2 : 194 : power : : 3.3V : 2 : -seven_seg[1] : 195 : output : 3.3-V LVTTL : : 2 : N +GND* : 195 : : : : 2 : GND : 196 : gnd : : : : GND* : 197 : : : : 2 : GND* : 198 : : : : 2 : GND* : 199 : : : : 2 : GND* : 200 : : : : 2 : -seven_seg[4] : 201 : output : 3.3-V LVTTL : : 2 : N +GND* : 201 : : : : 2 : VCCIO2 : 202 : power : : 3.3V : 2 : GND* : 203 : : : : 2 : GND : 204 : gnd : : : : -seven_seg[7] : 205 : output : 3.3-V LVTTL : : 2 : N +GND* : 205 : : : : 2 : GND* : 206 : : : : 2 : GND* : 207 : : : : 2 : GND* : 208 : : : : 2 : @@ -48,13 +48,13 @@ set_global_assignment -name DEVICE_FILTER_PACKAGE "ANY QFP" set_global_assignment -name DEVICE_FILTER_PIN_COUNT 208 set_global_assignment -name DEVICE_FILTER_SPEED_GRADE 8 set_global_assignment -name ERROR_CHECK_FREQUENCY_DIVISOR 1 -set_location_assignment PIN_40 -to seg[6] -set_location_assignment PIN_37 -to seg[5] -set_location_assignment PIN_43 -to seg[4] -set_location_assignment PIN_44 -to seg[3] -set_location_assignment PIN_39 -to seg[2] -set_location_assignment PIN_35 -to seg[1] -set_location_assignment PIN_34 -to seg[0] +set_location_assignment PIN_40 -to seven_seg[6] +set_location_assignment PIN_37 -to seven_seg[5] +set_location_assignment PIN_43 -to seven_seg[4] +set_location_assignment PIN_44 -to seven_seg[3] +set_location_assignment PIN_39 -to seven_seg[2] +set_location_assignment PIN_35 -to seven_seg[1] +set_location_assignment PIN_34 -to seven_seg[0] set_location_assignment PIN_23 -to clk set_location_assignment PIN_27 -to rst_n set_location_assignment PIN_92 -to sdram_addr[12] @@ -148,4 +148,5 @@ set_global_assignment -name PIN_FILE pong3.pin set_global_assignment -name VERILOG_FILE pong3.v set_global_assignment -name QSYS_FILE my_sys.qsys + set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
\ No newline at end of file @@ -85,7 +85,7 @@ module pong3( .sdram_0_wire_dqm (sdram_dqm ), .sdram_0_wire_ras_n(sdram_ras_n), .sdram_0_wire_we_n (sdram_we_n ), - .pio_0_d_export (SEG ),
+ .pio_0_d_export (seven_seg ),
.gpu_0_vga_red(vga_red),
diff --git a/software/Makefile b/software/Makefile new file mode 100644 index 0000000..13116c7 --- /dev/null +++ b/software/Makefile @@ -0,0 +1,60 @@ +# +# + +ELFDIR=../software/pong3 +BSPDIR=../software/pong3_bsp +ELF=pong3.elf + +SOPCINFO=../my_sys.sopcinfo +SOF=../pong3.sof + +run: load_elf.stamp + ./wrap.sh nios2-terminal + +flash: load_sof.stamp sof.flash elf.flash ${BSPDIR}/system.h + BASE=` grep EPCS_FLASH_CONTROLLER_0_BASE ${BSPDIR}/system.h | awk '{print $$3}' ` && \ + ./wrap.sh nios2-flash-programmer sof.flash --base=$${BASE} --epcs --accept-bad-sysid --device=1 --instance=0 --program --verbose && \ + ./wrap.sh nios2-flash-programmer elf.flash --base=$${BASE} --epcs --accept-bad-sysid --device=1 --instance=0 --program --verbose -g + +sof.flash: ${SOF} + ./wrap.sh sof2flash --input=$< --output=$@ --epcs --verbose + +elf.flash: ${ELFDIR}/${ELF} sof.flash + ./wrap.sh elf2flash --input=${ELFDIR}/${ELF} --output=$@ --epcs --after=sof.flash --verbose + + + + + + + +load_elf.stamp:load_sof.stamp ${ELFDIR}/${ELF} + ./wrap.sh nios2-download ${ELFDIR}/${ELF} -g + +load_sof.stamp: ${SOF} + ./wrap.sh quartus_pgm -m JTAG -o 'p;../pong3.sof' + +${ELFDIR}/${ELF}: ${BSPDIR}/libhal_bsp.a + ./wrap.sh ${MAKE} -C ${ELFDIR} + + +${BSPDIR}/libhal_bsp.a:${BSPDIR}/system.h + ./wrap.sh ${MAKE} -C ${BSPDIR} + +${BSPDIR}/system.h:${SOPCINFO} + rm -f $@ + (cd ${BSPDIR} && ${PWD}/wrap.sh ./create-this-bsp ) + + +clean: + ./wrap.sh ${MAKE} -C ${BSPDIR} clean + ./wrap.sh ${MAKE} -C ${ELFDIR} clean + /bin/rm -f sof.flash elf.flash + /bin/rm -rf ${BSPDIR}/drivers ${BSPDIR}/HAL ${BSPDIR}/linker.h ${BSPDIR}/linker.x ${BSPDIR}/system.h ${BSPDIR}/summary.html ${BSPDIR}/public.mk ${BSPDIR}/mem_init.mk ${BSPDIR}/memory.gdb ${BSPDIR}/alt_sys_init.c + + + + + + + diff --git a/software/pong3/.cproject b/software/pong3/.cproject index ae6d1bc..f15f89f 100644 --- a/software/pong3/.cproject +++ b/software/pong3/.cproject @@ -3,19 +3,19 @@ <cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> <storageModule moduleId="org.eclipse.cdt.core.settings"> - <buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763"> - <storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" moduleId="org.eclipse.cdt.core.settings"/> + <buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440"> + <storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440" moduleId="org.eclipse.cdt.core.settings"/> </buildSystem> - <cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763"> + <cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440"> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg"> - <folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763." name="/" resourcePath=""> - <toolChain id="altera.nios2.linux.gcc4.1592970977" name="Linux Nios II GCC4" superClass="altera.nios2.linux.gcc4"> - <targetPlatform id="altera.nios2.linux.gcc4.988746646" name="Nios II" superClass="altera.nios2.linux.gcc4"/> - <builder buildPath="${workspace_loc://pong3}" id="cdt.managedbuild.target.gnu.builder.base.142418973" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> - <tool id="cdt.managedbuild.tool.gnu.archiver.base.1625897181" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1933293821" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> - <option id="gnu.cpp.compiler.option.preprocessor.undef.710001009" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef" valueType="undefDefinedSymbols"> + <configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg"> + <folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440." name="/" resourcePath=""> + <toolChain id="altera.nios2.linux.gcc4.848844856" name="Linux Nios II GCC4" superClass="altera.nios2.linux.gcc4"> + <targetPlatform id="altera.nios2.linux.gcc4.910507236" name="Nios II" superClass="altera.nios2.linux.gcc4"/> + <builder buildPath="${workspace_loc://pong3}" id="cdt.managedbuild.target.gnu.builder.base.152967692" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1040914647" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1419793037" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> + <option id="gnu.cpp.compiler.option.preprocessor.undef.1238194750" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef" valueType="undefDefinedSymbols"> <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/> <listOptionValue builtIn="false" value="__FLT_EPSILON__"/> <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/> @@ -151,10 +151,10 @@ <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/> <listOptionValue builtIn="false" value="__cplusplus"/> </option> - <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.579269023" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.473814365" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1403439131" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> - <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1842834456" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" valueType="undefDefinedSymbols"> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.540100236" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> + <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1852800441" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" valueType="undefDefinedSymbols"> <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/> <listOptionValue builtIn="false" value="__FLT_EPSILON__"/> <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/> @@ -282,23 +282,23 @@ <listOptionValue builtIn="false" value="unix"/> <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/> </option> - <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1504475877" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.952505848" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.c.linker.base.537533455" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.230683032" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> - <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1562487580" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <tool id="cdt.managedbuild.tool.gnu.c.linker.base.780339284" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1093798203" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1769791579" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/> </inputType> </tool> - <tool id="cdt.managedbuild.tool.gnu.assembler.base.664604318" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> - <inputType id="cdt.managedbuild.tool.gnu.assembler.input.455490736" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + <tool id="cdt.managedbuild.tool.gnu.assembler.base.1967007695" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.938120387" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> </tool> </toolChain> </folderInfo> </configuration> </storageModule> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" moduleId="org.eclipse.cdt.core.settings" name="Nios II"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440" moduleId="org.eclipse.cdt.core.settings" name="Nios II"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -313,32 +313,32 @@ </cconfiguration> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <project id="pong3.null.495750362" name="pong3"/> + <project id="pong3.null.1631886421" name="pong3"/> </storageModule> <storageModule moduleId="scannerConfiguration"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> - <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1933293821;cdt.managedbuild.tool.gnu.cpp.compiler.input.579269023"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> + <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440.;cdt.managedbuild.tool.gnu.c.compiler.base.540100236;cdt.managedbuild.tool.gnu.c.compiler.input.952505848"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> <buildOutputProvider> <openAction enabled="true" filePath=""/> <parser enabled="true"/> </buildOutputProvider> <scannerInfoProvider id="specsFile"> - <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.cpp"" command="nios2-elf-g++" useDefault="true"/> + <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.c"" command="nios2-elf-gcc" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> </scannerConfigBuildInfo> - <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763.;cdt.managedbuild.tool.gnu.c.compiler.base.1403439131;cdt.managedbuild.tool.gnu.c.compiler.input.1504475877"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> + <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1741772440.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1419793037;cdt.managedbuild.tool.gnu.cpp.compiler.input.473814365"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> <buildOutputProvider> <openAction enabled="true" filePath=""/> <parser enabled="true"/> </buildOutputProvider> <scannerInfoProvider id="specsFile"> - <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.c"" command="nios2-elf-gcc" useDefault="true"/> + <runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.cpp"" command="nios2-elf-g++" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> diff --git a/software/pong3/pong3.c b/software/pong3/pong3.c index 63ae56c..0e88ac8 100644 --- a/software/pong3/pong3.c +++ b/software/pong3/pong3.c @@ -13,59 +13,12 @@ gpu_write (unsigned int reg, unsigned int data) IOWR (GPU_0_BASE, reg << 2, data); } -static int -find_intersection (int x, int y, int xd, int yd, int t) -{ - - // super lazy - we should use the power of MATHS - - while (x != t) - { - x += xd; - y += yd; - - if (y < 0) - y = 0; - if (y > 479) - y = 479; - if ((y == 479) || (y == 0)) - yd = -yd; - - if ((x == 639) || (x == 0)) - xd = -xd; - } - - return y; -} - -static int -dir (int a, int b) -{ - if (a > b) - return 1; - if (a < b) - return -1; - return 0; -} - -static void -move_bat (int *b, int db) -{ - - *b += dir (db, *b); - if (*b < 20) - *b = 20; - if (*b > 459) - *b = 459; - -} - static void load_sprite (void) { // RRR GGG BBB // set the sprite color 111 010 000 - orange - gpu_write (4, 0x01D0); + gpu_write (5, 0x01D0); // squirt the bromium logo into the sprite gpu_write (0x10, 0x00C0); @@ -86,6 +39,60 @@ load_sprite (void) gpu_write (0x1f, 0x00C0); } + +static int +dir (int a, int b) +{ + if (a > b) + return 1; + if (a < b) + return -1; + return 0; +} + +static void +move_bat (int *b, int db) +{ + *b += dir (db, *b); +} + +static int +squish (int *v, int min, int max) +{ + if (*v < min) + { + *v = min; + return 1; + } + if (*v >= max) + { + *v = max - 1; + return 1; + } + return 0; +} + +static int +find_intersection (int x, int y, int xd, int yd, int t) +{ + + // super lazy - we should use the power of MATHS + + while (x != t) + { + x += xd; + y += yd; + + if (squish (&y, 0, 480)) + yd = -yd; + + if (squish (&x, 0, 640)) + xd = -xd; + } + + return y; +} + int main (void) { @@ -117,35 +124,45 @@ main (void) { x += xd; y += yd; - if (y < 0) - y = 0; - if (y > 479) - y = 479; - if ((y == 479) || (y == 0)) + + + if (squish (&y, 0, 480)) yd = -yd; - if ((x == 639) || (x == 0)) + if (squish (&x, 0, 640)) { - xd = -xd; + xd = (rand () % 3) + 1; + if (x) + xd = -xd; yd = rand () % 7; yd -= 3; - dbat0 = find_intersection (x + xd, y + yd, xd, yd, 0); - dbat1 = find_intersection (x + xd, y + yd, xd, yd, 639); + + if (x) + { + dbat0 = find_intersection (x + xd, y + yd, xd, yd, 0); + dbat1 = 480 / 2; + } + else + { + dbat0 = 480 / 2; + + dbat1 = find_intersection (x + xd, y + yd, xd, yd, 639); + } } move_bat (&bat0, dbat0); move_bat (&bat1, dbat1); - gpu_write (0, x); - gpu_write (1, y); + gpu_write (1, x + 0x80); + gpu_write (2, y + 0x80); + gpu_write (3, bat0 + 0x80); + gpu_write (4, bat1 + 0x80); - gpu_write (2, bat0); - gpu_write (3, bat1); + gpu_write (0, 0); msleep (2); } } } -//------------------------------------------------------------------------- diff --git a/software/pong3_bsp/.cproject b/software/pong3_bsp/.cproject index bca629e..aaab98e 100644 --- a/software/pong3_bsp/.cproject +++ b/software/pong3_bsp/.cproject @@ -3,19 +3,19 @@ <cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> <storageModule moduleId="org.eclipse.cdt.core.settings"> - <buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873"> - <storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873" moduleId="org.eclipse.cdt.core.settings"/> + <buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754"> + <storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754" moduleId="org.eclipse.cdt.core.settings"/> </buildSystem> - <cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873"> + <cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754"> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg"> - <folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873." name="/" resourcePath=""> - <toolChain id="altera.nios2.linux.gcc4.9855396" name="Linux Nios II GCC4" superClass="altera.nios2.linux.gcc4"> - <targetPlatform id="altera.nios2.linux.gcc4.2140129943" name="Nios II" superClass="altera.nios2.linux.gcc4"/> - <builder buildPath="${workspace_loc://pong3_bsp}" id="cdt.managedbuild.target.gnu.builder.base.1474186794" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> - <tool id="cdt.managedbuild.tool.gnu.archiver.base.817937252" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1813359900" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> - <option id="gnu.cpp.compiler.option.preprocessor.undef.681487502" superClass="gnu.cpp.compiler.option.preprocessor.undef" valueType="undefDefinedSymbols"> + <configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg"> + <folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754." name="/" resourcePath=""> + <toolChain id="altera.nios2.linux.gcc4.578126036" name="Linux Nios II GCC4" superClass="altera.nios2.linux.gcc4"> + <targetPlatform id="altera.nios2.linux.gcc4.1516993476" name="Nios II" superClass="altera.nios2.linux.gcc4"/> + <builder buildPath="${workspace_loc://pong3_bsp}" id="cdt.managedbuild.target.gnu.builder.base.1752385920" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.716497011" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1037028462" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> + <option id="gnu.cpp.compiler.option.preprocessor.undef.846709354" superClass="gnu.cpp.compiler.option.preprocessor.undef" valueType="undefDefinedSymbols"> <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/> <listOptionValue builtIn="false" value="__FLT_EPSILON__"/> <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/> @@ -151,10 +151,10 @@ <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/> <listOptionValue builtIn="false" value="__cplusplus"/> </option> - <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1182153276" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1585848206" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.437673634" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> - <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1800356526" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" valueType="undefDefinedSymbols"> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.801049722" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> + <option id="gnu.c.compiler.option.preprocessor.undef.symbol.139423711" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" valueType="undefDefinedSymbols"> <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/> <listOptionValue builtIn="false" value="__FLT_EPSILON__"/> <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/> @@ -282,23 +282,23 @@ <listOptionValue builtIn="false" value="unix"/> <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/> </option> - <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2106556578" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.556327539" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.c.linker.base.582362953" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.682475739" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> - <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.208725282" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1531131981" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.893346218" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1294537006" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/> </inputType> </tool> - <tool id="cdt.managedbuild.tool.gnu.assembler.base.746360663" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> - <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1493526707" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + <tool id="cdt.managedbuild.tool.gnu.assembler.base.189505706" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1775744136" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> </tool> </toolChain> </folderInfo> </configuration> </storageModule> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873" moduleId="org.eclipse.cdt.core.settings" name="Nios II"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754" moduleId="org.eclipse.cdt.core.settings" name="Nios II"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -313,12 +313,12 @@ </cconfiguration> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <project id="pong3_bsp.null.637440566" name="pong3_bsp"/> + <project id="pong3_bsp.null.649544993" name="pong3_bsp"/> </storageModule> <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> <storageModule moduleId="scannerConfiguration"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> - <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873.;cdt.managedbuild.tool.gnu.c.compiler.base.437673634;cdt.managedbuild.tool.gnu.c.compiler.input.2106556578"> + <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754.;cdt.managedbuild.tool.gnu.c.compiler.base.801049722;cdt.managedbuild.tool.gnu.c.compiler.input.556327539"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> <buildOutputProvider> @@ -331,7 +331,7 @@ </scannerInfoProvider> </profile> </scannerConfigBuildInfo> - <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1018767873.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1813359900;cdt.managedbuild.tool.gnu.cpp.compiler.input.1182153276"> + <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.245290754.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1037028462;cdt.managedbuild.tool.gnu.cpp.compiler.input.1585848206"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> <buildOutputProvider> diff --git a/software/pong3_bsp/settings.bsp b/software/pong3_bsp/settings.bsp index e567b80..6bafac0 100644 --- a/software/pong3_bsp/settings.bsp +++ b/software/pong3_bsp/settings.bsp @@ -2,8 +2,8 @@ <sch:Settings xmlns:sch="http://www.altera.com/embeddedsw/bsp/schema"> <BspType>hal</BspType> <BspVersion>default</BspVersion> - <BspGeneratedTimeStamp>Oct 10, 2013 11:49:08 AM</BspGeneratedTimeStamp> - <BspGeneratedUnixTimeStamp>1381402148374</BspGeneratedUnixTimeStamp> + <BspGeneratedTimeStamp>Oct 10, 2013 11:06:28 PM</BspGeneratedTimeStamp> + <BspGeneratedUnixTimeStamp>1381442788161</BspGeneratedUnixTimeStamp> <BspGeneratedLocation>/home/root/projects/altera/pong3/software/pong3_bsp</BspGeneratedLocation> <BspSettingsFile>./settings.bsp</BspSettingsFile> <SopcDesignFile>../../my_sys.sopcinfo</SopcDesignFile> diff --git a/software/wrap.sh b/software/wrap.sh new file mode 100755 index 0000000..4caed0f --- /dev/null +++ b/software/wrap.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +AD=/software/apps/altera/quartus_ii_13.0sp1 +LL=linux +QUARTUS_ROOTDIR="${AD}/quartus" +PATH="${AD}/quartus/bin:${AD}/nios2eds/sdk2/bin:${AD}/nios2eds/bin:${AD}/nios2eds/bin/gnu/H-i686-pc-linux-gnu/bin:${PATH}" +LD_LIBRARY_PATH="${AD}/quartus/${LL}:${LD_LIBRARY_PATH}" + +export LD_LIBRARY_PATH PATH QUARTUS_ROOTDIR + +"$@" |