1 概述
本設(shè)計(jì)已實(shí)用于國家863計(jì)劃“可擴(kuò)展到T比特的高性能IPv4/v6路由器基礎(chǔ)平臺及實(shí)驗(yàn)系統(tǒng)”項(xiàng)目中。其主要功能是對主控部分的FPGA讀取Flash進(jìn)行控制。
在本項(xiàng)目中,主控部分的FPGA在重啟時(shí)需要從Flash中下載初始化程序。當(dāng)下載完成后,F(xiàn)PGA仍會根據(jù)需要從Flash相應(yīng)地址讀取數(shù)據(jù)。這就要求在FPGA和Flash之間有一塊控制邏輯來控制對Flash的讀取。本設(shè)計(jì)就是完成的對這塊控制邏輯的具體實(shí)現(xiàn)。
本文用VHDL語言在CPLD內(nèi)部編程將其實(shí)現(xiàn)。本文第2節(jié)給出用VHDL語言在CPLD內(nèi)部編程實(shí)現(xiàn)Flash讀取的過程,第3節(jié)對全文進(jìn)行概括總結(jié)。
2 實(shí)現(xiàn)
2.1 器件的選擇
我們選用Xilinx公司XC9500XL 3.3V ISP 系列XC95288XL-7TQ144I芯片。XC95288xl是一個(gè)3.3V的低電壓、高效的CPLD,在通信和計(jì)算機(jī)系統(tǒng)中的有廣泛的應(yīng)用。它包含16個(gè)54V18個(gè)功能塊,提供了6400個(gè)可用的門電路,這些門電路的傳播延時(shí)為6ns.
對于Flash,項(xiàng)目中選擇了Intel公司的Intel StrataFlash系列的256-Mbit J3型Flash.其數(shù)據(jù)寬度可分別支持8位或者16位。
2.2 實(shí)現(xiàn)中的問題及解決方法
項(xiàng)目中選用的Flash的輸出為16位,而向FPGA輸出的數(shù)據(jù)為32位,因此產(chǎn)了數(shù)據(jù)寬度不匹配的問題,解決的方法有兩種:
第一 使用兩塊相同的Flash,分別將其輸出的數(shù)據(jù)送入FPGA接口的高16位和低16位;其缺點(diǎn)是需要增加一塊Flash,從而成本增加。
第二 采用降低讀取速度的方法,把從一塊Flash中連續(xù)兩次讀取的16位數(shù)據(jù)拼接起來,組成一組32位的數(shù)據(jù)后送入FPGA接口。
出于對成本和復(fù)雜度的考慮,在此設(shè)計(jì)中我們采取了第二種方法加以實(shí)現(xiàn)。
2.3 基本設(shè)計(jì)模塊圖

2.4 用VHDL進(jìn)行實(shí)現(xiàn)(注:實(shí)體部分定義可分別參見模塊圖中的劃分)
Flash control 1
process(reset,gclk)
begin
if reset =‘0’ then
count_reset 《=‘0’;
elsif gclk‘event and gclk =’1‘ then
count_reset 《= not(count(4) and count(3) and count(2));
end if;
end process;
process(count_reset,gclk)
begin
if count_reset =’0‘ then
count 《=(others =》’0‘);
elsif gclk’event and gclk =‘1’ then
count 《=count +1;
end if;
end process;
process(count_reset,reset,enable)
begin
if reset =‘0’ then
F_CS 《=‘1’;
F_OE 《=‘1’;
F_WE 《=‘1’;
elsif count_reset =‘0’ then
F_CS 《= ‘1’;
F_OE 《= ‘1’;
F_WE 《= ‘1’;
elsif enable‘event and enable =’1‘ then
F_Abus 《= C_Abus;
F_CS 《= ’0‘;
F_OE 《= ’0‘;
F_WE 《= ’1‘;
C_Dbus 《= F_Dbus;
end if;
end process;
Flash control 2
d_count_rst 《= not(d_count(1) and (not d_count(0)) and empty);
sig_WD 《= not(d_count(1) and (not d_count(0)));
WR_DATA 《= sig_WD;
process(gclk,d_count)
begin
if reset =’0‘ then
d_count 《= ’1‘;
elsif F_CS = ’1‘ then
d_count1 《= not d_count1 ;
if gclk’event and gclk =‘1’ then
d_count2 《= d_count1;
d_count 《= d_count2;
end if;
end if;
end process;
process(reset,d_count,C_Dbus)
begin
if reset = ‘0’ then
data_adder 《= (others =》‘0’);
elsif d_count‘event and d_count = ’0‘ then
data_adder(31 downto 16) 《= C_Dbus;
elsif d_count’event and d_count = ‘1’ then
data_adder(15 downto 0) 《= C_Dbus;
end if;
end process;
enable 《= enable1 and enable2;
process(reset,d_count,F(xiàn)_CS)
begin
if reset = ‘0’ or F_CS = ‘0’ then
enable1 《= ‘1’;
enable2 《= ‘1’;
elsif d_count‘event then
if gclk’event and gclk =‘1’ then
enable1 《= ‘0’;
enable2 《= not enable1;
end if;
end if;
end process;
process(reset,F(xiàn)_CS)
begin
if reset = ‘0’ then
address《= X“400000”;
elsif F_CS = ‘1’ then
C_Abus 《= address;
address 《= adderss +1;
end if;
end process;
process(reset,F(xiàn)_CS)
begin
if reset = ‘0’ then
address《= X“400000”;
data_adder 《=(others =》‘0’);
elsif F_CS = ‘1’;
address 《= adderss +1;
end if;
end process;
process(d_count2,F(xiàn)_CS)
begin
if F_CS = ‘0’ then
enable1 《= ‘1’;
enable 《= ‘1’;
elsif d_count2 = “00” or d_count2 = “01” then
enable 《= ‘0’;
end if;
end process;
process(gclk,sig_WD)
begin
if sig_WD = ‘1’ then
Pulse_RW 《=‘1’;
elsif gclk‘event and gclk =’1‘ then
W_D1 《= sig_WD;
W_D2 《= W_D1;
if empty =’0‘ then
data_adder1 《= data_adder;
Pulse_RW 《= (W_D1 or (not W_D2));
end if;
end if;
end process;
(注:此程序在Xilinx公司的ISE6.2i環(huán)境下用VHDL編程實(shí)現(xiàn),其仿真波形見下圖)

3 結(jié)束語
在實(shí)際應(yīng)用中,以此CPLD對Flash的讀取進(jìn)行控制。仿真結(jié)果及最后的實(shí)際調(diào)試都表明該設(shè)計(jì)符合項(xiàng)目的要求。在程序中通過對讀取的記數(shù)控制,本設(shè)計(jì)可以在不增加Flash片數(shù)的情況下支持16/32/64位的數(shù)據(jù)輸出寬度。可以節(jié)約一定的成本,具有相當(dāng)?shù)撵`活性和實(shí)用性。
責(zé)任編輯:gt
電子發(fā)燒友App













評論