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

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

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

شمارنده

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

برنامه ی ذیل یک شمارنده ی چهار بیتی است در این برنامه preset و clear از اولویت بالاتری نسبت به clock برخوردار هستند.

از دیگر قابلیت های این برنامه می توان به خروجی آن که بر روی Seven_Segment است اشاره کرد.

 

 

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

 

entity OurCode is

    Port ( clk1 : in  STD_LOGIC;

           clk2 : in  STD_LOGIC;

           preset : in  STD_LOGIC;

           clear : in  STD_LOGIC;

           loud : in  STD_LOGIC;

                                      a : in  STD_LOGIC_VECTOR(3 downto 0);

           increase : in  STD_LOGIC;

           decrease : in  STD_LOGIC;

           y : out  STD_LOGIC_VECTOR (13 downto 0));

end OurCode;

 

architecture Behavioral of OurCode is

signal t:STD_LOGIC_VECTOR (13 downto 0);

signal tm:STD_LOGIC_VECTOR (3 downto 0);

signal clk:STD_LOGIC;

begin

            process(clk1,clk2)

   begin

            if clk2='0' and clk2'event then

            clk<=clk1;

            end if;

   end process;

process(clk,preset,clear,loud,increase,decrease)

begin

if clear = '1' then

tm <= "0000";

elsif preset = '1' then

tm <= "0001";--sgjsgsghgsghgh

elsif (clk='1' and clk'event) then

            if increase = '1' then

                        tm <= tm + "0001";

            elsif decrease = '1' then

                        tm <= tm - "0001";

            elsif loud = '1' then

                        tm <= a;

            end if;

end if;

end process;

            with tm select

            t <= "00000000111111" when "0000",

                                    "00000000000110" when "0001",

                                    "00000001011011" when "0010",

                                    "00000001001111" when "0011",

                                    "00000001100110" when "0100",

                                    "00000001101101" when "0101",

                                    "00000001111101" when "0110",

                                    "00000000000111" when "0111",

                                    "00000001111111" when "1000",

                                    "00000001101111" when "1001",

                                    "00001100111111" when "1010",

                                    "00001100000110" when "1011",

                                    "00001101011011" when "1100",

                                    "00001101001111" when "1101",

                                    "00001101100110" when "1110",

                                    "00001101101101" when others;

            y <= not t;

            end Behavioral;

 

 

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

نظرات  (۰)

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

ارسال نظر

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