بلاگ شخصی کیوان مهدوی

بلاگ شخصی کیوان مهدوی

به وبلاگ رسمی کیوان مهدوی خوش آمدید

شمارنده UpDown سه بیتی

يكشنبه, ۲۴ آذر ۱۳۹۲، ۰۷:۰۸ ب.ظ

هدف ما در این برنامه طراحی یک شمارنده ی Up Down سه بیتی است، که خروجی آن بر روی SevenSegment می باشد.

در این برنامه با توجه به متغیر x، در صورتی که برابر با "0" باشد عدد بعدی را تولید کرده و در صورتی که برابر با "1" باشد عدد قبلی را تولید می نماید

 

 < > 000 < > 111 < > 110 < > 101 < > 100 < > 011 < > 010 < > 001 < >

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

 

entity UpDown is

    Port ( clk1 : in  STD_LOGIC;

              clk2 : in  STD_LOGIC;

              x : in  STD_LOGIC;

              y : out  STD_LOGIC_VECTOR (6 downto 0));

end UpDown;

 

architecture Behavioral of UpDown is

signal clk : STD_LOGIC;

signal p : STD_LOGIC_vector (6 downto 0);

signal st : integer range 0 to 7;

begin

process(clk1, clk2)

begin

            if clk2'event and clk2 = '1' then

                        clk <= clk1;

            end if;

end process;

process (clk)

begin

if clk = '1' and clk'event then

                        if st = 0 then

                                    if x = '0' then

                                                p <= "0000110";

                                                st <= 1;

                                    else

                                                p <= "0000111";

                                                st <= 7;

                                    end if;

                        elsif st = 1 then

                                    if x = '0' then

                                                p <= "1011011";

                                                st <= 2;

                                    else

                                                p <= "0111111";

                                                st <= 0;

                                    end if;

                        elsif st = 2 then

                                    if x = '0' then

                                                p <= "1001111";

                                                st <= 3;

                                    else

                                                p <= "0000110";

                                                st <= 1;

                                    end if;

                        elsif st = 3 then

                                    if x = '0' then

                                                p <= "1100110";

                                                st <= 4;

                                    else

                                                p <= "1011011";

                                                st <= 2;

                                    end if;

                        elsif st = 4 then

                                    if x = '0' then

                                                p <= "1101101";

                                                st <= 5;

                                    else

                                                p <= "1001111";

                                                st <= 3;

                                    end if;

                        elsif st = 5 then

                                    if x = '0' then

                                                p <= "1111101";

                                                st <= 6;

                                    else

                                                p <= "1100110";

                                                st <= 4;

                                    end if;

                        elsif st = 6 then

                                    if x = '0' then

                                                p <= "0000111";

                                                st <= 7;

                                    else

                                                p <= "1101101";

                                                st <= 5;

                                    end if;

                        else

                                    if x = '0' then

                                                p <= "0111111";

                                                st <= 0;

                                    else

                                                p <= "1111101";

                                                st <= 6;

                                    end if;

end if;

end if;

end process;

y <= not p;

end Behavioral;

 

 

۹۲/۰۹/۲۴ موافقین ۱ مخالفین ۰
kvnmahdavi

UpDown

شمارنده

نظرات  (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی