|
功能:1、在LCD 上分两行显示 “DE2_70”和“Hello”
2、在NiosII IDE的控制台上显示:“Hello from Nios II!”
C:\Documents and Settings\Frank\My Documents\My Pictures\1.jpg
硬件设计中的顶层文件MY_FIRST_SOPC.v如下:- module MY_FIRST_SOPC
- (
- //////////////////// Clock Input ////////////////////
- iCLK_50, // 50 MHz
- //////////////////// LCD Module 16X2 ////////////////
- oLCD_ON, // LCD Power ON/OFF
- oLCD_BLON, // LCD Back Light ON/OFF
- oLCD_RW, // LCD Read/Write Select, 0 = Write, 1 = Read
- oLCD_EN, // LCD Enable
- oLCD_RS, // LCD Command/Data Select, 0 = Command, 1 = Data
- LCD_D, // LCD Data bus 8 bits
- );
- // PORT declarations
- //==================================================
- //////////////////////// Clock Input ////////////////////////
- input iCLK_50; // 50 MHz
- //////////////////// LCD Module 16X2 ////////////////////////////
- inout [7:0] LCD_D; // LCD Data bus 8 bits
- output oLCD_ON; // LCD Power ON/OFF
- output oLCD_BLON; // LCD Back Light ON/OFF
- output oLCD_RW; // LCD Read/Write Select, 0 = Write, 1 = Read
- output oLCD_EN; // LCD Enable
- output oLCD_RS; // LCD Command/Data Select,
- // 0 = Command, 1 = Data
- //========== 16*2 LCD Module
- assign oLCD_ON = 1'b1; // LCD ON
- assign oLCD_BLON = 1'b1; // LCD Back Light
- // Structural coding
- //==================================================
- DE2_70_SOPC u1 (
- // 1) global signals:
- .clk(iCLK_50),
- .reset_n(1),
- // the_lcd
- .LCD_E_from_the_lcd(oLCD_EN),
- .LCD_RS_from_the_lcd(oLCD_RS),
- .LCD_RW_from_the_lcd(oLCD_RW),
- .LCD_data_to_and_from_the_lcd(LCD_D)
- );
- endmodule
复制代码 锁定引脚:
C:\Documents and Settings\Frank\My Documents\My Pictures\2.png
然后compile/download
软件设计时,编写Hello_world.c- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "system.h"
- void hello_lcd(void);
- int main()
- {
- printf("Hello from Nios II!\n");
- hello_lcd();
-
- return 0;
- }
- void hello_lcd(void){
- FILE *pLCD;
- char szHello[] = "DE2_70\nHello\n";
-
- pLCD = fopen(LCD_NAME, "w");
- if (pLCD){
- fwrite(szHello, strlen(szHello), 1, pLCD);
- //fclose(pLCD);
- }else{
- printf("failed to open LCD\n");
- }
- }
复制代码 |
|