【正文】
所以我查閱了。查閱資料對于我有著非常重要的作用。比如,復(fù)位鍵功能實現(xiàn)的不完整性。但是完善的過程才是成長的過程,這里面學(xué)到的東西也最多。當(dāng)然問題還是很多,修改問題和分析問題成為了我完成系統(tǒng)設(shè)計和編程之后的主要任務(wù)。當(dāng)然我在編程的過程中,是分步將不同功能的模塊劃分添加的。上手編程以及編譯,花費的時間并不是很多。經(jīng)過系統(tǒng)框圖的設(shè)計,我已經(jīng)初步確定了各個模塊的使用和端口的選擇。所以,在我選擇了電子琴的課題之后,下手很快。VHDL作為一種編程語言,它的結(jié)構(gòu)清晰,語句簡單,實現(xiàn)方便。八、總結(jié)及結(jié)論經(jīng)過連續(xù)4次課以及自己抽出課余時間查閱資料和課下去過6次實驗室調(diào)試的經(jīng)歷與付出,我最終實現(xiàn)了vhdl編程的電子琴功能的實現(xiàn),其中包括基礎(chǔ)功能和所有提高要求。問題5:復(fù)位信號的設(shè)置和功能完善分析解決:首先要明確復(fù)位信號的具體功能,它不僅僅是使點陣輸出恢復(fù)初始圖形,更應(yīng)該具有停止演奏,原有音符輸入清零的功能。此問題不可消除,換了一塊板子下載成功,按鍵準確而無噪聲。所以首先解決編程問題,核對頻率表后,重新計算了相應(yīng)音符的分頻系數(shù),確實和原先的有所偏差。問題4:對應(yīng)按鍵,有的鍵音不準確。分析解決:出現(xiàn)此問題后,發(fā)現(xiàn)不是記錄有誤,而是記錄出現(xiàn)了跳音的現(xiàn)象,肯定是有的按鍵被判為無效,而按鍵判定部分的函數(shù)主要是根據(jù)分頻后的時鐘沿是否到達判決的,所以可能和分頻系數(shù)太小,導(dǎo)致按鍵時時鐘沿還未到達有關(guān)。分析解決:出現(xiàn)了這個問題后,我迅速使用光標定位找到了出錯模塊,仔細核對模塊的內(nèi)容和頂層文件的聲明內(nèi)容,后來發(fā)現(xiàn)是前后一組矢量的大小不匹配導(dǎo)致的,調(diào)整后,編譯通過。最后經(jīng)過進一步的調(diào)試,修改分頻系數(shù),使得點陣掃描清晰明亮。問題1:點陣輸出不穩(wěn)定,時亮?xí)r滅。我總共使用了5個撥碼開關(guān),8個按鍵,6個數(shù)碼選通管,8個數(shù)碼管分段顯示信號,主頻時鐘,揚聲器輸出,點陣顯示輸出16個引腳,共計45各引腳。且完成狀態(tài)正常良好。而在按鍵錄音時,由于我是用了二維數(shù)組來存儲按鍵信息,按下此鍵,可以清除數(shù)組原有數(shù)據(jù),即以前錄入的按鍵信息,重新錄入新數(shù)據(jù)。需要特別說明的是,BTN0為復(fù)位按鍵,按下有效。BW5,BW2為自動手動錄音選擇,BW5為高電平,對應(yīng)自動播放;BW5為低電平,對應(yīng)手動按鍵演奏;BW2為高電平,則啟動手動按鍵錄音的功能。而高中低音的模式選擇由BW6,BW7組合選擇,二者均為高電平時為高音輸出模式;均為低電平為低音輸出模式;分別對應(yīng)1,0為中音輸出模式。同時本電子琴還具有錄音與播放的功能,可以記錄錄入的任何音調(diào)以及時間的停頓。end behave。 end if。 end if。 if xiabiao=changdu then xiabiao=0。139。 xiabiao作為錄音重播的計數(shù)器 elsif jiepai39。139。139。end process。 else changdu=jishu。 錄入音符數(shù)目加1 end if。 if jishu=100 then jishu=0。139。 復(fù)位有效后,想錄音存儲的原有數(shù)組清除 elsif jiepai39。139。139。end process。 end if。 jiepai = not jiepai。139。beginprocess(clk)begin 產(chǎn)生錄音的節(jié)拍時鐘 if clk39。type shuzu is array(100 downto 0) of std_logic_vector(4 downto 0)。signal jiepai : std_logic。 signal xiabiao : integer range 0 to 50。end store。 重播按鍵 clr : in std_logic。 store1: in std_logic。entity store isport(index_key : in std_logic_vector(4 downto 0)。use 。end a。 end if。 else t=t+1。)then if t=24999 then t=0。event and clk=39。end process p2。 end if。 elsif st1(7 downto 0)=10111111then st1(7 downto 0)=01111111。 elsif st1(7 downto 0)=11011111then st1(7 downto 0)=10111111。 elsif st1(7 downto 0)=11101111then st1(7 downto 0)=11011111。 elsif st1(7 downto 0)=11110111then st1(7 downto 0)=11101111。 elsif st1(7 downto 0)=11111011then st1(7 downto 0)=11110111。 elsif st1(7 downto 0)=11111101then st1(7 downto 0)=11111011。 elsif st1(7 downto 0)=11111110then st1(7 downto 0)=11111101。event)then 這里實現(xiàn)了逐行掃描 if st1(7 downto 0)=00000000or st1(7 downto 0)=01111111then st1(7 downto 0)=11111110。139。 end if。 d6=01111110。 d4=00011110。 d2=00000110。) then d0=00000000。 elsif(clr=39。 d7=11111110。 d5=00111110。 d3=00001110。 無輸入時,列掃描的圖形輸出d1=00000010。 d7=11111100。 d5=00111100。 d3=00001100。 輸入7時,列掃描的圖形輸出d1=00000000。 d7=11111010。 d5=00111010。 d3=00001010。 輸入6時,列掃描的圖形輸出d1=00000010。 d7=11110110。 d5=00110110。 d3=00000110。 輸入5時,列掃描的圖形輸出d1=00000010。 d7=11101110。 d5=00101110。 d3=00001110。 輸入4時,列掃描的圖形輸出d1=00000010。 d7=11011110。 d5=00011110。 d3=00001110。 輸入3時,列掃描的圖形輸出d1=00000010。 d7=10111110。 d5=00111110。 d3=00001110。 輸入2時,列掃描的圖形輸出 d1=00000010。 d7=01111110。 d5=00111110。 d3=00001110。 d1=00000010。039。end process p1。index_store(0)。 index1= index_store(2)amp。139。039。index_key(0)。 index1= index_key(2)amp。039。039。index_auto(0)。 index1= index_auto(2)amp。039。139。lie=st1。 signal index1: std_logic_vector(2 downto 0)。signal t:integer range 0 to 24999。signal lie0,lie1,lie2,lie3,lie4,lie5,lie6,lie7:std_logic_vector(7 downto 0)。signal data:std_logic_vector(7 downto 0)。 End lattice。 clr:in std_logic。 replay:in std_logic。 列 index_auto : in std_logic_vector(4 downto 0)。 lie:out std_logic_vector(7 downto 0)。use 。use 。END fun。 end if。 else t=t+1。)then if t=24999 then t=0。event and clk=39。cat=cat_tmp。end if。 when others=led=0000000。 when 110=led=0000000。 when 100=led=0000000。 when 010=led= 0000000。elsif(cat_tmp=110111 or cat_tmp=111011 or cat_tmp=110111 or cat_tmp=111101 or cat_tmp=111110) then 剩余選通管無顯示 case index1 is when 000=led= 0000000。 when 11=led=1000000。 when 01=led=0000001。 end case。 when 111=led=1110000。 when 101=led=1011011。 when 011=led=1111001。 when 001=led= 0110000。end if。 when others=cat_tmp=111110。 when101111=cat_tmp=011111。 when111011=cat_tmp=110111。) then 數(shù)碼管宣統(tǒng)信號的掃描 case cat_tmp is when111110=cat_tmp=111101。event and clk_tmp=39。end process p0。index_store(0)。 index1= index_store(2)amp。139。039。index_key(0)。 index1= index_key(2)amp。039。039。index_auto(0)。 index1= index_auto(2)amp。039。139。039。 G=led(0)。 E=led(2)。 C=led(4)。 BEGIN A=led(6)。signal index: std_logic_vector(4 downto 0)。signal t:integer range 0 to 24999。ARCHITECTURE fun OF SEG7 ISsignal led:std_logic_vector(6 downto 0)。 DP:OUT std_logic )。 F:OUT std_logic。 D:OUT std_logic。 B:OUT std_logic。 index_store : in std_logic_vector(4 downto 0)。 cat:out std_logic_vector(5 downto 0)。 mode:IN std_logic_vector(1 downto 0)。 index_auto:IN std_logic_vector(4 downto 0)。use 。 數(shù)碼管顯示模塊library ieee。f=1/(2*(tone+1))*f0buzz = clk_data。 end if。 else i = i+1。 then if i = tone then i = 0。event and clk = 39。 signa