fpga內部存儲
⑴ fpga程序存儲在哪裡 是在外部存儲器 還是內部
你使用的是哪一種FPGA晶元。
FPGA雖然內部是SRAM,但也有含有FLASH的FPGA,外部也可以存儲程序(多種FLASH都可以,EPCS系列主要針對Altera的產品),建議你查看下其datasheet的配置方式那一章節。
⑵ fpga將處理後的數據存儲在哪 ram,還是flash中
FPGA內部是沒有flash的,只有ram,所以應該是在ram里。
⑶ 在FPGA內部做一個1k大小的存儲器,串口首先通過計算機將1k數據送給FPGA,然後,FPGA再通過串口送給計算機
,供你參考吧。
1. 頂層程序與模擬
(1)頂層程序
--文件名:top.vhd。
--功能:頂層映射。
--最後修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity top is
Port (clk32mhz,reset,rxd,xmit_cmd_p_in:in std_logic; --總的輸入輸出信號的定義
rec_ready,txd_out,txd_done_out:out std_logic;
txdbuf_in:in std_logic_vector(7 downto 0); --待發送數據輸入
rec_buf:out std_logic_vector(7 downto 0)); --接收數據緩沖
end top;
architecture Behavioral of top is
component reciever
Port (bclkr,resetr,rxdr:in std_logic;
r_ready:out std_logic;
rbuf:out std_logic_vector(7 downto 0));
end component;
component transfer
Port (bclkt,resett,xmit_cmd_p:in std_logic;
txdbuf:in std_logic_vector(7 downto 0);
txd:out std_logic;
txd_done:out std_logic);
end component;
component baud
Port (clk,resetb:in std_logic;
bclk:out std_logic);
end component;
signal b:std_logic;
begin
u1:baud port map(clk=>clk32mhz,resetb=>reset,bclk=>b); --頂層映射
u2:reciever port map(bclkr=>b,resetr=>reset,rxdr=>rxd,r_ready=>rec_ready,
rbuf=>rec_buf);
u3:transfer port map(bclkt=>b,resett=>reset,xmit_cmd_p=>xmit_cmd_p_in,
txdbuf=>txdbuf_in,txd=>txd_out,txd_done=>txd_done_out);
end Behavioral;
(2)程序模擬
模擬波形圖如圖8.8.5所示。
圖8.8.5 模擬波形
2. 波特率發生器程序與模擬
(1)波特率發生器VHDL程序
--文件名:baud.vhd.
--功能:將外部輸入的32MHz的信號分成頻率為153600Hz的信號。
--最後修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity baud is
Port (clk,resetb:in std_logic;
bclk:out std_logic);
end baud;
architecture Behavioral of baud is
begin
process(clk,resetb)
variable cnt:integer;
begin
if resetb='1' then cnt:=0; bclk<='0'; --復位
elsif rising_edge(clk) then
if cnt>=208 then cnt:=0; bclk<='1'; --設置分頻系數
else cnt:=cnt+1; bclk<='0';
end if;
end if;
end process;
end Behavioral;
(2)程序模擬
模擬波形如圖8.8.6所示。
圖8.8.6 波特率發生器的模擬波形
3. UART發送器程序與模擬
(1)UART發送器VHDL程序
--文件名:transfer.vhd。
--功能:UART發送器。
--說明:系統由五個狀態(x_idle,x_start,x_wait,x_shift,x_stop)和一個進程構成。
--最後修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity transfer is
generic(framlent:integer:=8);
Port (bclkt,resett,xmit_cmd_p:in std_logic; --定義輸入輸出信號
txdbuf:in std_logic_vector(7 downto 0):="11001010";
txd:out std_logic;
txd_done:out std_logic);
end transfer;
architecture Behavioral of transfer is
type states is (x_idle,x_start,x_wait,x_shift,x_stop); --定義個子狀態
signal state:states:=x_idle;
signal tcnt:integer:=0;
begin
process(bclkt,resett,xmit_cmd_p,txdbuf) --主控時序、組合進程
variable xcnt16:std_logic_vector(4 downto 0):="00000"; --定義中間變數
variable xbitcnt:integer:=0;
variable txds:std_logic;
begin
if resett='1' then state<=x_idle; txd_done<='0'; txds:='1'; --復位
elsif rising_edge(bclkt) then
case state is
when x_idle=> --狀態1,等待數據幀發送命令
if xmit_cmd_p='1' then state<=x_start; txd_done<='0';
else state<=x_idle;
end if;
when x_start=> --狀態2,發送信號至起始位
if xcnt16>="01111" then state<=x_wait; xcnt16:="00000";
else xcnt16:=xcnt16+1; txds:='0'; state<=x_start;
end if;
when x_wait=> --狀態3,等待狀態
if xcnt16>="01110" then
if xbitcnt=framlent then state<=x_stop; xbitcnt:=0;
else state<=x_shift;
end if;
xcnt16:="00000";
else xcnt16:=xcnt16+1; state<=x_wait;
end if;
when x_shift=>txds:=txdbuf(xbitcnt); xbitcnt:=xbitcnt+1; state<=x_wait; --狀態4,將待發數據進行並串轉換
when x_stop=> --狀態5,停止位發送狀態
if xcnt16>="01111" then
if xmit_cmd_p='0' then state<=x_idle; xcnt16:="00000";
else xcnt16:=xcnt16; state<=x_stop;
end if; txd_done<='1';
else xcnt16:=xcnt16+1; txds:='1'; state<=x_stop;
end if;
when others=>state<=x_idle;
end case;
end if;
txd<=txds;
end process;
end Behavioral;
UART發送器的模擬波形如圖8.8.7所示。
圖8.8.7 UART發送器的模擬波形
4. UART接收器程序與模擬
(1)UART接收器VHDL程序
--文件名:reciever.vhd。
--功能:UART接受器。
--說明:系統由五個狀態(r_start,r_center,r_wait,r_sample,r_stop)和兩個進程構成
--最後修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity reciever is
generic(framlenr:integer:=8);
Port (bclkr,resetr,rxdr:in std_logic; --定義輸入輸出信號
r_ready:out std_logic;
rbuf:out std_logic_vector(7 downto 0));
end reciever;
architecture Behavioral of reciever is
type states is (r_start,r_center,r_wait,r_sample,r_stop); --定義各子狀態
signal state:states:=r_start;
signal rxd_sync:std_logic;
begin
pro1:process(rxdr)
begin
if rxdr='0' then rxd_sync<='0';
else rxd_sync<='1';
end if;
end process;
pro2:process(bclkr,resetr,rxd_sync) --主控時序、組合進程
variable count:std_logic_vector(3 downto 0); --定義中間變數
variable rcnt:integer:=0;
variable rbufs:std_logic_vector(7 downto 0);
begin
if resetr='1' then state<=r_start; count:="0000"; --復位
elsif rising_edge(bclkr) then
case state is
when r_start=> --狀態1,等待起始位
if rxd_sync='0' then state<=r_center; r_ready<='0'; rcnt:=0;
else state<=r_start; r_ready<='0';
end if;
when r_center=> --狀態2,求出每位的中點
if rxd_sync='0' then
if count="0100" then state<=r_wait; count:="0000";
else count:=count+1; state<=r_center;
end if;
else state<=r_start;
end if;
when r_wait=> --狀態3,等待狀態
if count>="1110" then
if rcnt=framlenr then state<=r_stop;
else state<=r_sample;
end if;
count:="0000";
else count:=count+1; state<=r_wait;
end if;
when r_sample=>rbufs(rcnt):=rxd_sync; rcnt:=rcnt+1;state<=r_wait;
--狀態4,數據位采樣檢測
when r_stop=>r_ready<='1'; rbuf<=rbufs; state<=r_start; --狀態4,輸出幀接收完畢信號
when others=>state<=r_start;
end case;
end if;
end process;
end Behavioral;
⑷ FPGA配置文件在載入後是存儲在FPGA片內還是在片外內存
FPGA配置文件在載入後是存儲在FPGA片內的,否則FPGA是無法配置成你所設計的邏輯的。由於FPGA是易失性器件,所以還需要同時將配置文件存儲在非易失性器件中。這個非易失性器件,既可以置於FPGA片內,也可以放在片外。這要看你選用哪一種FPGA晶元了。
⑸ fpga器件中的存儲器塊有何作用
3.2 FPGA器件中的存儲器塊有何作用?
FPGA器件內通常有片內存儲器,這些片內存儲器速度快,讀操作的時間一般為3~4 ns,寫操作的時間大約為5 ns,或更短,用這些片內存儲器可實現RAM、ROM或FIFO等功能,非常靈活,為實現數字信號處理(DSP)、數據加密或數據壓縮等復雜數字邏輯的設計提供了便利;採用ROM查表方式可以完成數值運算、波形信號發生器等功能,是FPGA設計中一種常用的設計方法。