1 / 35

ECE 448: Lab 5 Serial Communications

ECE 448: Lab 5 Serial Communications. Agenda for today. Part 1: Serial Communications Part 2: Clock Management Part 3: Clock Domains Part 4: User Constraint File (UCF) Part 5: Board Demonstration Part 6: CoreGen. Part 1. Serial Communications. Serial Communications.

trish
Télécharger la présentation

ECE 448: Lab 5 Serial Communications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 448: Lab 5 Serial Communications

  2. Agenda for today Part 1: Serial Communications Part 2: Clock Management Part 3: Clock Domains Part 4: User Constraint File (UCF) Part 5: Board Demonstration Part 6: CoreGen

  3. Part 1 Serial Communications

  4. Serial Communications • Universal Asynchronous Receiver/Transmitter (UART) is a way of receiving/sending information from one computer to another. • Serial data means one bit at a time • These bits must be realigned to understand the data

  5. Serial Communications • Transmitter shifts the most significant bit (MSB) out while the receiver shifts into the least significant bit (LSB) Receiver Transmitter LSB MSB

  6. Serial Communications • High-Level Data Link Control (HDLC) is a data link protocol • ‘0’ is noted by a transition. • ‘1’ is represented by steady state. • Idle state transmits “flag” (x”7E”) • Data is sent between Flags

  7. Decoding HDLC Data - Flag clk transmitted data (starting from 0) 0 0 1 1 1 1 1 1 0 data after decoding Flag “7E” clk transmitted data (starting from 0) 0 0 1 1 1 1 1 1 0 data after decoding Flag “7E”

  8. Decoding HDLC Data – Valid Data clk transmitted data (starting from 0) 0 0 1 0 1 0 1 1 0 data after decoding Last bit of the flag or of previous data byte Data “AC” clk transmitted data (starting from 0) 0 0 1 0 1 0 1 1 0 data after decoding Data “AC”

  9. Serial Communications • Since x”7E” denotes flag, there needs to be protection from finding this in the data stream • Every time five consecutive ‘1’s are found in the data, an extra ‘0’ is inserted. Receiver knows to discard this bit • This does two things: • Helps bit alignment • Since energy is in transitions, old PLLs maintain enough energy to stay locked

  10. Serial Communications • Phase alignment • Since flag is unique, we can align by recognizing flag • When we get six ‘1’s in a row, next bit must be bit 7 of flag • Therefore bit 0 of new flag or data is coming soon

  11. Part 2 Clock Management

  12. Clock Management • Clock sources are generated off of the FPGA • Clock source needs to enter the FPGA • Clock needs to be “de-jittered” • Clock naturally has non-constant duty cycle and period • A steady clock makes routing more consistent • Clock needs to reach the rest of the chip

  13. Clock Management • Clock Enters FPGA and enters IBUFG • Output of BUFG goes to rest of FPGA • Invert of LOCKED signal is reset for all circuits on domain • To simulate, include the following lines in the library section • Library UNISIM; • use UNISIM.vcomponents.all; clk_50 clk_ibufg DCM Primitive clk0 IBUFG BUFG clkin clk0 clk0_180 BUFG clk0_180 reset clkfb locked

  14. Clock Management • DCM also changes clock frequency • CLK2X doubles frequency • CLKDV and CLKFX change the frequency based on the generics (see instantiation)

  15. Clock Management generic map ( CLKDV_DIVIDE => 2.0, -- Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5 -- 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0 CLKFX_DIVIDE => 1, -- Can be any integer from 1 to 32 CLKFX_MULTIPLY => 4, -- Can be any integer from 1 to 32 CLKIN_DIVIDE_BY_2 => FALSE, -- TRUE/FALSE to enable CLKIN divide by two feature CLKIN_PERIOD => 0.0, -- Specify period of input clock CLKOUT_PHASE_SHIFT => "NONE", -- Specify phase shift of NONE, FIXED or VARIABLE CLK_FEEDBACK => "1X", -- Specify clock feedback of NONE, 1X or 2X DESKEW_ADJUST => "SYSTEM_SYNCHRONOUS", -- SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or -- an integer from 0 to 15 DFS_FREQUENCY_MODE => "LOW", -- HIGH or LOW frequency mode for frequency synthesis DLL_FREQUENCY_MODE => "LOW", -- HIGH or LOW frequency mode for DLL DUTY_CYCLE_CORRECTION => TRUE, -- Duty cycle correction, TRUE or FALSE FACTORY_JF => X"C080", -- FACTORY JF Values PHASE_SHIFT => 0, -- Amount of fixed phase shift from -255 to 255 STARTUP_WAIT => FALSE) -- Delay configuration DONE until DCM LOCK, TRUE/FALSE

  16. Clock Management port map ( CLK0 => CLK0, -- 0 degree DCM CLK ouptput CLK180 => CLK180, -- 180 degree DCM CLK output CLK270 => CLK270, -- 270 degree DCM CLK output CLK2X => CLK2X, -- 2X DCM CLK output CLK2X180 => CLK2X180, -- 2X, 180 degree DCM CLK out CLK90 => CLK90, -- 90 degree DCM CLK output CLKDV => CLKDV, -- Divided DCM CLK out (CLKDV_DIVIDE) CLKFX => CLKFX, -- DCM CLK synthesis out (M/D) CLKFX180 => CLKFX180, -- 180 degree CLK synthesis out LOCKED => LOCKED, -- DCM LOCK status output PSDONE => PSDONE, -- Dynamic phase adjust done output STATUS => STATUS, -- 8-bit DCM status bits output CLKFB => CLKFB, -- DCM clock feedback CLKIN => CLKIN, -- Clock input (from IBUFG, BUFG or DCM) PSCLK => PSCLK, -- Dynamic phase adjust clock input PSEN => PSEN, -- Dynamic phase adjust enable input PSINCDEC => PSINCDEC, -- Dynamic phase adjust increment/decrement RST => RST); -- DCM asynchronous reset input

  17. Part 3 Clock Domains

  18. Clock Domains • Clock domains separate the FPGA into different sections • Crossing these “clock boundaries” requires special attention • For bits, double registers, edge detectors, etc. will provide adequate boundary crossing • Data busses usually require more attention i.e. FIFOs (First In/First Out)

  19. Clock Domains • DA is in transition by the next CLKB rising edge • Therefore DB status is unknown

  20. Clock Domains Rising Edge Detector • Rising Edge Detector crosses clock domains to a faster clock • Sends a 1-cycle long pulse after rising edge has been detected • Only goes from slow to fast clock • Flip-Flop is clocked on fast domain clock button clk clock input output

  21. Clock Domains FPGA FPGA rx_clk clk1k FIFO rd_clk 8 seg 8 8 rxd RX SSegCtrl 4x7seg display din dout JA 4 an button(0) rx_clk wr_en rd_en wr_clk RED btn Switches 8 txd TX JD debounce clk0_180 RED button(1) Buttons clk0

  22. Clock Domains • Three (3) clocks to generate • clk0 • Used for high speed internal logic • Generated by the DCM • clk0_180 • Used as clock out of transmitter unit to align txd transition on falling edge • Generated by the DCM • clk1k • Used as clock for switches, seven segment display, and other slow logic • Generated by counting clock divider

  23. Clock Domains • Why does rx_clk need its own domain? • We are interfacing with the necessary clk1k domain. This means that we have a frequency difference to allow for. • Even if we didn’t have the frequency offset, there is still no guarantee that the rx_clk is the same phase as clk0. This can lead to the same problems described earlier.

  24. Debounce Capacitance in the button and contacts “bouncing” causes spurs that cause false positives. A debouncing circuit removes these spurs.

  25. Debounce When the first change is detected, we ignore all subsequent changes for some period of time, preferably until all of the bouncing would have occurred. This is usually on the order of ms.

  26. Seven Segment Display • By lighting different combinations of LEDs, different figures appear • For Instance CA, CB, CC make ‘7’ • Common anode means that writing a ‘1’ to CA-DP illuminates the led, where a ‘0’ turns it off

  27. Seven Segment Display • SSRegCtrl has a 16 bit input that is divided into four 4-bit digits • AN(0:3) select which 7 segment display to output to • Digilent recommends a digit period of between 1khz and 60hz • Although the circuit has a 16-bit input, we’re only using 8 bits. You may use the other 8 bits for something else, or just set them to ‘0’s

  28. Clock Domains reset Counter =25000 15 en BUFG clk1k clk0

  29. Part 4 User Constraint File (UCF)

  30. User Constraint File (UCF) • File contains various constraints for Xilinx • Clock Periods • Clock Boundary Crossings (hard to do! That’s why we use a CoreGen’ed FIFO) • Circuit Locations • Pin Locations • Every pin in the top unit needs to have a pin in the UCF • The UCF needs to be included in Xilinx ISE, but not simulator (i.e. Aldec)

  31. User Constraint File (UCF) Top Level Unit (VHDL) UCF # Pin assignment for DispCtl # Connected to Basys2 onBoard 7seg display NET "seg<0>" LOC = "L14"; # Bank = 1, Signal name = CA NET "seg<1>" LOC = "H12"; # Bank = 1, Signal name = CB NET "seg<2>" LOC = "N14"; # Bank = 1, Signal name = CC NET "seg<3>" LOC = "N11"; # Bank = 2, Signal name = CD NET "seg<4>" LOC = "P12"; # Bank = 2, Signal name = CE NET "seg<5>" LOC = "L13"; # Bank = 1, Signal name = CF NET "seg<6>" LOC = "M12"; # Bank = 1, Signal name = CG NET "dp" LOC = "N13"; # Bank = 1, Signal name = DP NET "an<3>" LOC = "K14"; # Bank = 1, Signal name = AN3 NET "an<2>" LOC = "M13"; # Bank = 1, Signal name = AN2 NET "an<1>" LOC = "J12"; # Bank = 1, Signal name = AN1 NET "an<0>" LOC = "F12"; # Bank = 1, Signal name = AN0 # Pin assignment for LEDs NET "Led<7>" LOC = "G1" ; # Bank = 3, Signal name = LD7 NET "Led<6>" LOC = "P4" ; # Bank = 2, Signal name = LD6 NET "Led<5>" LOC = "N4" ; # Bank = 2, Signal name = LD5 NET "Led<4>" LOC = "N5" ; # Bank = 2, Signal name = LD4 NET "Led<3>" LOC = "P6" ; # Bank = 2, Signal name = LD3 NET "Led<2>" LOC = "P7" ; # Bank = 3, Signal name = LD2 NET "Led<1>" LOC = "M11" ; # Bank = 2, Signal name = LD1 NET "Led<0>" LOC = "M5" ; # Bank = 2, Signal name = LD0 # Pin assignment for SWs NET "sw<7>" LOC = "N3"; # Bank = 2, Signal name = SW7 NET "sw<6>" LOC = "E2"; # Bank = 3, Signal name = SW6 NET "sw<5>" LOC = "F3"; # Bank = 3, Signal name = SW5 NET "sw<4>" LOC = "G3"; # Bank = 3, Signal name = SW4 NET "sw<3>" LOC = "B4"; # Bank = 3, Signal name = SW3 NET "sw<2>" LOC = "K3"; # Bank = 3, Signal name = SW2 NET "sw<1>" LOC = "L3"; # Bank = 3, Signal name = SW1 NET "sw<0>" LOC = "P11"; # Bank = 2, Signal name = SW0 entity Spartan3E is generic( simulation : boolean := false); port( -- Clocks clk_in : in std_logic; -- LEDs led : out std_logic_vector(7 downto 0); -- Extention ports JA : in std_logic_vector(3 downto 0); JD : out std_logic_vector(3 downto 0); -- Seven Segment Display seg : out std_logic_vector(7 downto 0); an : out std_logic_vector(3 downto 0); -- Rotary button and switches sw : in std_logic_vector(7 downto 0); btn : in std_logic_vector(3 downto 0)); end entity Spartan3E;

  32. Part 5 CoreGen

  33. Part 6 Board Demonstration

  34. Board Expansion ports VGA connector 7 Segment Displays (4) ON/OFF Switch Buttons (4) Switches (8) LEDs (8)

  35. Extra Links • Programming Tool (Digilent Adept) http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,69&Prod=ADEPT http://www.xilinx.com/itp/xilinx8/books/data/docs/lib/lib0061_25.html http://www.xilinx.com/itp/xilinx5/data/docs/lib/lib0233_217.html • Programming Tool (Digilent Adept) http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,69&Prod=ADEPT http://www.xilinx.com/itp/xilinx8/books/data/docs/lib/lib0061_25.html http://www.xilinx.com/itp/xilinx5/data/docs/lib/lib0233_217.html

More Related