مدار های ترکیبی دیکدر لامپ های هفت قسمتی یکی از دیکدر هایی که اغلب به کار برده می شود،دیکدر 4 به 7 برای تبدیل کد bcd به کد هفت بیتی برای لامپ های seven.

Slides:



Advertisements
Similar presentations
28/10/2007DSD,USIT,GGSIPU1 Latch & Register Inference.
Advertisements

Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
Arbitrary Waveform Discussion 5.5 Example 34.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Shifters Discussion D7.1 Example Bit Shifter.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
Registers VHDL Tutorial R. E. Haskell and D. M. Hanna T2: Sequential Logic Circuits.
Integer Square Root.
Simple Sequential Circuits in VHDL. Contents Sequential circuit examples: - SR latch in dataflow style - D flip-flop in behavioral style - shift register.
Single-Cycle Instructions VHDL Tutorial R. E. Haskell and D. M. Hanna T5: VHDL ROM.
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 3 Khurram Kazi Some of the slides were taken from K Gaj ’ s lecture slides from GMU ’ s VHDL.
4-to-1 Multiplexer: case Statement Discussion D2.3 Example 6.
Sequencing and Control Mano and Kime Sections 8-1 – 8-7.
Finite State Machines Discussion D8.1 Example 36.
7-Segment Displays Digilent Spartan 3 Board Discussion DS-4.2.
7-Segment Displays VHDL Tutorial R. E. Haskell and D. M. Hanna T4: Xilinx LogiBLOX.
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
Random-Access Memory Distributed and Block RAM Discussion D10.3 Example 41.
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Designing with FPGAs ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
1 Part I: SYSTEM DESIGN. 2 Packages and Components Functions and Procedures Problem (Design & Implementation) Additional System Designs.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
Main Project : Simple Processor Mini-Project : 3-bit binary counter (using 7400 series) Memory By Oluwayomi B. Adamo.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
CPE 626 Advanced VLSI Design Lecture 6: VHDL Synthesis Aleksandar Milenkovic
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
CS/EE 3700 : Fundamentals of Digital System Design
기초 회로의 VHDL 설계 XOR SungKyunKwan Univ..
Data Storage VHDL ET062G & ET063G Lecture 4 Najeem Lawal 2012.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
CDA 4253 FGPA System Design Xilinx FPGA Memories
Sequential Logic Design by VHDL
Lecture 11 Xilinx FPGA Memories Part 2
Data Flow and Behavioral Modeling in VHDL 1 MS EMBEDDED SYSTEMS.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Combinational logic circuit
Main Project : Simple Processor Mini-Project : Vending Machine Memory
Part II A workshop by Dr. Junaid Ahmed Zubairi
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Part IV: VHDL CODING.
ECE 4110–5110 Digital System Design
Chapter 6 VHDL models of sequential logic blocks
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
A Data Stack CoreGen Discussion 12.1.
VHDL (VHSIC Hardware Description Language)
A Greatest Common Divisor (GCD) Processor
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
Fibonacci Sequence Lecture L4.1 Lab 3.
Modeling of Circuits with a Regular Structure
Fast, Asynchronous SRAM
Modeling of Circuits with Regular Structure
CprE / ComS 583 Reconfigurable Computing
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
Presentation transcript:

به نام خدا نمونه هایی از برنامه های VHDL استاد دکتر فاتح تهیه کنندگان محمد امین زاده بردیا دل آگاه

مدار های ترکیبی دیکدر لامپ های هفت قسمتی یکی از دیکدر هایی که اغلب به کار برده می شود،دیکدر 4 به 7 برای تبدیل کد bcd به کد هفت بیتی برای لامپ های seven segment می باشد.

مثال:برنامه ای بنویسید که به کمک دیکدر تمامی شماره های یک seven segment را نمایش دهد. library IEEE; use IEEE.std_logic_1164.all; entity seveseg is port ( D: in STD_LOGIC_VECTOR (3 downto 0); S: out STD_LOGIC_VECTOR (6 downto 0) ); end seveseg; --S=abcdefg architecture seveseg_arch of seveseg is begin with D select

S <= "1111110" when "0000",-- Display 0 "0110000" when "0001",-- Display 1 "1101101" when "0010",-- Display 2 "1111001" when "0011",-- Display 3 "0110011" when "0100",-- Display 4 "1011011" when "0101",-- Display 5 "0011111" when "0110",-- Display 6 "1110000" when "0111",-- Display 7 "1111111" when "1000",-- Display 8 "1110011" when "1001",-- Display 9 "0000000" when others;-- Blank for non decimal end seveseg_arch;

سیمولیت

فلیپ فلاپ ها برای ذخیره یک بیت اطلاعات است که مهم ترین آن ها فلیپ فلاپ D و T می باشد.

مثال : برنامه ای برای فلیپ فلاپ D بنویسید که اگر ورودی CLR برابر صفر شود خروجی q-out فلیپ فلاپ برابر صفر شود، در غیر این صورت اگر لبه بالا رونده پالس ساعت رخ دهد، اطلاعات وردی D به خروجی q منتقل شود ibrary IEEE; use IEEE.std_logic_1164.all; entity flipd is port ( d: in STD_LOGIC; clk: in STD_LOGIC; clr: in STD_LOGIC; q_out: out STD_LOGIC ); end flipd; architecture flipd_arch of flipd is

begin process (clk,clr) if clr='0' then q_out <='0'; elsif (clk'event and clk='1') then q_out <=d; end if; end process; end flipd_arch;

سیمولیت

مثال : برنامه ای برای فلیپ فلاپ T بنویسید که در لبه بالارونده پالس ساعت CLK ،اگر وردی T برابر یک باشد خروجی Q مکمل شود در غیر این صورت Q تغییر نکند. library IEEE; use IEEE.std_logic_1164.all; entity flipt is port ( t,clk: in STD_LOGIC; q: buffer STD_LOGIC ); end flipt; architecture flipt_arch of flipt is begin

process (clk) begin if (clk'event and clk='1') then if t='1' then q<=not(q); else q<=q; end if; end process; end flipt_arch;

سیمولیت

ثبات ها ثبات ها برای ذخیره اطلاعت از تعدادی فلیپ فلاپ تشکیل شده است

مثال : برنامه ای برای یک ثبات هشت بیتی با فلیپ فلاپ D بنویسید که در لبه پایین رونده پالس ساعت، اطلاعات وردی D را به خروجی ثبات Q انتقال دهد. library IEEE; use IEEE.std_logic_1164.all; entity registd is port ( d: in STD_LOGIC_VECTOR (7 downto 0); clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (7 downto 0)); end registd; architecture registd_arch of registd is begin

process (clk) begin if (clk'event and clk='0') then q<=d; end if; end process; end registd_arch;

مثال : برنامه ای برای یک ثبات هشت بیتی با فلیپ فلاپ D بنویسید که اگر ورودی ریست برابر یک شود خروجی ثبات Q برابر با صفر شود در غیر این صورت در لبه بالارونده پالس ساعت اگر Initial برابر یک گردد خروجی ثبات Q برابر با 11111111 شود در غیر این صورت وردی D به خروجی Q منتقل شود. library IEEE; use IEEE.std_logic_1164.all; entity registdr is port ( D : in std_logic_vector(0 to 7); Clk,reset,Initial : in std_logic; Q : out std_logic_vector(o to 7) ); End registdr; Architecture registdr_arc of registdr is Begin

Process(clk,reset) Begin If (reset = ‘1’) then Q <= b”00000000”; Elsif (clk’event and clk=‘1’) then if (initial = ‘1’) then q <= b”11111111”; else q <= d; end if; End if; End process; End registdr_arch;

ثبات شیفت دهنده ثبات شیفت دهنده ثباتی است که در لبه پالس ساعت اطلاعات آن یک بیت به راست و چپ شیفت داده می شود.

مثال : برنامه ای بنویسید که در لبه بالا رونده پالس ساعت محتویات یک ثبات هشت بیتی را یک بیت به طرف راست شیفت دهد library IEEE; use IEEE.std_logic_1164.all; entity shift1 is port ( clk: in STD_LOGIC; seri_rig: in STD_LOGIC; qout: buffer STD_LOGIC_VECTOR (7 downto 0) ); end shift1; architecture shift1_arch of shift1 is begin process(clk)

begin if (clk'event and clk='1') then qout(6 downto 0)<=qout(7 downto 1); qout(7)<=seri_rig; end if; end process; end shift1_arch;

برنامه ای بنویسید که اگر load برابر یک شود اطلاعات هشت بیتی data_in در ثبات هشت بیتی qout بار شود یعنی qout = data_in شود، در غیر این صورت در لبه بالاروند پالس ساعت محتویات ثبات qout یک بیت به طرف راست شیفت داده شود. library IEEE; use IEEE.std_logic_1164.all; entity shift2 is port ( clk,load,seri_rig: in STD_LOGIC; data_in: in STD_LOGIC_VECTOR (7 downto 0); qout: buffer STD_LOGIC_VECTOR (7 downto 0)); end shift2; architecture shift2_arch of shift2 is begin

process(clk,load) begin if load='1' then qout<=data_in; elsif(clk'event and clk='1') then qout<=seri_rig & qout(7 downto 1); end if; end process; end shift2_arch;

شمارنده ها شمارنده ها مدار هایی هستند که به ازای هر پالس ساعت یک شمار می اندازد.شمارنده ها می توانند دارای ورودی reset برای صفر کردن ، وردی load جهت بار کردن با یک مقدار اولیه ویا... باشد.

شمارنده هشت بیتی طراحی کنید که در لبه بالا رونده پالس ساعت یک شمار بیاندازد library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; // دستور العمل ریاضی Entity counter2 is port( Clk : std_logic; Count : buffer std_logic_vector(7 downto 0)); End counter2; Architecture counter2_arch of counter2 is Begin

Process(clk) Begin If (clk’event and clk = ‘1’) then Count <= unsigned(count+1); End if; End process; End counter2_arch;

مثال برنامه ی vhdl برای یک شمارنده هشت بیتی که دارای : الف ) وردی پالس ساعت clk ب ) ورودی reset ج )ورودی set برای یک کردن تمامی بیت ها د )ورودی enable برای فعال کردن شمارنده ه)ورودی load برای بار کردن اطلاعات ورودی در لبه بالارونده پالس ساعت و)ورودی هشت بیتی data برای بار کردن شمارنده در حالت اولیه ز)خروجی cnt شمارنده باشد را طراحی نماید

library IEEE; use IEEE. std_logic_1164. all; use ieee library IEEE; use IEEE.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity counter1 is port ( clk: in STD_LOGIC; set,reset: in STD_LOGIC; enable: in STD_LOGIC; load: in STD_LOGIC; data: in STD_LOGIC_VECTOR (7 downto 0); cnt: inout STD_LOGIC_VECTOR (7 downto 0) ); end counter1; architecture counter1_arch of counter1 is begin count: process(clk,set,reset)

begin if reset='1' then cnt<=(others=>'0'); elsif set='1' then cnt<=(others=>'1'); elsif (clk'event and clk='1') then if load='1' then cnt<=data; elsif enable='1' then cnt<=cnt+1; end if; end if; end process count ; end counter1_arch;

حافظه ها حافظه کامپیوتر شامل RAM و ROM می باشد که در زیر نمونه های از برنامه vhdl هر یک را بررسی می کنیم.

مثال :برنامه ای بنویسید که یک ram دارای 16 خانه حافظه 4 بیتی با وردی di و خروجی do باشد به طوری که در لبه بالارونده پالس ساعت اگر سیگنال we برابر یک شود اطلاعات ورودی در آدرس حافظه s نوشته شود.در غیر این صورت محتوای آدرس a حافظه خوانده شود. LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE IEEE.std_logic_unsigned.ALL; entity RAM is port (clk : in std_logic; we : in std_logic; a : in std_logic_vector(3 downto 0); di : in std_logic_vector(3 downto 0); do : out std_logic_vector(3 downto 0)); end RAM;

architecture syn of RAM is type ram_type is array (15 downto 0) of std_logic_vector (3 downto 0); signal RAM : ram_type; begin process (clk) begin if (clk'event and clk = '1') then if (we = '1') then RAM(conv_integer(a)) <= di; do <= (OTHERS => 'Z'); else do <= RAM(conv_integer(a)); end if; end if; end process; end syn;

سیمولیت

برنامه vhdl یک حافظه rom که دارای 32 خانه حافظه 4 بیتی با خروجی do باشد را بنویسید به طوری که در هر لحظه ای که وردی آدرس 5 بیتی در ورودی قرار گرفت محتوای خانه حافظه rom به آدرس مذکور در خروجی do قرار گیرد. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity ROM is port( adr : in std_logic_vector(4 downto 0); do : out std_logic_vector(3 downto 0) ); end ROM;

architecture dataflow of ROM is architecture dataflow of ROM is type rom is array (0 to 31) of std_logic_vector(3 downto 0); constant mem : rom :=( -- Content -- Address "0011", -- 00 "1100", -- 01 "0010", -- 02 "1000", -- 03 "1010", -- 04 "0010", -- 05 "1101", -- 06 "1100", -- 07 "1101", -- 08 "1110", -- 09 "0010", -- 10 "0100", -- 11 "1000", -- 12 "1010", -- 13 "1101", -- 14

"1100", -- 15 "1110", -- 16 "0000", -- 17 "0010", -- 18 "0100", -- 19 "0110", -- 20 "0110", -- 21 "1000", -- 22 "1010", -- 23 "1100", -- 24 "1110", -- 25 "0000", -- 26 "0010", -- 27 "0100", -- 28 "0110", -- 29 "1000", -- 30 "1010" -- 31 ); begin do <= mem(conv_integer(adr)); end dataflow;

سیمولیت

طراحی دستگاه محاسبه و منطقی ALU

مثال : دستگاه ALU طراحی کنید دارای دو وردی A و B چهار بیتی،کنترل OP سه بیتی و خروجی ALU_OUT چهار بیتی باشد و عملیات AND و OR و NAND و NOR و XNOR و NOT را انجام دهد. library ieee; use ieee.std_logic_1164.all; entity logical_alu is port ( a,b : in std_logic_vector(3 downto 0); op : in std_logic_vector(2 downto 0); alu_out: out std_logic_vector(3 downto 0)); end logical_alu; architecture behav of logical_alu is begin alu_out <= (a and b) when op="000" else (a or b) when op="001" else (a nand b) when op="010" else (a nor b) when op="011" else (a xor b) when op="100" else (not a) when op="110" else b; end behav;

مثال : دستگاه ALU طراحی کنید که دارای دو رودی A و B و وردی کنترل SEL دوبیتی و خروجی RES دوبیتی باشد و عملیات جمع و تفریق و AND و OR را انجام دهد. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; Entity alu1 is port( A : in std_logic_vector(1 downto 0); b : in std_logic_vector(1 downto 0); sel : in std_logic_vector(1 downto 0); res : out std_logic_vector(1 downto 0) )’ End alu1; Architecture behv of alu1 is Begin

Process (a,b,sel) Begin Case sel is when “00” => res <= a+b; when “01” => res <= a+(not b) + 1; when “10” => res <= a and b; when “11” => res <= a or b; when others => res <= “xx”; End case; End process; End behv;