【正文】
11時(shí)給一個(gè)clk脈沖時(shí)co=1且q3q2q1q0=0000;當(dāng)updown=0時(shí)為加法計(jì)數(shù)器bo=0當(dāng)q3q2q1q0=0000時(shí)給一個(gè)clk脈沖時(shí)co=1且q3q2q1q0=1111。三、流程圖 四、源程序library ieee。use 。entity lsh isport(clr,clk,load,updown:in std_logic。d:in integer range 0 to 15。count:out std_logic。q:buffer integer range 0 to 15)。end lsh。architecture one of lsh is beginprocess(clk,clr,d,load,updown)begin if clr=39。039。then q=0。 elsif(clk39。event and clk=39。139。)then if load=39。139。then q=d。 elsif updown=39。039。then q=q+1。 if q=15 then count=39。139。end if。 else q=q1。 if q=0 then count=39。039。end if。 end if。 end if。end process。end one。五、仿真波形使能端clr為0時(shí),輸出始終為0使能端為1,置數(shù)load=1時(shí),在脈沖的作用下,輸出q=輸入d使能端為1,置數(shù)load=0時(shí),實(shí)現(xiàn)如圖所示計(jì)數(shù)功能六、實(shí)驗(yàn)中遇到的問(wèn)題及解決步驟問(wèn)題:編寫(xiě)程序時(shí),由于過(guò)多使用elsif等語(yǔ)句,導(dǎo)致編寫(xiě)的邏輯有點(diǎn)不太清晰,end if 語(yǔ)句有時(shí)候沒(méi)有一一對(duì)應(yīng)清楚,在編譯時(shí)出現(xiàn)錯(cuò)誤。解決方法:嘗試過(guò)過(guò)取消elsif語(yǔ)句,把所有的情況都用if列些出來(lái),雖然程序邏輯上不會(huì)混亂,但是程序顯得比較冗長(zhǎng),為了使程序更精練,我們調(diào)整了程序的結(jié)構(gòu),讓end if與相應(yīng)的if語(yǔ)句對(duì)其,讓程序讀起來(lái)更有邏輯性,條理性。18