以下是我經過壹些改動重新編譯的。仿真後,狀態是正確的。
因為現在是十的六次方分頻,普通仿真工具要做真正的仿真還需要很長時間。當時模仿了壹個多小時。後來我把分頻器換了幾個分頻(只修改了下面的參數)得到狀態函數是正確的,但是輸出不是1S和0.5S,但是這個要求要按照程序寫,因為沒有問題。妳最好找開發板。
我把各種顯示模式設置成壹種狀態,然後改變狀態。如果出了問題,應該是前面的分頻問題。
當然沒有要求。可以假設輸入時鐘是0.5S,然後除以2得到0.1S,可以簡化很多。有問題給我發消息。
我在節目最後加了壹些評論。
圖書館ieee
使用IEEE . STD _ logic _ 1164 . all;
使用IEEE。STD_LOGIC_ARITH。所有;
使用IEEE。STD_LOGIC_UNSIGNED所有;
實體豐溪是港口(
reset,adjust,clk:in STD _ logic;
y:out STD _ logic _ vector(9 down to 0));
結束;
楓溪的建築行為是
信號計數:整數範圍0到6000;-計數器,以秒為單位
信號毫秒1,毫秒2:整數範圍0到500;-分頻,秒
信號second1,second 2:STD _ logic;-1.5秒
信號count clk:STD _ logic;-狀態機觸發時鐘
信號y _ out:STD _ logic _ vector(9 down to 0);
類型狀態是(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,
s12,s13,s14,s15,s16,s17,s18,s19,s20,s 21);-狀態生成,以狀態機的形式輸出所需的更改。
信號狀態:狀態;
開始
過程(CLK,復位)
開始
如果RESET='1 '那麽count & lt=0;second 1 & lt;='0';second2 & lt='0';
埃爾希夫·CLK事件和CLK='1 '那麽
計數& lt= count+1;-毫秒,可調整到您想要的時鐘。
如果計數=6000,則
毫秒1 & lt;=毫秒1+1;
毫秒& lt=毫秒2+1;
計數& lt=0;
結束if;
如果milli seconded 1 = 500 then-1可以調整成妳想要的時鐘。
second 1 & lt;= not second 1;
毫秒1 & lt;=0;
結束if;
如果毫秒2 = 250那麽-0.5s可以調整到妳想要的時鐘。
second2 & lt= not second2
毫秒& lt=0;
結束if;
結束if;
結束進程;
過程(調整、復位)-速度調節。
開始
if (reset='1 ')然後countclk & lt='0';其他
如果adjust='1 ',那麽countclk & lt= second 1;結束if;
如果adjust='0 ',那麽countclk & lt= second2結束if;
結束if;
結束進程;
過程(復位)-狀態轉換
開始
if (reset='1 ')然後
狀態& lt= s0其他
if(上升沿(計數時鐘))則
案例狀態為
當s0 = >時;狀態& lt= s 1;
當s 1 = & gt;狀態& lt= s2
當s2= >時;狀態& lt= s3
當s3 = >時;狀態& lt= s4
當s4= >時;狀態& lt= s5
當s5 = & gt狀態& lt= s6
當s6= >時;狀態& lt= s7
當s7 = >狀態& lt= s8
當s8= >時;狀態& lt= s9
當s9 = & gt狀態& lt= s 10;
當s10 = >時;狀態& lt= s 11;
當s 11 = & gt;狀態& lt= s 12;
當s12= >狀態& lt= s 13;
當s13= >狀態& lt= s 14;
當s14 = >狀態& lt= s 15;
當s15= >狀態& lt= s 16;
當s16= >狀態& lt= s 17;
當s17 = >狀態& lt= s 18;
當s18= >狀態& lt= s 19;
當s19= >狀態& lt= s20
當s20 = & gt狀態& lt= s 21;
當S21= >時;狀態& lt= S0
結束案例;
結束if;
結束if;
結束進程;
處理(復位)-狀態分配輸出。
開始
如果reset='1 ',則
y _ out & lt="1111111111";
其他
案例狀態為
當s0= >時;y _ out & lt="1111111111";
當s 1 = & gt;y _ out & lt="0111111111";
當s2= >時;y _ out & lt="0101111111";
當s3= >時;y _ out & lt="0101011111";
當s4= >時;y _ out & lt="0101010111";
當s5 = & gty _ out & lt="0101010101";
當s6= >時;y _ out & lt="1111111111";
當s7= >y _ out & lt="1011111111";
當s8= >時;y _ out & lt="1010111111";
當s9 = & gty _ out & lt="1010101111";
當s10= >時;y _ out & lt="1010101011";
當s 11 = & gt;y _ out & lt="1010101010";
當s12= >y _ out & lt="1111111111";
當s13= >y _ out & lt="0111111111";
當s14= >y _ out & lt="0011111111";
當s15= >y _ out & lt="0001111111";
當s16= >y _ out & lt="0000111111";
當s17= >y _ out & lt="0000011111";
當s18= >y _ out & lt="0000001111";
當s19= >y _ out & lt="0000000111";
當s20 = & gty _ out & lt="0000000011";
當s21 = >時;y _ out & lt="0000000001";
當別人= & gty _ out & lt= " ZZZZZZZZZZ
結束案例;
結束if;
y & lt= y _ out
結束進程;
結束;