Sequential statements (1) process

Slides:



Advertisements
Similar presentations
VHDL Lecture 1 Megan Peck EECS 443 Spring 08.
Advertisements

28/10/2007DSD,USIT,GGSIPU1 Latch & Register Inference.
L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.
Arbitrary Waveform Discussion 5.5 Example 34.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Sequential-Circuit Building Blocks
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
6/27/20061 Sequence Detectors Lecture Notes – Lab 5 Sequence detection is the act of recognizing a predefined series of inputs A sequence detector is a.
6/12/20151 Sequence Detectors Lecture Notes – Lab 4 Sequence detection is the act of recognizing a predefined series of inputs A sequence detector is a.
Finite State Machines Discussion D7.1 Mealy and Moore Machines.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
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.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
Finite State Machines Discussion D8.1 Example 36.
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);
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
ECE 545 Lecture 7 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
Introduction to VHDL (part 2)
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
ENG241 Digital Design Week #8 Registers and Counters.
Main Project : Simple Processor Mini-Project : 3-bit binary counter (using 7400 series) Memory By Oluwayomi B. Adamo.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 6 Mixing Design Styles.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
 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.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
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.
Controllers ENGIN 341 – Advanced Digital Design University of Massachusetts Boston Department of Engineering Dr. Filip Cuckov.
CDA 4253 FPGA System Design Sequential Circuit Building Blocks Hao Zheng Dept of Comp Sci & Eng USF.
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
An Introduction to Verilog: Transitioning from VHDL
Combinational logic circuit
Main Project : Simple Processor Mini-Project : Vending Machine Memory
Lecture L5.1 Mealy and Moore Machines
Registers and Counters
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
Figure 7.1 Control of an alarm system
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Hardware Description Languages
Maj Jeffrey Falkinburg Room 2E46E
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Part IV: VHDL CODING.
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
VHDL (VHSIC Hardware Description Language)
ECE 545 Lecture 6 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
COE 202 Introduction to Verilog
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
The Verilog Hardware Description Language
IAS 0600 Digital Systems Design
ECE 545 Lecture 9 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
The Verilog Hardware Description Language
Advanced Computer Architecture Lecture 1
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
EEL4712 Digital Design (Midterm 1 Review).
Presentation transcript:

Sequential statements (1) process [process_name:] PROCESS (sensitivity list) BEGIN sequential statements END PROCESS [process_name];

COMBINATIONAL PROCESS PROCESS(a, b, c) BEGIN d <= (a AND b) OR c; END PROCESS; ALL input signals must be in sensitivity list or latches will be produced!

If statement (sequential)– describing MUXs If condition1 then signal1 <= value1; signal2 <= value2; elsif condition2 then signal1 <= value3; signal2 <= value4; … [ELSE signal1 <= valuen-1; signal2 <= valuen;] end if; ENTITY mux IS PORT (i0: in std_logic; i1: in std_logic; s: in std_logic; o: out std_logic); END mux; ARCHITECTURE rtl OF mux IS BEGIN process(i0, i1, s) If s = ‘0’ then o <= i0; else o <= i1; end if; end process; END rtl;

CASE statement (sequential)– describing MUXs ENTITY mux IS PORT (i0: in std_logic; i1: in std_logic; s: in std_logic; o: out std_logic); END mux; ARCHITECTURE rtl OF mux IS BEGIN process(i0, i1, s) CASE s IS WHEN ‘0’ => o <= i0; WHEN OTHERS => s <= i1; end CASE; end process; END rtl; CASE expression IS when value1 => signal1 <= value2; signal2 <= value3; when value4 => signal1 <= value4; signal2 <= value5; . . . [when others => signal1 <= valuen-1; signal2 <= valuen;] end CASE;

Example Describe a 3-bit 4-to-1 MUX

CLOCKED PROCESS (Latch with asynchronous reset) PROCESS(clk, rst_n) BEGIN IF rst_n = ‘0’ THEN q <= (others => ‘0’); ELSIF clk= ‘1’ THEN q <= d; END IF; END PROCESS;

CLOCKED PROCESS (Latch with synchronous reset) PROCESS(clk) BEGIN IF clk = ‘1’ THEN if rst_n = ‘0’ then q <= (others => ‘0’); else q <= d; end if; END IF; END PROCESS;

CLOCKED PROCESS (Flip-flop with asynchronous reset) PROCESS(clk, rst_n) BEGIN IF rst_n = ‘0’ THEN q <= (others => ‘0’); ELSIF clk’event and clk= ‘1’ THEN q <= d; END IF; END PROCESS;

CLOCKED PROCESS (Flip-flop with synchronous reset) PROCESS(clk) BEGIN IF clk’event and clk= ‘1’ THEN IF rst_n = ‘0’ THEN q <= (others => ‘0’); else q <= d; end if; END IF; END PROCESS;

for loop statement – shift register [label]: for identifier in range loop statements end loop; ENTITY shift_reg is port(clk, rst_n: in std_logic; input: in std_logic; output: out std_logic); end shift_reg; Architecture rtl of shift_reg is signal d: std_logic_vector(3 downto 0); begin process(clk, rst_n) if rst_n = ‘0’ then d <= (others => ‘0’); elsif rising_edge(clk) then d(0) <= input; for i in 0 to 3 loop d(i+1) <= d(i); end loop; end if; end process; output <= d(3); end;

CLOCKED VS COMBINATIONAL PROCESS (1/2) process(clk, rst) BEGIN If rst = ‘1’ then q <= ‘0’; elsif clk’event and clk = ‘1’ then CASE c IS WHEN ‘0’ => q <= a; WHEN OTHERS => q <= b; end CASE; end if; end process; process(a, b, c) BEGIN CASE c IS WHEN ‘0’ => q <= a; WHEN OTHERS => q <= b; end CASE; end process;

CLOCKED VS COMBINATIONAL PROCESS (2/2) PROCESS(a, b, c) BEGIN d <= (a AND b) OR c; END PROCESS; PROCESS(clk, rst) BEGIN if rst = ‘1’ then d <= ‘0’; elsif clk’event and clk= ‘1’ then d <= (a AND b) OR c; end if; END PROCESS;

EXAMPLE: BINARY UPCOUNTER PROCESS(clk) begin if clk’event and clk=‘1’ then if rst_n = ‘0’ then –-synchronous reset count <= (others => ‘0’); else if en = ‘1’ then --count enable count <= count + ‘1’; end if; end process;

EXAMPLE DESCIBE A BINARY UP/DOWN COUNTER WITH ENABLE THAT COUNTS UPTO 12 AND THEN STARTS AGAIN FROM ZERO

The integer type Signal signal_name: integer range range_low to range_high Examples: Signal count: integer range 0 to 63 -- 6-bit counter Signal k: integer range 0 to 3 -- 2-bit counter

Binary up counter ver2 ARCHITECTURE rtl of counter is signal count: integer range 0 to 31; -- 5-bit counter begin PROCESS(clk) if clk’event and clk=‘1’ then if rst_n = ‘0’ then –-synchronous reset count <= 0; else if en = ‘1’ then --count enable count <= count + 1; end if; end process; end;

TESTBENCH Entity testbench_name is end testbench_name; ARCHITECTURE architecture_name of testbench_name IS COMPONENT declaration Signal declaration --signal clk: std_logic:=‘0’; BEGIN Component instantiation { clk <= not clk after 40 ns; --80 ns clock period a <= ‘1’, ‘0’ after 50 ns, ‘1’ after 100 ns; } end;

TESTBENCH EXAMPLE Entity testbench is end testbench; begin U_mux: mux port map ( i0 =>i0, i1=>i1, s=>s, o=> o); i0 <= ‘0’, ‘1’ after 50 ns, ‘0’ after 100 ns, ‘1’ after 150 ns, ‘0’ after 200 ns, ‘1’ after 250 ns, ‘0’ after 300 ns, ‘1’ after 350 ns; i1 <= ‘0’, ‘1’ after 100 ns, ‘1’ after 300 ns; s <= ‘0’, ‘1’ after 200 ns; end test; Entity testbench is end testbench; Architecture test of testbench is component mux PORT (i0: in std_logic; i1: in std_logic; s: in std_logic; o: out std_logic); END component; signal i0, i1, s, o: std_logic;

FINITE STATE MACHINES

FINITE STATE MACHINE IMPLEMENTATION

Mealy machines (1/3) ENTITY fsm is port(clk, rst_n, a, b: in std_logic; o: out std_logic); END ENTITY fsm; ARCHITECTURE rtl of fsm is Type state is (state0, state1); Signal state_pr, state_nx: state;

Mealy machines (2/4) BEGIN Process(clk, rst_n) --sequential part begin if (rst_n=‘0’) then state_pr <= state0; --default state elsif rising_edge(clk) then state_pr <= state_nx; end if; end process;

Mealy machines (3/4) process(a, state_pr) --combinational part begin CASE state_pr is WHEN state0 => if (a = ‘1’) then state_nx <= state1; output <= <value>; else state_nx <= state0; --optional end if;

Mealy machines (4/4) WHEN state1 => if (a = ‘1’) then state_nx <= state0; output <= <value>; --Mealy machine else state_nx <= state1; --optional output <= <value>; --Mealy machine end if; end CASE; end process;

Moore machines process(a, state_pr) --combinational part begin CASE state_pr is WHEN state0 => output <= <value>; --Moore machine if (a = ‘1’) then state_nx <= state1; else state_nx <= state0; --optional end if;

MOORE MACHINES WHEN state1 => output <= <value>; --Moore machine if (a = ‘1’) then state_nx <= state0; else state_nx <= state1; --optional end if; end CASE; end process;

EXAMPLE: OUT-OF-SEQUENCE COUNTER DESCRIBE A COUNTER WITH THE FOLLOWING SEQUENCE: “000” => “010” => “011” => “001” => “111” => “000”