FPGA萬年曆報告

2022-10-30 01:51:05 字數 3636 閱讀 6485

fpga-cpld原理及應用課程設計報告

題目基於sopc設計萬年曆

一、摘要

設計從系統硬體出發,由cpu、匯流排、ram、外接裝置等構成sopc builder的硬體系統,通過nios ii de2開發的嵌入式軟體編寫並嵌入sopc builder的硬體中實現萬年曆的整體開發。通過應用sopc builder開發工具,設計者可以擺脫傳統的、易於出錯的軟硬體設計細節,從而達到加快專案開發、縮短開發周期、節約開發成本的目的並具有高整合度、設計靈活和可移植性較好。

關鍵詞:萬年曆 sopc sopc builder nios ii de2

二、設計要求

用nios ii de2 開發板的lcd顯示電子鐘的日期和時間。lcd分兩行顯示,第1行顯示年、月、日;第2行顯示時、分、秒。用輸入button[0]來控制lcd行的修改,同時讓nios ii de2開發板上的綠色發光二極體亮滅來表示這個選擇。

當button[0]按一下後,ledg3亮,可以修改年、月和日的數字;再按一下button[0]後,ledg3滅,可以修改時、分和秒的數字。

另外用輸入按鈕button[3]來控制日期和時間的修改,當處於日期修改方式時,每次按動一次button[3],依次更換「年」、「月」和「日」的修改。當處於時間修改方式時,每次按動一次button[3],依次更換「時」、「分」和「秒」的修改。修改物件被選中後,按動button[2]輸入按鈕可以增加顯示的數字;按動button[1]輸入按鈕可以減少顯示的數字。

三、設計內容

1、按鍵資訊

button[3]:「年」、「月」、「日」或「時」、「分」、「秒」切換鍵

button[2]:+鍵

button[1]:-鍵

button[0]:「年」、「月」、「日」與「時」、「分」、「秒」切換鍵

顯示資訊

lcd_line1:顯示「年」、「月」、「日」

lcd_line1:顯示「時」、「分」、「秒」

2、sopc builder 硬體建立

sopc builder是在quartus ii裡的sopc builder進行的,先建立工程,在sopc builder裡新增硬體,包括cpu ,jtag_uart ,ram,lcd,pio,按鍵,led,以及lcd_on。

3、quartus ii硬體處理

硬體會自動建立乙個頂層模組,通過建乙個原理圖來對對應的硬體進行輸入輸出的新增,再鎖定引腳,編譯工程,硬體**。

4、nios ii de2嵌入軟體編寫

在nios ii裡建立工程,選擇相應的模組,編寫需要嵌入的軟體,新增缺少的標頭檔案對應的巨集定義,編譯工程,進行軟體**,在觀察結果。

四、設計步驟

1、開啟quartus ii新建工程

2、開啟sopc builder生成相應的硬體如圖所示

圖配置 建立好後點選generate執行,看是否出錯,然後點選exit退出。

3、呼叫剛才生成的硬體系統,在quartus ii中建立圖形檔案,然後進行引腳鎖定。

引腳鎖定引腳檔案如下:

然後進行編譯,在quartus i下生成檔案如下圖:

圖2. 頂層電路

4、nios ii執行

開啟nios ii ide2,建立工程,選擇count_binary模組,新增乙個的頂層檔案。

在此寫出c語言程式**。

/* * "hello world" example.

* * this example prints 'hello from nios ii' to the stdout stream. it runs on

* the nios ii 'standard', 'full_featured', 'fast', and 'low_cost' example

* designs. it runs with or without the microc/os-ii rtos and requires a stdout

* device in your system's hardware.

* the memory footprint of this hosted application is ~69 kbytes by default

* using the standard reference design.

* * for a reduced footprint version of this template, and an explanation of how

* to reduce the memory footprint for a given application, see the

* "small_hello_world" template.

* */

//key0列選擇 key1 - key2 + key3 選擇某一行

#include <>

#include "altera_**alon_pio_"

#include "alt_"

#include ""

#include <>

#include <>

#include <>

#include ""

int year=2014;

int month=06;

int day=21;

int hour=8;

int minute=20;

int second=30;

int selectkey=1;

int selectkeylr=1;

int key=0;

int shift=0,con=0,step=0;

int flag;

void lcd_init()

void lcd_show_text(char*text)

}void lcd_line1()

void lcd_line2()

判斷按鍵

int push_button(void)

{ if(iord(key_pio_base, 0)!=15)

{usleep(100);

if(iord(key_pio_base, 0)==14) //key3

printf("shift row");

usleep(100);

printf("\n\n");

while(1)

if(iord(key_pio_base,0)==15)break;

flag=1;

return 1;

沒按下的時候退出

if(iord(key_pio_base, 0)==13)

printf("+");

usleep(100);

printf("\n\n");

while(1)

if(iord(key_pio_base,0)==15)break;

flag=1;

return 2;

key2

if(iord(key_pio_base, 0)==11)

printf("-");

usleep(100);

printf("\n\n");

while(1)

if(iord(key_pio_base, 0)==15)

flag=1;

break;

return 3;

key1

if(iord(key_pio_base, 0)==7)

萬年曆開題報告

8 尹勇.微控制器開發環境 vision2的開發指南 m 北京 北京航空航天大學出版社,2004 173 199.9 馬忠梅,籍順心等 微控制器的c語言應用程式設計 m 北京航空航天大學出版社,2001年 10 新編微控制器原理與應用 第二版 西安電子科技大學出版社,2007.2 11 張萌.微控制...

萬年曆的設計與實現

學校 10126學號 01161030 分類號 tp密級公開 本科畢業 設計 學院 系鄂爾多斯學院電子資訊工程系 專業名稱自動化 年級 2011 級 學生姓名張文博 指導教師王俊林 2013年 6月 8 日 摘要本設計為乙個多功能的萬年曆,具有年 月 日 時 分 秒計數顯示功能,以24小時迴圈計數,...

C語言課程設計報告 萬年曆

萬年曆的設計 二 設計要求 1 能夠顯示星期 2 能夠顯示年月日 3 能夠修改 4 當系統時間變動時,能自動跳到相應的時間。三 設計目的 1.通過本項課程設計,可以培養獨立思考 綜合運用所學有關相應知識的能力,能更好的鞏固 c語言程式設計 課程學習的內容,掌握工程軟體設計的基本方法,強化上機動手程式...