找回密码
 注册
关于网站域名变更的通知
查看: 273|回复: 1
打印 上一主题 下一主题

基于SOPC的单通道TDC设计(3) 

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-4-12 10:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
本帖最后由 Taio 于 2019-4-12 10:56 编辑 2 |( g! `( G7 F7 x3 Z$ T8 r1 V; W

1 j, j1 u( x- E) {
基于SOPC的单通道TDC设计(3)
) R" j' ]$ H* i( z
2 软件系统. X  ~0 a6 s$ K

% U- M9 W. V/ o5 R/ L
: V9 I7 a4 I1 ~" N3 G/ m3 A- O, M
! H# y2 K2 r9 R0 `3 f4 N3 z
2.1 System.h
/*
* system.h - SOPC Builder system and BSP software package information
*
* Machine generated for CPU 'cpu' in SOPC Builder design 'audio_nios'
* SOPC Builder design path: E:/eeworld_soc/eeworld3/tdc1000_SoC/audio_nios.sopcinfo
*
* Generated: Tue Jun 02 11:18:56 CST 2015
*/
/ ^2 E1 d$ l8 e  a
/*
* DO NOT MODIFY THIS FILE
*
* Changing this file will have subtle consequences
* which will almost certainly lead to a nonfunctioning
* system. If you do modify this file, be aware that your
* changes will be overwritten and lost when this file
* is generated again.
*
* DO NOT MODIFY THIS FILE
*/
; v1 z1 E1 w) k
/*
* License Agreement
*
* Copyright (c) 2008
* Altera Corporation, San Jose, California, USA.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* This agreement shall be governed in all respects by the laws of the State
* of California and by the laws of the United States of America.
*/

  M/ p  }8 E7 E4 K$ l9 z
#ifndef __SYSTEM_H_
#define __SYSTEM_H_
0 t, `# u7 {, [) p
/* Include definitions from linker script generator */
#include "linker.h"
2 |( \/ S0 ~# C* r
$ e5 w3 o* b: [8 Q% n2 m" p5 r  h
/*
* CPU configuration
*
*/

6 a0 T$ A" _7 ^' k$ X1 a
#define ALT_CPU_ARCHITECTURE "altera_nios2_gen2"
#define ALT_CPU_BIG_ENDIAN 0
#define ALT_CPU_BREAK_ADDR 0x05100820
#define ALT_CPU_CPU_ARCH_NIOS2_R1
#define ALT_CPU_CPU_FREQ 100000000u
#define ALT_CPU_CPU_ID_SIZE 1
#define ALT_CPU_CPU_ID_VALUE 0x00000000
#define ALT_CPU_CPU_IMPLEMENTATION "fast"
#define ALT_CPU_DATA_ADDR_WIDTH 0x1b
#define ALT_CPU_DCACHE_BYPASS_MASK 0x80000000
#define ALT_CPU_DCACHE_LINE_SIZE 32
#define ALT_CPU_DCACHE_LINE_SIZE_LOG2 5
#define ALT_CPU_DCACHE_SIZE 2048
#define ALT_CPU_EXCEPTION_ADDR 0x05080020
#define ALT_CPU_FLASH_ACCELERATOR_LINES 0
#define ALT_CPU_FLASH_ACCELERATOR_LINE_SIZE 0
#define ALT_CPU_FLUSHDA_SUPPORTED
#define ALT_CPU_FREQ 100000000
#define ALT_CPU_HARDWARE_DIVIDE_PRESENT 0
#define ALT_CPU_HARDWARE_MULTIPLY_PRESENT 1
#define ALT_CPU_HARDWARE_MULX_PRESENT 0
#define ALT_CPU_HAS_DEBUG_CORE 1
#define ALT_CPU_HAS_DEBUG_STUB
#define ALT_CPU_HAS_EXTRA_EXCEPTION_INFO
#define ALT_CPU_HAS_ILLEGAL_INSTRUCTION_EXCEPTION
#define ALT_CPU_HAS_JMPI_INSTRUCTION
#define ALT_CPU_ICACHE_LINE_SIZE 32
#define ALT_CPU_ICACHE_LINE_SIZE_LOG2 5
#define ALT_CPU_ICACHE_SIZE 4096
#define ALT_CPU_INITDA_SUPPORTED
#define ALT_CPU_INST_ADDR_WIDTH 0x1b
#define ALT_CPU_NAME "cpu"
#define ALT_CPU_NUM_OF_SHADOW_REG_SETS 0
#define ALT_CPU_OCI_VERSION 1
#define ALT_CPU_RESET_ADDR 0x05080000
. J8 D0 O$ I$ ]* \" [+ Z" Y

/ B( l) ^9 [5 \/ f% @
/*
* CPU configuration (with legacy prefix - don't use these anymore)
*
*/
. ~3 S* c2 n4 Y0 |  c2 z7 b" ?( F* O
#define NIOS2_BIG_ENDIAN 0
#define NIOS2_BREAK_ADDR 0x05100820
#define NIOS2_CPU_ARCH_NIOS2_R1
#define NIOS2_CPU_FREQ 100000000u
#define NIOS2_CPU_ID_SIZE 1
#define NIOS2_CPU_ID_VALUE 0x00000000
#define NIOS2_CPU_IMPLEMENTATION "fast"
#define NIOS2_DATA_ADDR_WIDTH 0x1b
#define NIOS2_DCACHE_BYPASS_MASK 0x80000000
#define NIOS2_DCACHE_LINE_SIZE 32
#define NIOS2_DCACHE_LINE_SIZE_LOG2 5
#define NIOS2_DCACHE_SIZE 2048
#define NIOS2_EXCEPTION_ADDR 0x05080020
#define NIOS2_FLASH_ACCELERATOR_LINES 0
#define NIOS2_FLASH_ACCELERATOR_LINE_SIZE 0
#define NIOS2_FLUSHDA_SUPPORTED
#define NIOS2_HARDWARE_DIVIDE_PRESENT 0
#define NIOS2_HARDWARE_MULTIPLY_PRESENT 1
#define NIOS2_HARDWARE_MULX_PRESENT 0
#define NIOS2_HAS_DEBUG_CORE 1
#define NIOS2_HAS_DEBUG_STUB
#define NIOS2_HAS_EXTRA_EXCEPTION_INFO
#define NIOS2_HAS_ILLEGAL_INSTRUCTION_EXCEPTION
#define NIOS2_HAS_JMPI_INSTRUCTION
#define NIOS2_ICACHE_LINE_SIZE 32
#define NIOS2_ICACHE_LINE_SIZE_LOG2 5
#define NIOS2_ICACHE_SIZE 4096
#define NIOS2_INITDA_SUPPORTED
#define NIOS2_INST_ADDR_WIDTH 0x1b
#define NIOS2_NUM_OF_SHADOW_REG_SETS 0
#define NIOS2_OCI_VERSION 1
#define NIOS2_RESET_ADDR 0x05080000

" k+ k4 W3 b3 n* b& O  q+ A$ ]3 M" d! L4 \3 N
/*
* Define for each module class mastered by the CPU
*
*/

- A! l# P6 [) d9 s
#define __ALTERA_AVALON_JTAG_UART
#define __ALTERA_AVALON_NEW_SDRAM_CONTROLLER
#define __ALTERA_AVALON_ONCHIP_MEMORY2
#define __ALTERA_AVALON_PIO
#define __ALTERA_AVALON_SYSID_QSYS
#define __ALTERA_AVALON_TIMER
#define __ALTERA_NIOS2_GEN2
#define __SEG7_IF
3 |& \* y. C3 v7 S3 z; c' g1 J
6 j6 z1 [6 h- Q. J* K
/*
* System configuration
*
*/

, z+ S9 L) m% U% H; d) q
#define ALT_DEVICE_FAMILY "Cyclone V"
#define ALT_ENHANCED_INTERRUPT_API_PRESENT
#define ALT_IRQ_BASE NULL
#define ALT_LOG_PORT "/dev/null"
#define ALT_LOG_PORT_BASE 0x0
#define ALT_LOG_PORT_DEV null
#define ALT_LOG_PORT_TYPE ""
#define ALT_NUM_EXTERNAL_INTERRUPT_CONTROLLERS 0
#define ALT_NUM_INTERNAL_INTERRUPT_CONTROLLERS 1
#define ALT_NUM_INTERRUPT_CONTROLLERS 1
#define ALT_STDERR "/dev/jtag_uart"
#define ALT_STDERR_BASE 0x5101028
#define ALT_STDERR_DEV jtag_uart
#define ALT_STDERR_IS_JTAG_UART
#define ALT_STDERR_PRESENT
#define ALT_STDERR_TYPE "altera_avalon_jtag_uart"
#define ALT_STDIN "/dev/jtag_uart"
#define ALT_STDIN_BASE 0x5101028
#define ALT_STDIN_DEV jtag_uart
#define ALT_STDIN_IS_JTAG_UART
#define ALT_STDIN_PRESENT
#define ALT_STDIN_TYPE "altera_avalon_jtag_uart"
#define ALT_STDOUT "/dev/jtag_uart"
#define ALT_STDOUT_BASE 0x5101028
#define ALT_STDOUT_DEV jtag_uart
#define ALT_STDOUT_IS_JTAG_UART
#define ALT_STDOUT_PRESENT
#define ALT_STDOUT_TYPE "altera_avalon_jtag_uart"
#define ALT_SYSTEM_NAME "audio_nios"

/ g: r* C! T- m0 H) W2 I) n8 _5 n- N
/*
* altera_hostfs configuration
*
*/
5 T5 M* |7 O7 Z  Y) E' t
#define ALTERA_HOSTFS_NAME "/mnt/host"

3 [" c- s2 |5 X  g8 _* H% B& }) u. ^" _& P
/*
* altera_ro_zipfs configuration
*
*/

$ i1 F) B5 x5 V0 m0 A9 E
#define ALTERA_RO_ZIPFS_BASE 0x0
#define ALTERA_RO_ZIPFS_NAME "/mnt/rozipfs"
#define ALTERA_RO_ZIPFS_OFFSET 0x100000

  U  C' ?1 i6 J- r# \: j7 c4 O* X( y; j. E( Z. g& s
/*
* din32 configuration
*
*/
# n7 ?; P- Z1 l, O/ y; S& \# a; E
#define ALT_MODULE_CLASS_din32 altera_avalon_pio
#define DIN32_BASE 0x4000050
#define DIN32_BIT_CLEARING_EDGE_REGISTER 0
#define DIN32_BIT_MODIFYING_OUTPUT_REGISTER 0
#define DIN32_CAPTURE 0
#define DIN32_DATA_WIDTH 32
#define DIN32_DO_TEST_BENCH_WIRING 0
#define DIN32_DRIVEN_SIM_VALUE 0
#define DIN32_EDGE_TYPE "NONE"
#define DIN32_FREQ 10000000
#define DIN32_HAS_IN 1
#define DIN32_HAS_OUT 0
#define DIN32_HAS_TRI 0
#define DIN32_IRQ -1
#define DIN32_IRQ_INTERRUPT_CONTROLLER_ID -1
#define DIN32_IRQ_TYPE "NONE"
#define DIN32_NAME "/dev/din32"
#define DIN32_RESET_VALUE 0
#define DIN32_SPAN 16
#define DIN32_TYPE "altera_avalon_pio"
+ y0 x' _. w* ?9 ~
' X/ ]0 D7 b' @& p, Y. |
/*
* hal configuration
*
*/

: F3 W. V' o' M- L
#define ALT_MAX_FD 32
#define ALT_SYS_CLK TIMER
#define ALT_TIMESTAMP_CLK TIMER

) j! l  E2 b" K' j& X, g5 k* W6 }1 ?
2 q9 F: q9 G7 p4 V
/*
* jtag_uart configuration
*
*/
- c+ }* Z) f: P2 T# x! ~
#define ALT_MODULE_CLASS_jtag_uart altera_avalon_jtag_uart
#define JTAG_UART_BASE 0x5101028
#define JTAG_UART_IRQ 0
#define JTAG_UART_IRQ_INTERRUPT_CONTROLLER_ID 0
#define JTAG_UART_NAME "/dev/jtag_uart"
#define JTAG_UART_READ_DEPTH 64
#define JTAG_UART_READ_THRESHOLD 8
#define JTAG_UART_SPAN 8
#define JTAG_UART_TYPE "altera_avalon_jtag_uart"
#define JTAG_UART_WRITE_DEPTH 64
#define JTAG_UART_WRITE_THRESHOLD 8
, c+ ~! x1 S* {' _# q

# w. \; Y, L1 S) q
/*
* key configuration
*
*/
! D* V+ t; p' h$ ~; C1 A3 ]) _; l
#define ALT_MODULE_CLASS_key altera_avalon_pio
#define KEY_BASE 0x4000080
#define KEY_BIT_CLEARING_EDGE_REGISTER 0
#define KEY_BIT_MODIFYING_OUTPUT_REGISTER 0
#define KEY_CAPTURE 1
#define KEY_DATA_WIDTH 4
#define KEY_DO_TEST_BENCH_WIRING 0
#define KEY_DRIVEN_SIM_VALUE 0
#define KEY_EDGE_TYPE "FALLING"
#define KEY_FREQ 10000000
#define KEY_HAS_IN 1
#define KEY_HAS_OUT 0
#define KEY_HAS_TRI 0
#define KEY_IRQ 1
#define KEY_IRQ_INTERRUPT_CONTROLLER_ID 0
#define KEY_IRQ_TYPE "EDGE"
#define KEY_NAME "/dev/key"
#define KEY_RESET_VALUE 0
#define KEY_SPAN 16
#define KEY_TYPE "altera_avalon_pio"
0 M6 |5 A* [6 V4 C9 {( k& Z

  Z/ K3 ~  G7 ^9 l3 D
/*
* onchip_memory2 configuration
*
*/

; X) q" u( l+ A" E
#define ALT_MODULE_CLASS_onchip_memory2 altera_avalon_onchip_memory2
#define ONCHIP_MEMORY2_ALLOW_IN_SYSTEM_MEMORY_CONTENT_EDITOR 0
#define ONCHIP_MEMORY2_ALLOW_MRAM_SIM_CONTENTS_ONLY_FILE 0
#define ONCHIP_MEMORY2_BASE 0x5080000
#define ONCHIP_MEMORY2_CONTENTS_INFO ""
#define ONCHIP_MEMORY2_DUAL_PORT 0
#define ONCHIP_MEMORY2_GUI_RAM_BLOCK_TYPE "AUTO"
#define ONCHIP_MEMORY2_INIT_CONTENTS_FILE "audio_nios_onchip_memory2"
#define ONCHIP_MEMORY2_INIT_MEM_CONTENT 1
#define ONCHIP_MEMORY2_INSTANCE_ID "NONE"
#define ONCHIP_MEMORY2_IRQ -1
#define ONCHIP_MEMORY2_IRQ_INTERRUPT_CONTROLLER_ID -1
#define ONCHIP_MEMORY2_NAME "/dev/onchip_memory2"
#define ONCHIP_MEMORY2_NON_DEFAULT_INIT_FILE_ENABLED 0
#define ONCHIP_MEMORY2_RAM_BLOCK_TYPE "AUTO"
#define ONCHIP_MEMORY2_READ_DURING_WRITE_MODE "DONT_CARE"
#define ONCHIP_MEMORY2_SINGLE_CLOCK_OP 0
#define ONCHIP_MEMORY2_SIZE_MULTIPLE 1
#define ONCHIP_MEMORY2_SIZE_VALUE 320000
#define ONCHIP_MEMORY2_SPAN 320000
#define ONCHIP_MEMORY2_TYPE "altera_avalon_onchip_memory2"
#define ONCHIP_MEMORY2_WRITABLE 1

. K0 A' o4 t" W+ a; p% {
* k+ [7 s& ]! q+ d) i- Z
/*
* pio_led configuration
*
*/

- A% Z& {7 I- H+ }9 ~
#define ALT_MODULE_CLASS_pio_led altera_avalon_pio
#define PIO_LED_BASE 0x4000070
#define PIO_LED_BIT_CLEARING_EDGE_REGISTER 0
#define PIO_LED_BIT_MODIFYING_OUTPUT_REGISTER 0
#define PIO_LED_CAPTURE 0
#define PIO_LED_DATA_WIDTH 10
#define PIO_LED_DO_TEST_BENCH_WIRING 0
#define PIO_LED_DRIVEN_SIM_VALUE 0
#define PIO_LED_EDGE_TYPE "NONE"
#define PIO_LED_FREQ 10000000
#define PIO_LED_HAS_IN 0
#define PIO_LED_HAS_OUT 1
#define PIO_LED_HAS_TRI 0
#define PIO_LED_IRQ -1
#define PIO_LED_IRQ_INTERRUPT_CONTROLLER_ID -1
#define PIO_LED_IRQ_TYPE "NONE"
#define PIO_LED_NAME "/dev/pio_led"
#define PIO_LED_RESET_VALUE 0
#define PIO_LED_SPAN 16
#define PIO_LED_TYPE "altera_avalon_pio"

0 y2 c" H8 _- r/ N& @3 {
- y/ ^  Y1 I5 g9 B, F8 o
/*
* rd_empt configuration
*
*/

2 ]. d9 s+ c! y, A  U3 W, h  Q4 U" P
#define ALT_MODULE_CLASS_rd_empt altera_avalon_pio
#define RD_EMPT_BASE 0x4000020
#define RD_EMPT_BIT_CLEARING_EDGE_REGISTER 0
#define RD_EMPT_BIT_MODIFYING_OUTPUT_REGISTER 0
#define RD_EMPT_CAPTURE 0
#define RD_EMPT_DATA_WIDTH 1
#define RD_EMPT_DO_TEST_BENCH_WIRING 0
#define RD_EMPT_DRIVEN_SIM_VALUE 0
#define RD_EMPT_EDGE_TYPE "NONE"
#define RD_EMPT_FREQ 10000000
#define RD_EMPT_HAS_IN 1
#define RD_EMPT_HAS_OUT 0
#define RD_EMPT_HAS_TRI 0
#define RD_EMPT_IRQ -1
#define RD_EMPT_IRQ_INTERRUPT_CONTROLLER_ID -1
#define RD_EMPT_IRQ_TYPE "NONE"
#define RD_EMPT_NAME "/dev/rd_empt"
#define RD_EMPT_RESET_VALUE 0
#define RD_EMPT_SPAN 16
#define RD_EMPT_TYPE "altera_avalon_pio"

8 ?* Y3 R6 C+ P) q
  a: n' _2 i) _) B: r4 Y$ u
/*
* rd_rqt configuration
*
*/

7 e- [) V4 `$ P2 N* G
#define ALT_MODULE_CLASS_rd_rqt altera_avalon_pio
#define RD_RQT_BASE 0x4000030
#define RD_RQT_BIT_CLEARING_EDGE_REGISTER 0
#define RD_RQT_BIT_MODIFYING_OUTPUT_REGISTER 0
#define RD_RQT_CAPTURE 0
#define RD_RQT_DATA_WIDTH 1
#define RD_RQT_DO_TEST_BENCH_WIRING 0
#define RD_RQT_DRIVEN_SIM_VALUE 0
#define RD_RQT_EDGE_TYPE "NONE"
#define RD_RQT_FREQ 10000000
#define RD_RQT_HAS_IN 0
#define RD_RQT_HAS_OUT 1
#define RD_RQT_HAS_TRI 0
#define RD_RQT_IRQ -1
#define RD_RQT_IRQ_INTERRUPT_CONTROLLER_ID -1
#define RD_RQT_IRQ_TYPE "NONE"
#define RD_RQT_NAME "/dev/rd_rqt"
#define RD_RQT_RESET_VALUE 0
#define RD_RQT_SPAN 16
#define RD_RQT_TYPE "altera_avalon_pio"
6 G. j" k0 B. [+ W9 F
4 Z; @) Y! x4 o2 m$ m
/*
* sdram configuration
*
*/
2 Y# j' D! f! m+ s# I. N
#define ALT_MODULE_CLASS_sdram altera_avalon_new_sdram_controller
#define SDRAM_BASE 0x0
#define SDRAM_CAS_LATENCY 3
#define SDRAM_CONTENTS_INFO
#define SDRAM_INIT_NOP_DELAY 0.0
#define SDRAM_INIT_REFRESH_COMMANDS 2
#define SDRAM_IRQ -1
#define SDRAM_IRQ_INTERRUPT_CONTROLLER_ID -1
#define SDRAM_IS_INITIALIZED 1
#define SDRAM_NAME "/dev/sdram"
#define SDRAM_POWERUP_DELAY 100.0
#define SDRAM_REFRESH_PERIOD 15.625
#define SDRAM_REGISTER_DATA_IN 1
#define SDRAM_SDRAM_ADDR_WIDTH 0x19
#define SDRAM_SDRAM_BANK_WIDTH 2
#define SDRAM_SDRAM_COL_WIDTH 10
#define SDRAM_SDRAM_DATA_WIDTH 16
#define SDRAM_SDRAM_NUM_BANKS 4
#define SDRAM_SDRAM_NUM_CHIPSELECTS 1
#define SDRAM_SDRAM_ROW_WIDTH 13
#define SDRAM_SHARED_DATA 0
#define SDRAM_SIM_MODEL_BASE 1
#define SDRAM_SPAN 67108864
#define SDRAM_STARVATION_INDICATOR 0
#define SDRAM_TRISTATE_BRIDGE_SLAVE ""
#define SDRAM_TYPE "altera_avalon_new_sdram_controller"
#define SDRAM_T_AC 6.0
#define SDRAM_T_MRD 3
#define SDRAM_T_RCD 20.0
#define SDRAM_T_RFC 70.0
#define SDRAM_T_RP 20.0
#define SDRAM_T_WR 14.0
/*
* seg7 configuration
*
*/
+ {8 s+ @/ \$ q" b4 b+ f9 O
#define ALT_MODULE_CLASS_seg7 SEG7_IF
#define SEG7_BASE 0x4000000
#define SEG7_IRQ -1
#define SEG7_IRQ_INTERRUPT_CONTROLLER_ID -1
#define SEG7_NAME "/dev/seg7"
#define SEG7_SPAN 32
#define SEG7_TYPE "SEG7_IF"
; W0 A( D0 I6 w7 G/ Q
8 q& U: ~6 O( F4 [
/*
* sw configuration
*
*/

  T% y9 h4 ]4 Q& A( n. a
#define ALT_MODULE_CLASS_sw altera_avalon_pio
#define SW_BASE 0x4000060
#define SW_BIT_CLEARING_EDGE_REGISTER 0
#define SW_BIT_MODIFYING_OUTPUT_REGISTER 0
#define SW_CAPTURE 1
#define SW_DATA_WIDTH 10
#define SW_DO_TEST_BENCH_WIRING 0
#define SW_DRIVEN_SIM_VALUE 0
#define SW_EDGE_TYPE "FALLING"
#define SW_FREQ 10000000
#define SW_HAS_IN 1
#define SW_HAS_OUT 0
#define SW_HAS_TRI 0
#define SW_IRQ 2
#define SW_IRQ_INTERRUPT_CONTROLLER_ID 0
#define SW_IRQ_TYPE "EDGE"
#define SW_NAME "/dev/sw"
#define SW_RESET_VALUE 0
#define SW_SPAN 16
#define SW_TYPE "altera_avalon_pio"

2 R) j' B# i4 ]& P! o- j% i9 O9 o7 e  Z) r) u
/*
* sysid_qsys configuration
*
*/
. w" t$ x& o6 H3 D4 W. f
#define ALT_MODULE_CLASS_sysid_qsys altera_avalon_sysid_qsys
#define SYSID_QSYS_BASE 0x5101020
#define SYSID_QSYS_ID 0
#define SYSID_QSYS_IRQ -1
#define SYSID_QSYS_IRQ_INTERRUPT_CONTROLLER_ID -1
#define SYSID_QSYS_NAME "/dev/sysid_qsys"
#define SYSID_QSYS_SPAN 8
#define SYSID_QSYS_TIMESTAMP 1433211715
#define SYSID_QSYS_TYPE "altera_avalon_sysid_qsys"

  W3 }3 z% s0 o6 v7 m
6 M, ]; W7 u* l
/*
* timer configuration
*
*/

: ^' z( D! f( i! A# c6 B
#define ALT_MODULE_CLASS_timer altera_avalon_timer
#define TIMER_ALWAYS_RUN 0
#define TIMER_BASE 0x5101000
#define TIMER_COUNTER_SIZE 32
#define TIMER_FIXED_PERIOD 0
#define TIMER_FREQ 100000000
#define TIMER_IRQ 3
#define TIMER_IRQ_INTERRUPT_CONTROLLER_ID 0
#define TIMER_LOAD_VALUE 99999
#define TIMER_MULT 0.001
#define TIMER_NAME "/dev/timer"
#define TIMER_PERIOD 1
#define TIMER_PERIOD_UNITS "ms"
#define TIMER_RESET_OUTPUT 0
#define TIMER_SNAPSHOT 1
#define TIMER_SPAN 32
#define TIMER_TICKS_PER_SEC 1000
#define TIMER_TIMEOUT_PULSE_OUTPUT 0
#define TIMER_TYPE "altera_avalon_timer"
3 x" q9 n; k" y1 \+ L7 B
$ [! ]  f' i( P
/*
* wr_full configuration
*
*/

0 v4 T' m: B) x3 `( V  `! b
#define ALT_MODULE_CLASS_wr_full altera_avalon_pio
#define WR_FULL_BASE 0x4000040
#define WR_FULL_BIT_CLEARING_EDGE_REGISTER 0
#define WR_FULL_BIT_MODIFYING_OUTPUT_REGISTER 0
#define WR_FULL_CAPTURE 1
#define WR_FULL_DATA_WIDTH 1
#define WR_FULL_DO_TEST_BENCH_WIRING 0
#define WR_FULL_DRIVEN_SIM_VALUE 0
#define WR_FULL_EDGE_TYPE "RISING"
#define WR_FULL_FREQ 10000000
#define WR_FULL_HAS_IN 1
#define WR_FULL_HAS_OUT 0
#define WR_FULL_HAS_TRI 0
#define WR_FULL_IRQ 4
#define WR_FULL_IRQ_INTERRUPT_CONTROLLER_ID 0
#define WR_FULL_IRQ_TYPE "EDGE"
#define WR_FULL_NAME "/dev/wr_full"
#define WR_FULL_RESET_VALUE 0
#define WR_FULL_SPAN 16
#define WR_FULL_TYPE "altera_avalon_pio"

4 L$ y4 K" `% h
#endif /* __SYSTEM_H_ */
/ e9 c7 u! @3 p) A
2.2 Main.c
#include "my_includes.h"
#include "LED.h"
#include "SEG7.h"
#include <math.h>
#ifdef DEBUG_APP
#define APP_DEBUG(x)    DEBUG(x)
#else
#define APP_DEBUG(x)
#endif
///////////////////////////////////////////////////////////////////////////////
//////////// Internal function prototype & data structure /////////////////////
///////////////////////////////////////////////////////////////////////////////
//================= internal function prototype & data structure definit =====
#define MAX_TRY_CNT         1024
#define USE_SDRAM_FOR_DATA
#ifndef USE_SDRAM_FOR_DATA
#define BUF_SAMPLE_NUM     (96000*5)  // 5 second @ 96K
#endif
void button_monitor_isr(void* context, alt_u32 id);
bool button_monitor_start(volatile alt_u32 *pPressedMask);
void TDC_monitor_isr(void* context, alt_u32 id);
bool TDC_monitor_start(volatile alt_u32 *pPressedMask);
void TEST_monitor_isr(void* context, alt_u32 id);
bool TEST_monitor_start(volatile alt_u32 *pPressedMask);
void display_time_elapsed(alt_u32 sample_num);
void button_monitor_isr(void* context, alt_u32 id) {
        volatile alt_u32* pPressedMask = (volatile alt_u32*) context;
        *pPressedMask |= IORD_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE) & 0x0F; // 4-button
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE, 0);
        printf("in ISR\r\n");
        printf("wr = %d rd = %d \r\n", IORD_ALTERA_AVALON_PIO_DATA(WR_FULL_BASE) & 0x01,
                                               IORD_ALTERA_AVALON_PIO_DATA(RD_EMPT_BASE) & 0x01);
}
bool button_monitor_start(volatile alt_u32 *pPressedMask) {
        bool bSuccess = TRUE;
        // enable interrupt
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(KEY_BASE, 0x0F); // 4-button
        // Reset the edge catpure register
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE, 0);
        printf("in start\r\n");
        // register IRQ
        if (bSuccess
                        && (alt_irq_register(KEY_IRQ, (void *) pPressedMask,
                                        button_monitor_isr) != 0)) {
                printf("[SW-MONITOR]register button IRQ fail\r\n");
                bSuccess = FALSE;
        }
        return bSuccess;
}
void TDC_monitor_isr(void* context, alt_u32 id) {
        volatile alt_u32* pPressedMask = (volatile alt_u32*) context;
        *pPressedMask |= IORD_ALTERA_AVALON_PIO_EDGE_CAP(WR_FULL_BASE) & 0x01; // 1-line in
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(WR_FULL_BASE, 0);
        printf("in fifo-ISR\r\n");
}
bool TDC_monitor_start(volatile alt_u32 *pPressedMask) {
        bool bSuccess = TRUE;
        // enable interrupt
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(WR_FULL_BASE, 0x01); // 4-button
        // Reset the edge catpure register
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(WR_FULL_BASE, 0);
        printf("in fifo-start\r\n");
        // register IRQ
        if (bSuccess
                        && (alt_irq_register(WR_FULL_IRQ, (void *) pPressedMask,
                                        TDC_monitor_isr) != 0)) {
                printf("Fifo IRQ fail\r\n");
                bSuccess = FALSE;
        }
        return bSuccess;
}
void TEST_monitor_isr(void* context, alt_u32 id) {
        volatile alt_u32* pPressedMask = (volatile alt_u32*) context;
        *pPressedMask |= IORD_ALTERA_AVALON_PIO_EDGE_CAP(TEST_SIG_BASE) & 0x01; // 1-line in
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(TEST_SIG_BASE, 0);
        printf("in test-ISR\r\n");
}
bool TEST_monitor_start(volatile alt_u32 *pPressedMask) {
        bool bSuccess = TRUE;
        // enable interrupt
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(TEST_SIG_BASE, 0x01); // 4-button
        // Reset the edge catpure register
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(TEST_SIG_BASE, 0);
        printf("in test-start\r\n");
        // register IRQ
        if (bSuccess
                        && (alt_irq_register(TEST_SIG_IRQ, (void *) pPressedMask,
                                        TEST_monitor_isr) != 0)) {
                printf("TEST IRQ fail\r\n");
                bSuccess = FALSE;
        }
        return bSuccess;
}
void display_time_elapsed(alt_u32 sample_num) {
        // assume sample rate is 48K
        alt_u32 time;
        SEG7_Decimal(123456, 0x04);
}
bool init(void) {
        bool bSuccess = TRUE;
        SEG7_Clear();
        SEG7_Decimal(0x00000000, 0x00);
        return bSuccess;
}
7 @* K* m% U+ j% F- y" ~1 L9 A
7 ^! k! n  J5 F4 p/ l: m* D" U

* f7 Z+ U; x) N0 Y6 H: D) Y- \
int main() {
        volatile alt_u32 button_mask = 0;
        volatile alt_u32 tdc_mask = 0;
        volatile alt_u32 test_mask = 0;
        alt_u32 *pBuf, *pPlaying, *pRecording, RecordLen, PlayLen, data, try_cnt,
                        buf_sample_size;
        printf("\nHello World\n");
        if (!init())
                return 0;
#ifdef USE_SDRAM_FOR_DATA
        pBuf = (alt_u32 *) SDRAM_BASE;
        buf_sample_size = SDRAM_SPAN / sizeof(alt_u32);
#else   
        // alloc memory to stroe PCM data
        buf_sample_size = BUF_SAMPLE_NUM;
        pBuf = malloc(buf_sample_size * sizeof(alt_u32));
        if (!pBuf) {
                LCD_TextOut("malloc fail\n\n");
                printf("malloc fail\r\n");
                return 0;
        }
#endif   
        button_monitor_start(&button_mask);  // button IRQ
        TDC_monitor_start(&tdc_mask);  // TDC IRQ
        TEST_monitor_start(&test_mask);  // TDC IRQ
        printf("ready\n");
0 f4 h& ~7 T/ Y4 J
        // infinite loop
        while (1) {
                //
        }
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-10-9 01:13 , Processed in 0.140625 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表