RS-232 Port Discussion D7.1. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)

Slides:



Advertisements
Similar presentations
Shift-Registers and Push Button Debounce
Advertisements

Serial I/O - Programmable Communication Interface
Arbitrary Waveform Discussion 5.5 Example 34.
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
A Simple Microcontroller VHDL Tutorial R. E. Haskell and D. M. Hanna T6: VHDL State Machines.
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.
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.
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.
Finite State Machines Discussion D7.1 Mealy and Moore Machines.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
7-Segment Display DIO1 Board. Digilab2 – DIO1 Boards Four 7-segment displays A0A1A2A3.
Lecture L6.2 VHDL Multiply Operator (*)
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
Division Lecture L6.3. Division
Finite State Machines Mano and Kime Sections 4-4, 4-5, 4-8.
Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise “010”true if b < a.
Finite State Machines Discussion D8.1 Example 36.
Lab 3 & 4 Discussion EE414/514 VHDL Design September 25.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Division Discussion D11.3. Division
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.
Sequential Multiplication Lecture L6.4. Multiplication 13 x = 8Fh 1101 x
RS-232 Port Lecture L9.3. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
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);
ECE 371- Unit 11 Introduction to Serial I/O. TWO MAJOR CLASSES OF SERIAL DATA INTERFACES ASYNCHRONOUS SERIAL I/O - USES “FRAMING BITS” (START BIT AND.
PS/2 Mouse/Keyboard Port Discussion D7.2. PS/2 Port.
Serial Communication ETEC 6416.
The 8051 Microcontroller and Embedded Systems
Digilent System Board Capabilities Serial Port (RS-232) Parallel Port 1 Pushbutton Hint: Good for a reset button Connected to a clock input. See Digilent.
Lecture Set 9 MCS-51 Serial Port.
Unit 4 Design and Synthesis of Datapath Controllers
1 Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
UART ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
Chapter 10 State Machine Design. 2 State Machine Definitions State Machine: A synchronous sequential circuit consisting of a sequential logic section.
BYU ECEn 320 Lab 4 UART Transmitter. BYU ECEn 320 UART Transmimtter Specification VGA Serial A1 Expansion Connector PS2 A2 Expansion Connector B1 Expansion.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
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.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
VHDL Project I: Serial Adder Matthew Murach Slides Available at:
Prime Numbers Lecture L6.1 Sieve of Eratosthenes.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Lecture # 14. RS – 232C Standard Standard for physical dimensions of the connectors. PC (DTE) Modem RS – 232C Cable Connected via serial port (DCE)
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.
Sequential statements (1) process
Serial mode of data transfer
UART Serial Port Programming
Lecture L5.1 Mealy and Moore Machines
SERIAL PORT PROGRAMMING
Serial Communication: RS-232 (IEEE Standard)
UART Serial Port Programming
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
UART Serial Port Programming
Serial Communication Interface
VHDL (VHSIC Hardware Description Language)
A Greatest Common Divisor (GCD) Processor
Fibonacci Sequence Lecture L4.1 Lab 3.
Multiplication Discussion 11.1.
Figure 8.1. The general form of a sequential circuit.
Fast, Asynchronous SRAM
RS-232 Port Discussion D12.1.
Presentation transcript:

RS-232 Port Discussion D7.1

Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)

Spartan-3 board: DCE male connector PC: DTE female connector Straight-through cable

Note: TxD (pin 2) on Spartan-3 DCE connector is connected to RD (pin 2) on the PC DTE connector

UART clock frequency = 16 x Baud rate or 64 x Baud rate

Standard ASCII Codes

How would you make the following hardware Tx UART? 8-bit parallel data comes in tx_data(7:0) and is loaded into a transmit buffer txbuff when tdre is high. When ready goes high the contents of txbuff is sent out TxD as asynchronous serial data. When txbuff is empty, tdre is set to 1.

UART Transmit State Diagram

VHDL Canonical Sequential Network State Register Combinational Network x(t) s(t+1) s(t) z(t) clk init present state present input next state present output process(clk, init) process(present_state, x)

VHDL Mealy Machine State Register C1 x(t) s(t+1) s(t) z(t) clk init present state present input next state C2 process(clk, init) process(present_state, x)

VHDL Moore Machine State Register C1 x(t) s(t+1) s(t) z(t) clk init present state present input next state C2 process(present_state, x) process(present_state) process(clk, init)

VHDL Canonical Sequential Network State Register Combinational Network x(t) s(t+1) s(t) z(t) clk init present state present input next state present output process(clk, init) process(present_state, x) Combine into a single process

UART Transmit State Diagram

entity uart_tx is port( clk : in STD_LOGIC; clr : in STD_LOGIC; tx_data : in STD_LOGIC_VECTOR(7 downto 0); ready : in STD_LOGIC; tdre : out STD_LOGIC; TxD : out STD_LOGIC ); end uart_tx;

architecture uart_tx of uart_tx is type state_type is (mark, start, delay, shift, stop); signal state: state_type; signal txbuff: STD_LOGIC_VECTOR (7 downto 0); signal baud_count: STD_LOGIC_VECTOR (11 downto 0); signal bit_count: STD_LOGIC_VECTOR (3 downto 0); constant bit_time: STD_LOGIC_VECTOR (11 downto 0) := X"A28"; begin 9600 baud

uart2: process(clk, clr, ready) begin if clr = '1' then state <= mark; txbuff <= " "; baud_count <= X"000"; bit_count <= "0000"; TxD <= '1'; elsif (clk'event and clk = '1') then case state is when mark =>-- wait for ready bit_count <= "0000"; tdre <= '1'; if ready = '0' then state <= mark; txbuff <= tx_data; else baud_count <= X"000"; state <= start; -- go to start end if;

when start =>-- output start bit baud_count <= X"000"; TxD <= '0'; tdre <= '0'; state <= delay;-- go to delay when delay =>-- wait bit time tdre <= '0'; if baud_count >= bit_time then baud_count <= X"000"; if bit_count < 8 then-- if not done state <= shift;-- go to shift else-- else state <= stop;-- go to stop end if; else baud_count <= baud_count + 1; state <= delay; -- stay in delay end if;

when shift =>-- get next bit tdre <= '0'; TxD <= txbuff(0); txbuff(6 downto 0) <= txbuff(7 downto 1); bit_count <= bit_count + 1; state <= delay; when stop =>-- stop bit tdre <='0'; TxD <= '1'; if baud_count >= bit_time then baud_count <= X"000"; state <= mark; else baud_count <= baud_count + 1; state <= stop; end if; end case; end if; end process uart2; end uart_tx;

Test Transmit UART Set slide switches to some ASCII code and then press button 0 to send ASCII code out serial port. SW BTN(0)

entity tx_tst_ctrl is port( clk : in STD_LOGIC; clr : in STD_LOGIC; btn : in STD_LOGIC; tdre : in STD_LOGIC; ready : out STD_LOGIC ); end tx_tst_ctrl;

architecture tx_tst_ctrl of tx_tst_ctrl is type state_type is (wtbtndn, wttdre, load, wtbtnup); signal state: state_type; begin ctrl: process(clk, clr, btn, tdre) begin if clr = '1' then state <= wtbtndn; ready <= '0'; elsif (clk'event and clk = '1') then case state is when wtbtndn =>-- wait for btn if btn = '0' then -- if bnt up state <= wtbtndn;-- stay in wtbtndo ready <= '0'; else ready <= '0'; state <= wttdre;-- else go to wttdre end if;

when wttdre =>-- wait for tdre = 1 if tdre = '0' then -- if tdre = 0 state <= wttdre;-- stay in wtdone ready <= '0'; else state <= load;-- else go to load ready <= '0'; end if; when load =>-- output ready ready <= '1'; state <= wtbtnup;-- go to wtbtnup

when wtbtnup =>-- wait for btn up if btn = '1' then -- if btn down state <= wtbtnup;-- stay in wtbtnup ready <= '0'; else ready <= '0'; state <= wtbtndn;-- else go to wtbtndn end if; end case; end if; end process ctrl; end tx_tst_ctrl;

Test Transmit UART Top-level design entity uart_tx_test is port ( mclk : in STD_LOGIC; SW : in STD_LOGIC_VECTOR(7 downto 0); BTN : in STD_LOGIC_VECTOR(3 downto 0); LD : out STD_LOGIC_VECTOR(7 downto 0); TxD : out STD_LOGIC ); end uart_tx_test; Pin "R13"

architecture uart_tx_test_arch of uart_tx_test is component uart_tx port( clk : in STD_LOGIC; clr : in STD_LOGIC; tx_data : in STD_LOGIC_VECTOR(7 downto 0); ready : in STD_LOGIC; tdre : out STD_LOGIC; TxD : out STD_LOGIC ); end component; component tx_tst_ctrl port( clk : in STD_LOGIC; clr : in STD_LOGIC; btn : in STD_LOGIC; tdre : in STD_LOGIC; ready : out STD_LOGIC ); end component;

component debounce is port ( inp, clk, clr: in std_logic; outp: out std_logic ); end component; signal clr, clk, cclk: std_logic; signal tdre, ready, BTN0: std_logic; signal clkdiv : std_logic_vector(23 downto 0); begin

-- Divide the master clock (50Mhz) down to a lower frequency. process (mclk) begin if clr = '1' then clkdiv <= " "; elsif mclk = '1' and mclk'Event then clkdiv <= clkdiv + 1; end if; end process; clk <= clkdiv(0); MHz cclk <= clkdiv(17); Hz LD(7) <= BTN(1); LD(6) <= BTN(2); LD(5) <= BTN(1); LD(4) <= BTN(2); LD(3) <= BTN(1); LD(2) <= BTN(2); LD(1) <= BTN(1); LD(0) <= tdre; clr <= BTN(3);

U1: uart_tx port map (TxD => TxD, clk => clk, clr => clr, ready => ready, tx_data => SW,tdre => tdre); U2: tx_tst_ctrl port map (clk => clk, clr => clr, btn => BTN0, tdre => tdre, ready => ready); U3: debounce port map (inp => BTN(0), clr => clr, clk => cclk, outp => BTN0); end uart_tx_test_arch; SW BTN(0)

How would you make the following hardware Rx UART? 8-bit asynchronous serial data comes in RxD and fills up the shift register data_rx. When data_rx is full, rdrf is set to 1. rdrf is cleared to zero by bringing clrflg high. The framing error flag FE is set to 1 if the stop bit is not 1.

UART clock frequency = 16 x Baud rate or 64 x Baud rate

UART Receive State Diagram

entity uart_rx is port( RxD : in STD_LOGIC; clk : in STD_LOGIC; clr : in STD_LOGIC; rdrf_clr : in STD_LOGIC; rdrf : out STD_LOGIC; FE : out STD_LOGIC; rx_data : out STD_LOGIC_VECTOR(7 downto 0) ); end uart_rx;

architecture uart_rx of uart_rx is type state_type is (mark, start, delay, shift, stop); signal state: state_type; signal rxbuff: STD_LOGIC_VECTOR (7 downto 0); signal baud_count: STD_LOGIC_VECTOR (11 downto 0); signal bit_count: STD_LOGIC_VECTOR (3 downto 0); signal rdrf_set, fe_set, cclr, cclr8, rxload: STD_LOGIC; constant bit_time: STD_LOGIC_VECTOR (11 downto 0) := X"A28"; constant half_bit_time: STD_LOGIC_VECTOR (11 downto 0) := X"514"; begin 9600 baud

uart2: process(clk, clr, rdrf_clr) begin if clr = '1' then state <= mark; rxbuff <= " "; baud_count <= X"000"; bit_count <= "0000"; FE <= '0'; elsif rdrf_clr = '1' then rdrf <= '0'; elsif (clk'event and clk = '1') then case state is when mark =>-- wait for start bit baud_count <= X"000"; bit_count <= "0000"; if RxD = '1' then state <= mark; else FE <= '0'; state <= start; -- go to start end if;

when start =>-- check for start bit if baud_count >= half_bit_time then baud_count <= X"000"; state <= delay; else baud_count <= baud_count + 1; state <= start; end if; when delay => if baud_count >= bit_time then baud_count <= X"000"; if bit_count < 8 then state <= shift; else state <= stop; end if; else baud_count <= baud_count + 1; state <= delay; end if;

when shift =>-- get next bit rxbuff(7) <= RxD; rxbuff(6 downto 0) <= rxbuff(7 downto 1); bit_count <= bit_count + 1; state <= delay; when stop => rdrf <= '1'; if RxD = '0' then FE <= '1'; else FE <= '0'; end if; state <= mark; end case; end if; end process uart2; rx_data <= rxbuff; end uart_rx;

Test of UART

Test Receive UART Receive ASCII code sent from terminal program on PC when key is pressed and display on LEDs.

Test Transmit UART Echo back ASCII code sent from PC. rdrf_clr

entity test2_rx_ctrl is port( clk : in STD_LOGIC; clr : in STD_LOGIC; rdrf : in STD_LOGIC; rdrf_clr : out STD_LOGIC ); end test2_rx_ctrl; architecture test2_rx_ctrl of test2_rx_ctrl is type state_type is (wtrdrf, load); signal state: state_type;

begin ctrl: process(clk, clr, rdrf) begin if clr = '1' then state <= wtrdrf; rdrf_clr <= '0'; elsif (clk'event and clk = '1') then case state is when wtrdrf => rdrf_clr <= '0'; if rdrf = '0' then state <= wtrdrf; else state <= load; end if; when load => rdrf_clr <= '1'; state <= wtrdrf; end case; end if; end process ctrl; end test2_rx_ctrl;

entity uart_test2 is port ( mclk : in STD_LOGIC; BTN3 : in STD_LOGIC; RxD : in STD_LOGIC; LD : out STD_LOGIC_VECTOR(7 downto 0); TxD : out STD_LOGIC ); end uart_test2; architecture uart_test2_arch of uart_test2 is component uart_tx port( clk : in STD_LOGIC; clr : in STD_LOGIC; tx_data : in STD_LOGIC_VECTOR(7 downto 0); ready : in STD_LOGIC; tdre : out STD_LOGIC; TxD : out STD_LOGIC ); end component; Top-level test of UART

component tx_tst_ctrl port( clk : in STD_LOGIC; clr : in STD_LOGIC; btn : in STD_LOGIC; tdre : in STD_LOGIC; ready : out STD_LOGIC ); end component; component uart_rx port( RxD : in STD_LOGIC; clk : in STD_LOGIC; clr : in STD_LOGIC; rdrf_clr : in STD_LOGIC; rdrf : out STD_LOGIC; FE : out STD_LOGIC; rx_data : out STD_LOGIC_VECTOR(7 downto 0) ); end component;

component test2_rx_ctrl port( clk : in STD_LOGIC; clr : in STD_LOGIC; rdrf : in STD_LOGIC; rdrf_clr : out STD_LOGIC ); end component; signal clr, clk, cclk: std_logic; signal tdre, rdrf, rdrf_clr, FE, ready, btn: std_logic; signal clkdiv : std_logic_vector(23 downto 0); signal data : std_logic_vector(7 downto 0);

begin -- Divide the master clock (50Mhz) down to a lower frequency. process (mclk) begin if clr = '1' then clkdiv <= " "; elsif mclk = '1' and mclk'Event then clkdiv <= clkdiv + 1; end if; end process; clk <= clkdiv(0); MHz cclk <= clkdiv(17); Hz LD <= data; clr <= BTN3; btn <= rdrf_clr;

U1: uart_tx port map (TxD => TxD, clk => clk, clr => clr, ready => ready, tx_data => data,tdre => tdre); U2: uart_rx port map (RxD => RxD, clk => clk, clr => clr, rdrf_clr => rdrf_clr, rx_data => data,rdrf => rdrf, FE => FE); U3: tx_tst_ctrl port map (clk => clk, clr => clr, tdre => tdre, btn => btn, ready => ready); U4: test2_rx_ctrl port map (clk => clk, clr => clr, rdrf => rdrf, rdrf_clr => rdrf_clr); end uart_test2_arch;