diff options
author | James <james.mckenzie@citrix.com> | 2013-10-13 13:12:09 +0100 |
---|---|---|
committer | James <james.mckenzie@citrix.com> | 2013-10-13 13:12:09 +0100 |
commit | abb7029fae182f1ef86f64af458267a996748e2b (patch) | |
tree | ac8f0241ea06d16cd1a70be493076210978c02be | |
parent | 7fbec04d3aaca8909f89b325e125e46fe218e3be (diff) | |
download | sdram-abb7029fae182f1ef86f64af458267a996748e2b.tar.gz sdram-abb7029fae182f1ef86f64af458267a996748e2b.tar.bz2 sdram-abb7029fae182f1ef86f64af458267a996748e2b.zip |
fish
-rw-r--r-- | .gitignore | 32 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | sdram.qsf | 4 | ||||
-rw-r--r-- | sdram_mcu.qsys | 48 | ||||
-rw-r--r-- | src/sdram.c | 54 |
5 files changed, 123 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5fb795 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +db +incremental_db +*.qws +*.rpt +*.bak +*.pof +*.sof +*.done +*.fit.summary +*.jdi +*.map.summary +*.sta.summary +*.sopcinfo +script/ +*~ +src/*.elf +src/*.objdump +src/*.map +bsp +*.swp +elf.flash +sof.flash +*.stamp +src/Makefile +src/obj +*.pin +.qsys_edit +.sopc_builder +*.bsf +sdram_mcu/ +sdram_mcu.cmp +sdram_mcu.html @@ -55,6 +55,17 @@ bsp.stamp:${SOPC_FILE} /bin/rm -rf ${BSP_DIR} mkdir -p ${BSP_DIR} tools/wrap nios2-bsp ${BSP_TYPE} ${BSP_DIR} ${SOPC_FILE} ${NIOS2_BSP_ARGS} ${CPU_NAME} + tools/wrap nios2-bsp-update-settings --bsp-dir ${BSP_DIR} --settings bsp/settings.bsp \ + --set hal.sys_clk_timer none \ + --set hal.max_file_descriptors 4 \ + --set hal.enable_c_plus_plus 0 \ + --set hal.make.bsp_cflags_optimization -Os \ + --set hal.enable_exit 0 \ + --set hal.enable_small_c_library 1 \ + --set hal.enable_clean_exit 0 \ + --set hal.enable_reduced_device_drivers 1 \ + --set hal.enable_lightweight_device_driver_api 1 + tools/wrap nios2-bsp-generate-files --bsp-dir ${BSP_DIR} --settings bsp/settings.bsp tools/wrap make -C ${BSP_DIR} touch $@ @@ -89,4 +100,3 @@ clean: - @@ -123,8 +123,8 @@ set_location_assignment PIN_161 -to dm9000_int set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top -set_global_assignment -name SEARCH_PATH db/ip/sdram_mcu/ -tag from_archive -set_global_assignment -name SEARCH_PATH db/ip/sdram_mcu/submodules/ -tag from_archive +set_global_assignment -name SEARCH_PATH sdram_mcu/synthesis/ -tag from_archive +set_global_assignment -name SEARCH_PATH sdram_mcu/synthesis/submodules/ -tag from_archive set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "3.3-V LVTTL" set_location_assignment PIN_108 -to vga_red[0] set_location_assignment PIN_113 -to vga_red[1] diff --git a/sdram_mcu.qsys b/sdram_mcu.qsys index 0764db1..6de6dcb 100644 --- a/sdram_mcu.qsys +++ b/sdram_mcu.qsys @@ -24,7 +24,7 @@ { datum baseAddress { - value = "155752"; + value = "172128"; type = "String"; } } @@ -48,7 +48,7 @@ { datum baseAddress { - value = "153600"; + value = "169984"; type = "String"; } } @@ -69,7 +69,7 @@ { datum baseAddress { - value = "151552"; + value = "167936"; type = "String"; } } @@ -105,27 +105,27 @@ type = "int"; } } - element onchip_memory2_0.s1 + element pio_0.s1 { datum baseAddress { - value = "139264"; + value = "172112"; type = "String"; } } - element timer_0.s1 + element onchip_memory2_0.s1 { datum baseAddress { - value = "155680"; + value = "147456"; type = "String"; } } - element pio_0.s1 + element timer_0.s1 { datum baseAddress { - value = "155728"; + value = "172064"; type = "String"; } } @@ -152,7 +152,7 @@ <parameter name="projectName" value="sdram.qpf" /> <parameter name="sopcBorderPoints" value="false" /> <parameter name="systemHash" value="1" /> - <parameter name="timeStamp" value="1381664019246" /> + <parameter name="timeStamp" value="1381664865183" /> <parameter name="useTestBenchNamingPattern" value="false" /> <instanceScript></instanceScript> <interface name="clk" internal="clk_0.clk_in" type="clock" dir="end" /> @@ -278,8 +278,8 @@ <parameter name="tightlyCoupledInstructionMaster1AddrWidth" value="1" /> <parameter name="tightlyCoupledInstructionMaster2AddrWidth" value="1" /> <parameter name="tightlyCoupledInstructionMaster3AddrWidth" value="1" /> - <parameter name="instSlaveMapParam"><![CDATA[<address-map><slave name='async_8bit_bus_adapter_0.avalon_slave' start='0x10000' end='0x20000' /><slave name='onchip_memory2_0.s1' start='0x22000' end='0x24000' /><slave name='nios2_qsys_0.jtag_debug_module' start='0x25000' end='0x25800' /><slave name='epcs_flash_controller_0.epcs_control_port' start='0x25800' end='0x26000' /><slave name='timer_0.s1' start='0x26020' end='0x26040' /><slave name='pio_0.s1' start='0x26050' end='0x26060' /></address-map>]]></parameter> - <parameter name="dataSlaveMapParam"><![CDATA[<address-map><slave name='async_8bit_bus_adapter_0.avalon_slave' start='0x10000' end='0x20000' /><slave name='onchip_memory2_0.s1' start='0x22000' end='0x24000' /><slave name='nios2_qsys_0.jtag_debug_module' start='0x25000' end='0x25800' /><slave name='epcs_flash_controller_0.epcs_control_port' start='0x25800' end='0x26000' /><slave name='timer_0.s1' start='0x26020' end='0x26040' /><slave name='pio_0.s1' start='0x26050' end='0x26060' /><slave name='jtag_uart_0.avalon_jtag_slave' start='0x26068' end='0x26070' /></address-map>]]></parameter> + <parameter name="instSlaveMapParam"><![CDATA[<address-map><slave name='async_8bit_bus_adapter_0.avalon_slave' start='0x10000' end='0x20000' /><slave name='onchip_memory2_0.s1' start='0x24000' end='0x26EE0' /><slave name='nios2_qsys_0.jtag_debug_module' start='0x29000' end='0x29800' /><slave name='epcs_flash_controller_0.epcs_control_port' start='0x29800' end='0x2A000' /><slave name='timer_0.s1' start='0x2A020' end='0x2A040' /><slave name='pio_0.s1' start='0x2A050' end='0x2A060' /></address-map>]]></parameter> + <parameter name="dataSlaveMapParam"><![CDATA[<address-map><slave name='async_8bit_bus_adapter_0.avalon_slave' start='0x10000' end='0x20000' /><slave name='onchip_memory2_0.s1' start='0x24000' end='0x26EE0' /><slave name='nios2_qsys_0.jtag_debug_module' start='0x29000' end='0x29800' /><slave name='epcs_flash_controller_0.epcs_control_port' start='0x29800' end='0x2A000' /><slave name='timer_0.s1' start='0x2A020' end='0x2A040' /><slave name='pio_0.s1' start='0x2A050' end='0x2A060' /><slave name='jtag_uart_0.avalon_jtag_slave' start='0x2A060' end='0x2A068' /></address-map>]]></parameter> <parameter name="clockFrequency" value="80000000" /> <parameter name="deviceFamilyName" value="Cyclone II" /> <parameter name="internalIrqMaskSystemInfo" value="7" /> @@ -368,7 +368,7 @@ <parameter name="initMemContent" value="true" /> <parameter name="initializationFileName" value="onchip_mem.hex" /> <parameter name="instanceID" value="NONE" /> - <parameter name="memorySize" value="8192" /> + <parameter name="memorySize" value="12000" /> <parameter name="readDuringWriteMode" value="DONT_CARE" /> <parameter name="simAllowMRAMContentsFile" value="false" /> <parameter name="simMemInitOnlyFilename" value="0" /> @@ -421,7 +421,7 @@ start="nios2_qsys_0.data_master" end="epcs_flash_controller_0.epcs_control_port"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00025800" /> + <parameter name="baseAddress" value="0x00029800" /> <parameter name="defaultConnection" value="false" /> </connection> <connection kind="clock" version="13.0" start="clk_0.clk" end="timer_0.clk" /> @@ -443,7 +443,7 @@ start="nios2_qsys_0.data_master" end="pio_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00026050" /> + <parameter name="baseAddress" value="0x0002a050" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -468,7 +468,7 @@ start="nios2_qsys_0.data_master" end="jtag_uart_0.avalon_jtag_slave"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00026068" /> + <parameter name="baseAddress" value="0x0002a060" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -513,7 +513,7 @@ start="nios2_qsys_0.data_master" end="onchip_memory2_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00022000" /> + <parameter name="baseAddress" value="0x00024000" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -522,7 +522,7 @@ start="nios2_qsys_0.instruction_master" end="onchip_memory2_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00022000" /> + <parameter name="baseAddress" value="0x00024000" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -531,7 +531,7 @@ start="nios2_qsys_0.instruction_master" end="nios2_qsys_0.jtag_debug_module"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00025000" /> + <parameter name="baseAddress" value="0x00029000" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -540,7 +540,7 @@ start="nios2_qsys_0.data_master" end="nios2_qsys_0.jtag_debug_module"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00025000" /> + <parameter name="baseAddress" value="0x00029000" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -549,7 +549,7 @@ start="nios2_qsys_0.instruction_master" end="epcs_flash_controller_0.epcs_control_port"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00025800" /> + <parameter name="baseAddress" value="0x00029800" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -558,7 +558,7 @@ start="nios2_qsys_0.instruction_master" end="timer_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00026020" /> + <parameter name="baseAddress" value="0x0002a020" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -567,7 +567,7 @@ start="nios2_qsys_0.data_master" end="timer_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00026020" /> + <parameter name="baseAddress" value="0x0002a020" /> <parameter name="defaultConnection" value="false" /> </connection> <connection @@ -576,7 +576,7 @@ start="nios2_qsys_0.instruction_master" end="pio_0.s1"> <parameter name="arbitrationPriority" value="1" /> - <parameter name="baseAddress" value="0x00026050" /> + <parameter name="baseAddress" value="0x0002a050" /> <parameter name="defaultConnection" value="false" /> </connection> <connection diff --git a/src/sdram.c b/src/sdram.c new file mode 100644 index 0000000..60b9459 --- /dev/null +++ b/src/sdram.c @@ -0,0 +1,54 @@ +#include <io.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include "system.h" + + +#define msleep(msec) usleep(1000*msec); + +pio_write (unsigned int data) +{ + IOWR (PIO_0_BASE, 0, data); +} + + +static void +show_score (int score) +{ + // int to seven segment lookup: MSB dp g f e d c b a LSB + const uint8_t lookup[10] = + { 0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F }; + + uint8_t ss = 0; + + // show negative with DP + if (score < 0) + { + ss |= 0x80; + score = -score; + } + + if (score > 9) + score = 9; + + ss |= lookup[score]; + + pio_write (ss); +} +int +main (void) +{ + int i; + printf ("Working...\n"); + for (;;) { + for (i=-9;i<10;++i) + { + printf("%d\n",i); + show_score(i); + msleep(200); + } + } +} |