UART ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.

Slides:



Advertisements
Similar presentations
Sequential Design ELEC 311 Digital Logic and Circuits Dr. Ron Hayne
Advertisements

Floating-Point Arithmetic ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
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.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
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.
RS-232 Port Discussion D7.1. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
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.
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.
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.
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.
Implement UART core on FPGA The High Speed Digital Systems Laboratory Electrical Engineering Faculty, Technion By: Marganit Fina Supervisor: Rivkin Ina.
Finite State Machines Discussion D8.1 Example 36.
SM Charts and Microprogramming
RS-232 Port Lecture L9.3. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
Lecture #5 In this lecture we will introduce the sequential circuits.
1 SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004.
PS/2 Mouse/Keyboard Port Discussion D7.2. PS/2 Port.
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.
Unit 4 Design and Synthesis of Datapath Controllers
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
ELEC / Computer Architecture and Design Fall 2009 ELEC / Computer Architecture and Design Fall 2009 Modeling for Synthesis.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
ENG241 Digital Design Week #8 Registers and Counters.
Digital Design – Hardware Description Languages Chapter 9 - Hardware Description Languages.
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
Design Examples ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
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.
Controllers ENGIN 341 – Advanced Digital Design University of Massachusetts Boston Department of Engineering Dr. Filip Cuckov.
VHDL for Sequential Logic
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
ECE DIGITAL LOGIC LECTURE 20: REGISTERS AND COUNTERS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/19/2015.
INF H131 Clock and Reset Unit (CRU) module library ieee; use ieee.std_logic_1164.all; entity cru is port ( arst : in std_logic; -- Asynch. reset.
VHDL Models For Memory And Busses 구 본 진.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
SCI Communication Proudly Presented By: Adam Cardi & Aaron Enes.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
UART Jin-Fu Li. 2 EE613 VLSI DesignNational Central University Introduction UART (modem)  Universal asynchronous receiver and transmitter Data format.
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Registers and Counters
Figure 7.1 Control of an alarm system
Part II A workshop by Dr. Junaid Ahmed Zubairi
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
ECE 4110–5110 Digital System Design
UART Controller 구현 Lecture #11.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Introduction to ModelSim Implementing Sequential
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
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.
Lecture #5 In this lecture we will introduce the sequential circuits.
Figure 8.1. The general form of a sequential circuit.
Fast, Asynchronous SRAM
Modeling of Circuits with Regular Structure
RS-232 Port Discussion D12.1.
High-Low Guessing Game
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
Presentation transcript:

UART ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering

418_112 UART  Universal Asynchronous Receiver Transmitter Serial Data Transmission

418_113 68HC11 Microcontroller  UART Registers RSRReceive Shift Register RDRReceive Data Register TDRTransmit Data Register TSRTransmit Shift Register SCCRSerial Communications Control Register SCSRSerial Communications Status Register  UART Flags TDRETransmit Data Register Empty RDRFReceive Data Register Full

418_114 UART Block Diagram

418_115 Transmitter Operation  Microcontroller waits until TDRE = '1' Loads data into TDR Clears TDRE  UART transfers data from TDR to TSR Sets TDRE  UART outputs start bit ('0') then shifts TSR right eight times followed by a stop bit ('1')

418_116 Transmitter SM Chart

418_117 Transmitter VHDL Model library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity UART_Transmitter is port(Bclk, sysclk, rst_b, TDRE, loadTDR: in std_logic; DBUS: in unsigned(7 downto 0); setTDRE, TxD: out std_logic); end UART_Transmitter;

418_118 Transmitter VHDL Model architecture xmit of UART_Transmitter is type stateType is (IDLE, SYNCH, TDATA); signal state, nextstate: stateType; signal TSR: unsigned(8 downto 0); signal TDR: unsigned(7 downto 0); signal Bct: integer range 0 to 9; signal inc, clr, loadTSR, shftTSR, start: std_logic; signal Bclk_rising, Bclk_Dlayed: std_logic; begin TxD <= TSR(0); setTDRE <= loadTSR; Bclk_rising <= Bclk and (not Bclk_Dlayed);

418_119 Transmitter VHDL Model Xmit_Control: process(state, TDRE, Bct, Bclk_rising) begin inc <= '0'; clr <= '0'; loadTSR <= '0'; shftTSR <= '0'; start <= '0'; case state is when IDLE => if (TDRE = '0') then loadTSR <= '1'; nextstate <= SYNCH; else nextstate <= IDLE; end if;

418_1110 Transmitter VHDL Model when SYNCH => if (Bclk_rising = '1') then start <= '1'; nextstate <= TDATA; else nextstate <= SYNCH; end if; when TDATA => if (Bclk_rising = '0') then nextstate <= TDATA; elsif (Bct /= 9) then shftTSR <= '1'; inc <= '1'; nextstate <= TDATA; else clr <= '1'; nextstate <= IDLE; end if; end case; end process;

418_1111 Transmitter VHDL Model Xmit_update: process(sysclk, rst_b) begin if (rst_b = '0') then TSR <= " "; state <= IDLE; Bct <= 0; Bclk_Dlayed <= '0'; elsif (sysclk'event and sysclk = '1') then state <= nextstate; if (clr = '1') then Bct <= 0; elsif (inc = '1') then Bct <= Bct + 1; end if;

418_1112 Transmitter VHDL Model if (loadTDR = '1') then TDR <= DBUS; end if; if (loadTSR = '1') then TSR <= TDR & '1'; end if; if (start = '1') then TSR(0) <= '0'; end if; if (shftTSR = '1') then TSR <= '1' & TSR(8 downto 1); end if; Bclk_Dlayed <= Bclk; end if; end process; end xmit;

418_1113 Receiver Operation  UART waits for start bit Shifts bits into RSR  When all data bits and stop bit are received RSR loaded into RDR Set RDRF  Microcontroller waits until RDRF is set Read RDR Clear RDRF

418_1114 Sampling RxD

418_1115 Receiver SM Chart

418_1116 Receiver VHDL Model library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity UART_Receiver is port(RxD, BclkX8, sysclk, rst_b, RDRF: in std_logic; RDR: out unsigned(7 downto 0); setRDRF, setOE, setFE: out std_logic); end UART_Receiver;

418_1117 Receiver VHDL Model architecture rcvr of UART_Receiver is type stateType is (IDLE, START_DETECTED, RECV_DATA); signal state, nextstate: stateType; signal RSR: unsigned(7 downto 0); signal ct1 : integer range 0 to 7; signal ct2 : integer range 0 to 8; signal inc1, inc2, clr1, clr2, shftRSR, loadRDR: std_logic; signal BclkX8_Dlayed, BclkX8_rising: std_logic; begin BclkX8_rising <= BclkX8 and (not BclkX8_Dlayed);

418_1118 Receiver VHDL Model Rcvr_Control: process(state, RxD, RDRF, ct1, ct2, BclkX8_rising) begin inc1 <= '0'; inc2 <= '0'; clr1 <= '0'; clr2 <= '0'; shftRSR <= '0'; loadRDR <= '0'; setRDRF <= '0'; setOE <= '0'; setFE <= '0'; case state is when IDLE => if (RxD = '0') then nextstate <= START_DETECTED; else nextstate <= IDLE; end if;

418_1119 Baud Rate Generator Select BitsBAUD Rate 00038, ,

418_1120 VHDL Model entity clk_divider is port(Sysclk, rst_b: in std_logic; Sel: in unsigned(2 downto 0); BclkX8: buffer std_logic; Bclk: out std_logic); end clk_divider; architecture baudgen of clk_divider is signal ctr1: unsigned(3 downto 0) := "0000"; -- divide by 13 counter signal ctr2: unsigned(7 downto 0) := " "; -- div by 256 ctr signal ctr3: unsigned(2 downto 0) := "000"; -- divide by 8 counter signal Clkdiv13: std_logic;

418_1121 VHDL Model begin process(Sysclk) -- first divide system clock by 13 begin if (Sysclk'event and Sysclk = '1') then if (ctr1 = "1100") then ctr1 <= "0000"; else ctr1 <= ctr1 + 1; end if; end process; Clkdiv13 <= ctr1(3);

418_1122 VHDL Model process(Clkdiv13) -- ctr2 is an 8-bit counter begin if (Clkdiv13'event and Clkdiv13 = '1') then ctr2 <= ctr2 + 1; end if; end process; BclkX8 <= ctr2(to_integer(sel)); -- MUX process(BclkX8) begin if (BclkX8'event and BclkX8 = '1') then ctr3 <= ctr3 + 1; end if; end process; Bclk <= ctr3(2); end baudgen;

418_1123 Complete UART entity UART is port(SCI_sel, R_W, clk, rst_b, RxD: in std_logic; ADDR2: in unsigned(1 downto 0); DBUS: inout unsigned(7 downto 0); SCI_IRQ, TxD, RDRF_out, Bclk_out, TDRE_out: out std_logic); end UART; architecture uart1 of UART is component UART_Receiver port(RxD, BclkX8, sysclk, rst_b, RDRF: in std_logic; RDR: out unsigned(7 downto 0); setRDRF, setOE, setFE: out std_logic); end component;

418_1124 Complete UART component UART_Transmitter port(Bclk, sysclk, rst_b, TDRE, loadTDR: in std_logic; DBUS: in unsigned(7 downto 0); setTDRE, TxD: out std_logic); end component; component clk_divider port(Sysclk, rst_b: in std_logic; Sel: in unsigned(2 downto 0); BclkX8: buffer std_logic; Bclk: out std_logic); end component;

418_1125 Complete UART signal RDR, SCSR, SCCR: unsigned(7 downto 0); signal TDRE, RDRF, OE, FE, TIE, RIE: std_logic; signal BaudSel: unsigned(2 downto 0); signal setTDRE, setRDRF, setOE, setFE, loadTDR, loadSCCR: std_logic; signal clrRDRF, Bclk, BclkX8, SCI_Read, SCI_Write: std_logic; begin RCVR: UART_Receiver port map(RxD, BclkX8, clk, rst_b, RDRF, RDR, setRDRF, setOE, setFE); XMIT: UART_Transmitter port map(Bclk, clk, rst_b, TDRE, loadTDR,DBUS, setTDRE, TxD); CLKDIV: clk_divider port map(clk, rst_b, BaudSel, BclkX8, Bclk);

418_1126 Microcontroller Interface  Memory-Mapped I/O ADDR2R_WAction 000 DBUS  RDR 001 TDR  DBUS 010 DBUS  SCSR 011 DBUS  hi-Z 1-0 DBUS  SCCR 1-1 SCCR  DBUS

418_1127 UART Test Bench entity UART_test is end UART_test; architecture test1 of UART_test is component UART port(SCI_sel, R_W, clk, rst_b, RxD: in std_logic; ADDR2: in unsigned(1 downto 0); DBUS: inout unsigned(7 downto 0); SCI_IRQ, TxD, RDRF_out, Bclk_out, TDRE_out: out std_logic); end component; signal SCI_sel, R_W, clk, rst_b, RxD, SCI_IRQ, TxD, RDRF, Bclk, TDRE: std_logic := '0'; signal ADDR2: unsigned(1 downto 0); signal DBUS: unsigned(7 downto 0);

418_1128 UART Test Bench begin uart1: UART port map (SCI_sel, R_W, clk, rst_b, RxD, ADDR2, DBUS, SCI_IRQ, TxD, RDRF, Bclk, TDRE); clk <= not clk after 50 ns; process begin wait for 120 ns; rst_b <= '1'; SCI_sel <= '1'; DBUS <= " "; ADDR2 <= "10"; R_W <= '1'; wait for 100 ns;

418_1129 UART Test Bench DBUS <= " "; ADDR2 <= "00"; wait for 100 ns; R_W <= '0'; wait until TDRE = '1'; DBUS <= " "; R_W <= '1'; wait for 100 ns; R_W <= '0'; wait until TDRE = '1'; DBUS <= " "; R_W <= '1'; wait for 100 ns; R_W <= '0'; wait; end process; end test1;

418_1130 ModelSim Simulation

418_1131 ModelSim Simulation

418_1132 Loop-Back Test RxD <= TxD; process begin wait for 120 ns; report "Begin Testing"; rst_b <= '1'; SCI_sel <= '1'; -- Set SCCR DBUS <= " "; ADDR2 <= "10"; R_W <= '1'; wait for 100 ns; -- Load TDR DBUS <= " "; ADDR2 <= "00"; wait for 100 ns; DBUS <= "ZZZZZZZZ"; R_W <= '0'; wait until RDRF = '1'; assert DBUS = " " report "Test Failed"; report "Testing Complete"; wait;

418_1133 Loop-Back Test

418_1134 Summary  Universal Asynchronous Receiver Transmitter Transmitter Receiver Baud Rate Generator VHDL Models ModelSim Simulation