一. 实现功能
在LCD1602上滚动显示"Hello from Nios II"
二. 实验进程
1. 新建工程HelloWorld,顶层实体名HelloWorld;
2.重新设置编译输出目录为../HelloWorld/release;
3.创建SOPC系统HelloWorld_System;
4. Detailed as display;
Notes: 1. CPU: Reset Vector Memory&Exception Vector Memory set on-chip memory;
2. Onchip-memory: Total Memory Size set 30Kbyte;
3. 对于较长字符,常见做法是让字符在LCD上滚动显示,方法即加入一个间隔定时器Interval Timer;
5.Verilog 完成顶层实体:
module HelloWorld( input CLOCK_50, input[0:0] KEY, inout[7:0] LCD_DATA, output LCD_EN, output LCD_RS, output LCD_RW, output LCD_BLON, output LCD_ON ); assign LCD_BLON=1; assign LCD_ON=1; HelloWorld_System u0 ( // 1) global signals: .clk(CLOCK_50), .reset_n(KEY[0]), // the_lcd .LCD_E_from_the_lcd(LCD_EN), .LCD_RS_from_the_lcd(LCD_RS), .LCD_RW_from_the_lcd(LCD_RW), .LCD_data_to_and_from_the_lcd(LCD_DATA) ); endmodule
6. 分析综合,引脚分配
7. 打开Nios II IDE, Switch Workspace: ../HelloWord/software
Note:设置PTF文件时,这个文件的路径不能有空格或者中文;
Note: 配置System Library properties,将stdin,stdout,stderr三项全部设置为lcd, System clock timer设置为Timer, 取消掉Clean Exit(Flush Buffer)和Support C++前的勾,因为我们的程序不会退出,也不包含C++的函数和库.复选中Program never exits,以减小程序体积. Reduced device driver的勾绝对不能选,否则LCD无响应;
8. 工程优化
分别右击应用工程和系统库工程,执行Properties,选中弹出的对话框里的C/C++ Build, 将Configuration设为Release,编译器参数设置为-Os; Project->Build All,编译结果为22K,去System Library Properties 勾上Small C Libray,再次编译,程序只有12K;
9. Nios Ii Program:
* The memory footprint of this hosted application is ~69 kbytes by default #include <stdio.h> int main() { printf("Hello from Nios II!\n"); return 0; }