嵌入式系统 SOPC(SOC),A case study llxx@ustc.edu.cn
内容提要 本讲的目的 : 介绍嵌入式系统 ; 了解 SOPC 的开发过程
现代计算机系统
嵌入式系统的应用 llxx@ustc.edu.cn 4/87
嵌入式控制系统的软 / 硬件框架 llxx@ustc.edu.cn 5/87
基于 FPGA 的嵌入式系统硬件平台
基于 FPGA 的嵌入式系统结构
FPGA support for embedded systems 硬件 Processor core that can be instantiated on the FPGA chip Altera: 基于 Nios II 微处理器的 SOPC 系统 Xilinx: 基于 MicroBlaze 微处理器的 SOPC 系统 Memory modules and interfaces I/O interfaces Timer/counter circuits 软件 CAD software tools for designing and implementing a system
Nios processor 2000 年,Altera 发布了 Nios 处理器, 这是第一款可用于可编程逻辑器件的可配置的软核处理器 基于 RISC 技术 16 位指令集 16/32 位数据通道 5 级流水线 在一个时钟周期内完成一条指令的处理 具有一种基于 JTAG 的 OCI( 片上仪器 ) 芯核 2004 年,Altera 继推出 CycloneⅡ 和 StratrixⅡ 器件系列后, 又推出支持这些芯片的 NiosⅡ 嵌入式处理器
Nios Ⅱ 系列处理器的特性 种类 CPU 结构片内调试定制指令软件开发工具 32Bit 指令集 特性 32Bit 数据总线和地址总线 2G Byte 寻址空间 32 个通用寄存器 32 个中断源 基于边界扫描测试 (JTAG) 的调试逻辑, 支持硬件断点 数据触发以及片外和片内的调试跟踪 最多达到 256 个用户定义的 CPU 指令 NiosⅡIDE( 集成开发环境 ) 基于 GNU 的编译器 硬件辅助的调试模块
Nios Ⅱ 系列处理器的特性
Nios Ⅱ 系列处理器的指令字
Example of a Nios Ⅱ Processor System
Altera CAD tools:quartus II Quartus II: 用于完成 Nios II 系统的综合 硬件优化 适配 编程下载和硬件系统测试 gate level,chip level,board level SOPC Builder: 用于实现 Nios II 系统的配置 生成 基于 Nios II 处理器的 FPGA 系统, 不包括 FPGA 片外部分 Nios II IDE: 用于软件开发 调试及运行 工程管理器 ; 编辑器和编译器 ; 调试器 ; 闪存编程器 ModelSim: 用于对 SOPC 生成的 Nios II 系统的 HDL 描述进行系统功能仿真 Matlab/DSP Builder 可生成 Nios II 系统的硬件加速器
Nios Ⅱ 嵌入式处理器软 硬件开发流程 (1) Processor Library SOPC Builder GUI Configure Processor Custom Instructions (2) Peripheral Library Hardware Development EDIF Netlist HDL Source Files Testbench Select & Configure Peripherals, IP Connect Blocks Generate IP Modules Software Development Nios II IDE C Header files Custom Library Peripheral Drivers (3) Synthesis & Fitter User Design Other IP Blocks Quartus II Hardware Configuration File Altera PLD (4) Verification & Debug JTAG, Serial, or Ethernet Executable Code On-Chip Debug Software Trace Hard Breakpoints SignalTap II Compiler, Linker, Debugger User Code Libraries RTOS GNU Tools
硬件设计过程 硬件 : 1. 创建一个 Quartus Ⅱ 工程 2. 创建 Nios Ⅱ 系统模块 1 启动 SOPC Builder 2 添加 CPU 和外围器件 3 指定基地址 4 系统设置 5 生成系统模块 3. 将 Nios Ⅱ 系统模块符号添加到 BDF 文件中 4. 编译 Quqrtus Ⅱ 工程 5. 编程 FPGA 软件 : 启动 Nios Ⅱ IDE; 1. 建立新的软件工程, 编写源程序 ; 2. 编译工程 ; 3. 运行程序 ; 4. 调试程序 ; 5. 将程序下载到开发板上的 Flash 中
Elements of the System Contents Tab
System designed using the SOPC Builder
系统生成 运行 ModelSim 软件 SDK 使能 HDL 使能 使能 ModelSim 生成仿真文件 系统生成过程消息栏 SOPC Builder 消息栏
基于 Linux 的计算机系统组成
HAL 系统库
实验 实验一, 门级设计, 波形仿真 完成基本 FPGA 设计流程, 并功能仿真 参考 Quartus10 教程 - 基本.doc 实验二, 基本嵌入式系统 设计一个计算机系统, 并仿真调试 CPU+SRAM+JTAG UART + hello_world_small 参考 SOPC 开发快速入门教程中文版 - 全 - 从 chip 到 sopc.pdf 中第三章第三节的实验一, 但 无需加 pll, 无需关联 FPGA 引脚, 无需 program, 无需 build 基于 ISS 仿真调试, 无需开发板 实验三, 复杂嵌入式系统 完成一个电子钟系统设计 参考 北航 NIOS 教程 ( 全 - 电子钟 ).ppt 实验四, 基于 uc/os 的系统
实验二, 基本嵌入式系统, 仿真调试
User s view of the alarm clock
Block diagram of the alarm clock
Parallel I/O Interface - PIO PIO is a parameterized module that can be used for both input and output purposes. It can be configured at design time as: an input port an output port a bidirectional port
Registers in the PIO interface
Interval Timer Includes a counter whose contents are decremented by one in each clock cycle It can raise an interrupt request when the contents of the counter reach zero It can be programmed for continuous operation, where the counter is reset to its starting value each time its contents are decremented to zero
Registers in the Interval Timer interface
Continued on the next slide Figure 11.6
Continued on the next slide Figure 11.6 (continued)
Continued on the next slide Figure 11.7
Continued on the next slide Figure11.7 (continued)
Continued on the next slide Figure 11.7 (continued)
Figure 11.7 (continued)
Continued on the next slide Figure 11.7 (continued)
Continued on the next slide Figure 11.7 (continued)
Continued on the next slide Figure 11.7 (continued)
Figure 11.7 (continued)
SOPC 系统
llxx@ustc.edu.cn 44/94
实验二, 基本嵌入式系统 -LED, 仿真调试
实验二, 另一种仿真验证模式, 是否可行? 将如下代码转成 Nios II 机器指令, 存入 RAM 编写 testbench, 分析 output 端口 led 的波形
Nios II 的特殊控制指令
GUI Elements on the System Generation Tab