【文章內(nèi)容簡介】
when others=bcd=null。 —— 此都為把二進(jìn)制翻譯為 BCD 碼 。 end case。 end process。 end architecture fun。 武漢理工大學(xué)《能力拓展訓(xùn)練》課程設(shè)計(jì)說明書 6 對(duì)十進(jìn)制數(shù) 分位 原理圖如圖 32 所示: 圖 32 對(duì)十進(jìn)制數(shù)分位原理圖 具體程序語言如下: library ieee。 use 。 use 。 entity bcd is port(din:in std_logic_vector(11 downto 0)。 y0,y1,y2:out std_logic_vector(3 downto 0) )。 end bcd。 architecture fun of bcd is begin process (din) is begin case din is when000000000000=y0=0000。y1=0000。y2=0000。 when000000000001=y0=0001。y1=0000。y2=0000。 when000000000010=y0=0010。y1=0000。y2=0000。 when000000000011=y0=0011。y1=0000。y2=0000。 when000000000100=y0=0100。y1=0000。y2=0000。 when000000000101=y0=0101。y1=0000。y2=0000。 when000000000110=y0=0110。y1=0000。y2=0000。 when000000000111=y0=0111。y1=0000。y2=0000。 din[ 11. .0] y 0[ 3. .0]y 1[ 3. .0]y 2[ 3. .0]bc dins t武漢理工大學(xué)《能力拓展訓(xùn)練》課程設(shè)計(jì)說明書 7 when000000001000=y0=1000。y1=0000。y2=0000。 when000000001001=y0=1001。y1=0000。y2=0000 。 。 。 。 when001001000110=y0=0110。y1=0100。y2=0010。 when001001000111=y0=0111。y1=0100。y2=0010。 when001001001000=y0=1000。y1=0100。y2=0010。 when001001001001=y0=1001。y1=0100。y2=0010。 when001001010000=y0=0000。y1=0101。y2=0010。 when001001010001=y0=0001。y1=0101。y2=0010。 when001001010010=y0=0010。y1=0101。y2=0010。 when001001010011=y0=0011。y1=0101。y2=0010。 when001001010100=y0=0100。y1=0101。y2=0010。 when001001010101=y0=0101。y1=0101。y2=0010。 when others=y0=0000。y1=0000。y2=0000。 —— 以上程序都為把輸出的 BCD 碼的個(gè)、十、百位分別存入 y0、 y y2 中。 end case。 end process。 end architecture fun 分別輸出 十進(jìn)制數(shù) 原理圖如圖 33 所示: 圖 33 對(duì)三位分位輸出原理圖 C LK 2y 0[ 3. .0]y 1[ 3. .0]y 2[ 3. .0]D A OU T[3. .0]S E L[ 2. .0]S E LT IM Ein s t4武漢理工大學(xué)《能力拓展訓(xùn)練》課程設(shè)計(jì)說明書 8 具體程序語言如下: library ieee。 use 。 use ieee 。 use ieee 。 entity seltime is port( clk2: std_logic。 y0,y1,y2:IN std_logic _vector(3 downto 0)。 daout:out std_logic _ ector(3 downto 0)。 sel: out std_logic _ vector(2 downto 0))。 end。 architecture fun seltime is signal count: std_logic _ vector(2 downto 0)。 begin sel=count。 process(clk2) begin if clk 239。event and c