標籤:
前提:前段時間搞過Plan Ahead 、XPS 、SDK下搭建xilinx 的zynq 7000(zerdboard)的PS和PL聯機實驗,嘗試定義平台、搭建匯流排和DMA,見之前的部落格。
趁熱打鐵,最後一遍過一下altera的Nios II 在3c120片上ram流水燈實驗。
平台:quartus 10 + NIOS II EDK 10,3c120+EPCS16(64)+CFI Flash + Sdram(Sram),這是標配。
1、搭建quartus的硬體平台:
PLL+LE模組(FPGA 本體邏輯模組)+NIOS核(nios),相當於SOPC + FPGA 設計了。
1、1 開啟quartus:
設定晶片、配置EPCS——falsh的引腳:
(不使用epcs的跳過,此處是 cyclone 3環境,要把epcs falsh 的四個引腳設為常規IO,配置完FPGA後當做常規flash來儲存nios的程式用)。
1、2 配置產生sof 、pof檔案:
同樣是在assigned、device、下:
1、3建立圖形化設計檔案 bolck digama/schematic 檔案:
雙擊空白處,添加PLL模組:
1、4 自檢一個LED點亮的檔案,然後編譯、導覽列右鍵檔案產生 creat synbom 檔案,加入到設計檔案中:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
entity my_f_led is
port
(
clk: in std_logic;
rst: in std_logic;
f_usr_led : out std_logic_vector(1 downto 0)
);
end ;
architecture arch_my_f_led of my_f_led is
signal clk_5m:std_logic;
begin
proc1_car_calcu:process(clk,rst)
variable proc1_state : std_logic_vector(7 downto 0);
variable proc1_i : integer range 0 to 15;
variable proc1_cnt : std_logic_vector(23 downto 0);
begin
if rst = ‘0‘ then
proc1_state := (others=>‘0‘) ;
proc1_i := 0 ;
proc1_cnt := (others=>‘0‘) ;
elsif rising_edge(clk) then
proc1_cnt := proc1_cnt + x"000001";
f_usr_led(0) <= proc1_cnt(22);
f_usr_led(1) <= proc1_cnt(23);
end if ;
end process ;
end arch_my_f_led;
1、5 菜單上選擇 tool sopc builder,產生一個sopc,名字自己起,添加nios 免費核、添加jtag uart、PIO、epcs flash、sdram、system id等
對照圖上添加,開始的打算是:
nios核程式存在epcs flash(或者CFI falsh)上(reset vector 選擇),運行在onchip ram 或者SDRAM(sram,下拉選擇)上(exception vector 選擇)。
1、6 接下來菜單、system-》auto——assgin 中斷及基地址、然後下一步、產生sopc檔案及模組,要等很久才完成儲存退出。
1、7 加入project下的nios 核。配上引腳。pll+PL+nios:
1、8編譯前開啟qsf檔案,把epcs的regular io 配置一下:
注意前後順序(設定regular IO 在引腳分配之前),IO的電壓在pin planer裡面就該設定為3.3V,因為epcs 配置電壓就是3.3V。
接下來儲存該檔案,編譯產生sof 及pof,佔用資源是2000 多個LE。
2、接下來開啟nios IDE,建立nios 的軟體
2、1 建立application c/C++ 項目,選擇helloword模板,改一下成led的程式。
2、2 選中導覽列中的hello word 0 項目,右鍵 build project(注意調試就是debug ,完了之後是release版)。
編譯完成後調試是quartus 下載 sof 檔案,即jtag 介面 ,然後選中項目 run as nios hardware;
運行就是flash program,Cable 也是接在jtag上。下面是兩個對應的圖。
2、3 庫檔案及編譯減小體積,這裡程式的。text 及 rodata在 cfi falsh 運行模式下選擇cfi flash ;
我想選擇epcs falsh,編譯總是提示epcs滿了不能放下,導致這個地方卡死了無法繼續進行。
偵錯模式下(在ram裡運行,掉電消失),都選擇sdram 或者ram。
總結:nios我目前只實現在run as hardware 偵錯模式(庫檔案都選擇ram);
程式段放在epcs flsh上編譯老出錯,無法進行下一步;
程式段放在ram上能progarm 到epcs flash,但是掉電後ple部分ok,nios根本跑步起來。
先到這裡吧,畢竟不是標配的運行環境。
quartus 下 實現 nios II 實驗(未完成啊)