導航:首頁 > 編程語言 > fpga計時器程序

fpga計時器程序

發布時間:2023-08-19 13:54:07

㈠ fpga verilog里一個模塊的時鍾有2種以上的選擇 ,怎麼實現

在always模塊里用case語句吧,這樣調理清晰,我給個例子,程序貼上來之後排版有點亂,你自己排一下版吧

always @(*)
begin
case(lte_switch)
2'h1 : begin // tx only
txnrx_txon = 1'b1;
enable_rxon = 1'b1;
paon = 1'b1;
lna_on = 1'b0;
rfsw = 1'b1;
end
2'h2 : begin // rx only
txnrx_txon = 1'b0;
enable_rxon = 1'b1;
paon = 1'b0;
lna_on = 1'b1;
rfsw = 1'b0;
end
2'h3 : begin
txnrx_txon = 1'b0;
enable_rxon = 1'b0;
paon = 1'b0;
lna_on = 1'b0;
rfsw = 1'b0;
end
default:begin // normal
txnrx_txon = T2K_GPIO14 ;
enable_rxon = T2K_GPIO0 ;
paon = T2K_GPIO15 ;
lna_on = ~paon ;
rfsw = T2K_GPIO14 ;
end
endcase
end

㈡ 基於FPGA技術的數字時鍾萬年歷設計

【實驗目的】:

設計一個24小時制數字鍾,要求能顯示時,分,秒,並且可以手動調整時和分

【試驗中所用器材】:

開發環境MAX—PLUSII,ZY11EDA13BE 試驗系統, VHDL 語言.

【設計原理】

數字鍾的主體是計數器,它記錄並顯示接收到的秒脈沖個數,其中秒和分為模60計數器,小時是模24計數器,分別產生3位BCD碼。BCD碼經解碼,驅動後接數碼管顯示電路。

秒模60計數器的進位作為分模60計數器的時鍾,分模60計數器的進位作為模24計數器的時鍾。

為了實現手動調整時間,在外部增加了setm(調整分),seth(調整時)按鍵,當這兩個按鍵為低電平時,電路正常計時,當為高電平時,分別調整分,時。同時在外部還增加了一個清零按鍵clr.和消抖動電路。

【單元模塊設計部分】

消抖動電路關鍵部分

signal key_in1,key_in2:std_logic:='0';

begin

process(clk,key_in)

begin

if clk'event and clk='1' then

key_in1<=key_in;key_in2<=key_in1;

if key_in='1' and key_in1='1' and key_in2='1' then key_out<='1';

else key_out<='0';

時序模擬圖

模60計數器程序關鍵部分:

signal md_temp,mg_temp:std_logic_vector(3 downto 0);

begin

process(clk,clr)

begin

if clr='1' then

md_temp<="0000"; mg_temp<="0000";

elsif set='1' then

md_temp<=setl; mg_temp<=seth;

elsif clk'event and clk='1' then

if md_temp="1001" then

md_temp<="0000";mg_temp<=mg_temp+'1';

else md_temp<=md_temp+'1';

end if;

if md_temp="1001" and mg_temp="0101" then

md_temp<="0000";mg_temp<="0000";

秒時序模擬圖

分時序模擬

分的清零和調整時間部分

模24計數器程序關鍵部分

signal hd_temp,hg_temp:std_logic_vector(3 downto 0);

begin

process(clk,clr,set,setl,seth)is

begin

if set='1' then hd_temp<=setl; hg_temp<=seth;

elsif clr='1' then hd_temp<="0000"; hg_temp<="0000";

elsif clk'event and clk='1' then

if hg_temp="0010" and hd_temp="0011" then

hd_temp<="0000"; hg_temp<="0000";

elsif hd_temp="1001" then

hg_temp<=hg_temp+'1' hd_temp<="0000";

else hd_temp<=hd_temp+'1';

end if;

end if;

end process ;

時時序模擬圖

清零和調時

顯示部分關鍵程序

process (sd,sg,md,mg,hd,hg)

begin

case sd is

when "0000" =>sl<="1111110";

when "0001" =>sl<="0110000";

when "0010" =>sl<="1101101";

when "0011" =>sl<="1111001";

when "0100" =>sl<="0110011";

when "0101" =>sl<="1011011";

when "0110" =>sl<="1011111";

when "0111" =>sl<="1110000";

when "1000" =>sl<="1111111";

when "1001" =>sl<="1111011";

when others =>sl<="0000000";

end case;

if clk_g'event and clk_g='1' then

if sel="101" then

sel<="000";

else sel<=sel+'1';

end if;

end if;

end process;

process(sel,sd,sl,sg,sh,md,ml,mg,mh,hd,hl,hg,hh)

begin

case sel is

when"000"=>led<=sl;

led_which<=sd;

when"001"=>led<=sh;

led_which<=sg;

when"010"=>led<=ml;

led_which<=md;

when"011"=>led<=mh;

led_which<=mg;

when"100"=>led<=hl;

led_which<=hd;

when"101"=>led<=hh;

led_which<=hg;

when others=>led<="0000000";

led_which<="0000";

end case;

模擬圖

頂層文件關鍵程序

port(

clk,clk_g:in std_logic;-----clk_g是用在數碼管顯示裡面的信號

clr: in std_logic;------clr=1時 清零

setm,seth:in std_logic;---------setm為1時調分,seth為1時調時

setd,setg:in std_logic_vector(3 downto 0);----調整時間的時候,setd調整的是低位setg調整高位

led:out std_logic_vector(6 downto 0);

sel_out: out std_logic_vector(2 downto 0);

led_which: out std_logic_vector(3 downto 0));---輸出的是秒分時的哪一個

begin

u1:de_shake port map (clk=>clk,key_in=>clr,key_out=>clro);

u2:de_shake port map (clk=>clk,key_in=>setm,key_out=>setmo);

u3:de_shake port map (clk=>clk,key_in=>seth,key_out=>setho);

u4:s60 port map (clk=>clk,clr=>clro,sd=>sdl,sg=>sgh,fenmaichong=>fenmaichongo);

u5:m60 port map (clk=>fenmaichongo,clr=>clro,md=>mdl,mg=>mgh,xiaoshimaichong=>xiaoshimaichongo,setl=>setd,seth=>setg,set=>setmo);

u6:h24 port map (clk=>xiaoshimaichongo,clr=>clro,hd=>hdl,hg=>hgh,set=>setho,setl=>setd,seth=>setg);

u7:led_xs port map (clk_g=>clk_g,sd=>sdl,sg=>sgh,md=>mdl,mg=>mgh,hd=>hdl,hg=>hgh,led=>led,sel_out=>sel_out,led_which=>led_which);

㈢ 32MHZ的時鍾,在FPGA中用Verilog語言編寫一個5us的死區程序,請教各位大神有相似的例子能發我一份嗎/

mole d_asyn(clk,clr,d,q); //模塊輸入輸出口,共四個信號,每個都是1bit的
input clk,clr,d; //這些是作為輸入
output q; //這些是作為輸出
reg q; //q在作為寄存器類的輸出,就是說可以用<= 箭頭賦值(見下面)
always @(posedge clr) //posedge:上升沿。就是說在clr信號的上升沿的時候都會觸發這個操作
begin //可以忽略,就是多條語句在一塊的時候要用
q<=0; //清0
end
always @(necedge clk) //negedge:下降沿,你肯定拼錯了 ,在clk下降沿的時候觸發
begin
#10 q<=d; //延遲10個單位,這個在#timescale那裡定義,這個只在模擬的時候有用,在器件上的時候不能這樣做延遲
end
endmole

閱讀全文

與fpga計時器程序相關的資料

熱點內容
linux16進制看elf文件 瀏覽:663
紙檔文件怎麼能變成excel檔 瀏覽:481
迅雷下載總出現jsp 瀏覽:150
創建網頁用什麼編程語言 瀏覽:526
考研哪個app好 瀏覽:30
計算機網路的概念是什麼 瀏覽:625
網路硬碟存儲製作 瀏覽:4
iphone怎麼備份數據到電腦 瀏覽:41
微信小程序報表控制項 瀏覽:722
ipad添加不了qq郵箱賬號和密碼 瀏覽:503
matlab中文文件名 瀏覽:236
excel是啥類型文件 瀏覽:471
安慶培訓編程怎麼選 瀏覽:817
vs2010mfc工具箱 瀏覽:402
刪除文件重置win10怎麼恢復 瀏覽:180
新裝win10有線連不上 瀏覽:785
資料庫商品名唯一怎麼標注 瀏覽:214
電信5g網路什麼時候出 瀏覽:626
手機如何把視頻打包到文件夾裡面 瀏覽:248
excel數據轉vcf文件 瀏覽:585

友情鏈接