MIPI D-PHY Bandwidth Matrix Table User Guide UG110 Version 1.0, June 2015 MIPI D-PHY Bandwidth Matrix Table User Guide Introduction As we move from the world of standard-definition to the high-definition and ultra-high-definition, the common parallel interfaces are difficult to expand, require many interconnects and consume relatively large amounts of power. Emerging packet-based serial interfaces, such as MIPI CSI-2 and DSI address many of the shortcomings of the parallel interfaces, while also introducing system complexity. Understanding the mathematics behind the parallel and serial interface bandwidth estimation can prevent a lot of problems when choosing a FPGA device with the right number of data lanes supporting the required data transfer rate. This document describes in details the methods of calculating the bandwidth and data rate of the image sensor’s output of the RGB, YUV or RAW data over a single or multi-lane MIPI CSI-2 and DSI interface. The same calculation method can be applied to other video interface such FPD-Link, HiSPI and HDMI etc. Figure 1 shows a conceptual model of the CMOS Sensor Bridge Design. On the left, a CMOS sensor transfers image data to the FPGA through 1 to 4 serial data lanes; the FPGA sensor bridge merges the image data from multiple lanes and converts them into parallel data; on the right, the image data are sent out over the parallel bus in standard video format. Based on the known video format information, we can calculate the require bandwidth. Because the FPGA does not buffer the video frames, the peak transfer rate of CMOS sensor input must meet the bandwidth requirement of the output. With this presumption, we can estimate the maximum data rate and bit clock frequency of the CMOS sensor interface. Figure 1. CMOS Sensor Bridge Model CMOS Parallel I/F CSI-2, DSI . 1~4 . data lanes . FPGA Sensor Bridge 8~ 24-bit Data Bus Output Image FV/ LV CLK CLK 2 MIPI D-PHY Bandwidth Matrix Table User Guide Video Format To estimate the data transfer rate, we need to understand the format of the video data transferred over the sensor bridge. Video is composed of a series of still images. Each still image is composed of individual lines of pixel data. Figure 2 illustrates a conceptual interlaced video frame. The progressive video frame is similar to it except for only one field per frame. Figure 2. Interlaced Mode Video Frame Format Htotal (Total Horizontal Samples) Hactive (Active Horizontal Samples) Vactive (Active Vertical Lines) of Field No. 1 Horizontal Blanking Field No. 1 Field No. 1 Active Video Field No. . 2 Active Video Vactive (Active Vertical Lines) of Field No. 2 Horizontal Blanking Vertical Blanking Field No. . 2 Vtotal (Vertical Total Lines) Vertical Blanking Vertical Blanking For digital video, either a separate Horizontal Sync (HS), Vertical Sync (VS) and Data Enable (DE) signals are used to synchronize the video data transfer, or a special sequence embedded into the video data stream indicating the Start of the Active Video (SAV) or End of the Active Video (EAV). For MIPI CSI-2, two packets structures are defined for Low Level Protocol layer: Long packets to carry payload data, and the Short Packets for Frame Synchronization (i.e. Frame Start and Frame End) and Line Synchronization (i.e. Line Start and Line End). 3 MIPI D-PHY Bandwidth Matrix Table User Guide There are many characteristics of the video streams, for example, frame rate, interlaced vs progressive, aspect ratio, stereoscopic, color space and color depth etc. We will review the major parameters that will be used in the calculation of the data transfer rate in the later sections of the document. Video Resolution and Pixel Clock The video resolution is quoted as Width x Height, with the unit in pixels: for example, 1920x1080 means the horizontal width is 1920 pixels and the vertical height is 1080 lines. Figure 3 shows the chart of the common display resolutions. Figure 3. Most Common Display Resolutions Source: https://en.wikipedia.org/wiki/File:Vector_Video_Standards4.svg There are two major types of video format standards: SMPTE/CEA defines video standards for the Television and broadcast; VESA Display Monitor Timing (DMT) standard defines the video standards for the computer monitors. Table 1 lists the most common video resolutions. Among them, we choose HD (1280x720p), FHD(1920x1080p) and UHD(3840x2160p) as examples to calculate the bandwidth and data rate in the later sections. 4 MIPI D-PHY Bandwidth Matrix Table User Guide Table 1. Common Video Format Hactive Vactive Htotal Vtotal Refresh Rate(Hz) Pixel Freq(MHz) 640 480 800 525 59.94 25.175 Television Video Format EDTV [email protected] [email protected] 720 480 858 525 59.94 27 720x576p@50Hz 720 576 864 625 50 27 HDTV 1280x720p@60Hz 1280 720 1650 750 60 74.25 Full HD 1920x1080i@60Hz 1920 1080 2200 1125 60 74.25 1920x1080p@60Hz 1920 1080 2200 1125 60 148.5 3840X2160p@60Hz 3840 2160 4400 2250 60 594 4096x2160p@60Hz 4096 2160 4400 2250 60 594 UHDTV Computer Monitor Format XGA 1024x768p@60Hz 1024 768 1344 806 60 65 WXGA 1280x800p@60Hz 1280 800 1680 831 59.81 83.5 WXGA+ 1440x900p@60Hz 1440 900 1904 934 59.887 106.5 HD 1366x768p@60Hz 1366 768 1792 798 59.79 85.5 HD+ 1600x900p@60Hz (RB) 1600 900 1800 1000 60 108 WUXGA 1920x1200p@60Hz(RB) 1920 1200 2080 1235 59.95 154 WQXGA 2560x1600p@60Hz(RB) 2560 1600 2720 1646 59.97 268.5 Some of the image sensors can output the standard video formats by cropping or binning the pixels, the others may output non-standard resolutions. The important thing is to obtain the information of the Total Horizontal Samples, Total Vertical Lines and frame Refresh Rate. We will discuss how to calculate the bandwidth based on the above information. Color Depth Color depth, also known as bit depth, can be either referred to as bits-per-pixel (bpp) which specifies the number of bits used for a single pixel, or referred to as bits-per-component (bpc) which specifies the number of bits used to represent each color component of a single pixel. Deep color supports 30/36/48-bit for three RGB colors. In this document, the term Pixel Size is equivalent to the color depth in bits-per-pixel. For example, the pixel size of a 30bit deep color RGB is defined as 30 bits per pixel, or 10 bits per color component. 5 MIPI D-PHY Bandwidth Matrix Table User Guide MIPI CSI-2/DSI Interfaces MIPI Camera Serial Interface 2 (CSI-2) and Display serial Interface (DSI) are two of the serial interface protocols based on MIPI D-PHY physical interface. MIPI D-PHY supports unidirectional HS (High Speed) mode and Bidirectional LP (Low Power) mode. For the application of CMOS sensor bridge, we will only need the MIPI D-PHY receiver (RX) on the FPGA receive interface, which allows the bridge to receive HS data on one clock lane and up to four data lanes. Figure 4a shows the block diagram of the Unidirectional Receiver HS Mode Only interface, and Figure 4b shows the block diagram of the Unidirectional Receive HS Mode and Bidirectional LP Mode interface. For details of both Receiver/Transmitter HS and LP modes interface implementation, please refer to Lattice reference design document RD1182 – MIPI D-PHY Interface IP. Figure 4. Unidirectional Receive HS Mode Only Implementation MIPI D-PHY TX Device 50 Ohm CLOCK_P LPCLK[1] DCK_p DCK_n CLOCK_N LPCLK[0] LVCMOS12 LVDS25 LVCMOS12 LP0[1] LVCMOS12 DATA0_P D0_n DATA0_N LP0[0] LVDS25 LVCMOS12 50 Ohm 50 Ohm LP3[1] LVCMOS12 DATA3_P D3_p D3_n LVDS25 DATA3_N LP3[0] LVCMOS12 50 Ohm 6 IO Controller D0_p Aligner 50 Ohm iDDRx4 50 Ohm MIPI D-PHY Bandwidth Matrix Table User Guide Figure 5. Unidirectional Receive HS Mode and Bidirectional LP Mode Interface Implementation MIPI DPHY TX Device LATTICE FPGA CLOCK_P DPHY RX Module DCK_p 100 Ohm DCK_n LVDS25 D0_n LVDS25 DATA0_N DATA3_P IO Controller D0_p 100 Ohm Aligner DATA0_P iDDRx4 CLOCK_N D3_p 100 Ohm D3_n LVDS25 DATA3_N Packetizing The MIPI CSI-2 supports YUV, RGB or RAW data with varying pixel formats from 6 to 24 bits per pixel. In the transmitter the pixels are packed into bytes (Pixel-to-byte Packing) before sending the data to Low Level Protocol layer; in the receiver the bytes received from the Low Level Protocol layer are unpacked into pixel (Byte-to-pixel Unpacking). One CSI-2 long packet shall contain one line of image data. The total size of data within a long packet for all data types shall be a multiple of eight bits (byte). Figure 5 shows an example of packing four 10-bit pixel data (RAW10) into five bytes to look like 8-bit data format. Figure 6. An Example of RAW10 Transmissions on CSI-2 Bus P1[9:2] (A) P3[9:2] (C) P2[9:2] (B) P4[9:2] (D) A2 A3 A4 A5 A6 A7 A8 A9 B2 B3 B4 B5 B6 B7 B8 B9 C2 C3 C4 C5 C6 C7 C8 C9 D2 D3 D4 D5 D6 D7 D8 D9 P1 [1:0] P2 [1:0] P3 [1:0] P4 [1:0] P5[9:2] (E) P6[9:2] (F) P7[9:2] (G) AO A3 B0 B1 C0 C1 D0 D1 E2 E3 E4 E5 E6 E7 E8 E9 F2 F3 F4 F5 F6 F7 F8 F9 G2 G3 G4 G5 G6 G7 G8 G9 8 Bits 8 Bits 8 Bits 7 8 Bits MIPI D-PHY Bandwidth Matrix Table User Guide Table 2 specifies the packet size constraints for the supported data formats. The length of each packet must be a multiple of the values in the table. For simplicity, all data format examples are single lane configurations Table 2. CSI-2 Packet Size Constraints1 Data Format Odd/Even Lines Pixels Bytes Bits Odd 2 2 16 Even 2 4 32 Odd 4 5 40 Even 4 10 80 2 4 32 YUV420 8-bit YUV420 10-bit YUV422 8-bit YUV422 10-bit 2 5 40 RGB888 1 3 24 RGB666 4 9 72 RGB565 1 2 16 RGB555 1 2 16 RGB444 1 2 16 RAW6 4 3 24 RAW7 8 7 56 RAW8 1 1 8 RAW10 4 5 40 RAW12 2 3 24 RAW14 4 7 56 1. RGB555 and RGB444 data should be made to look like RGB565 data by inserting padding bits to the LSBs of each color component. Multi-lane MIPI CSI-2 is lane-scalable. Applications requiring more bandwidth than that provided by one data lane, or those trying to avoid high clock rates, can expand the data path to two, three, or four lanes wide and obtain approximately linear increases in peak bus bandwidth Bandwidth and Data Rate Definitions Pixel Clock – the time base in MHz at which individual pixels are transmitted Bandwidth – the capacity required in Mbps of a given system to pass a specific frequency Data Rate – the data flow throughput in bits per second of the transport layer Bandwidth and Data Rate Calculation In this section, we will summarize how to calculate the bandwidth and data transfer rate Pixel Clock (MHz) If the video format is standard, the pixel clock frequency can be obtained from the SMPTE/CEA or VESA standards. Or we can calculate the pixel clock frequency using the following equation: Pixel Clock Frequency = Total Horizontal Samples * Total Vertical Lines * Refresh Rate The Total Horizontal Samples and Total Vertical Lines include blanking period. The Refresh Rate may be referred to as Frame Rate or Vertical Frequency. 8 MIPI D-PHY Bandwidth Matrix Table User Guide Total Data Rate or Bandwidth (Mbps/Gbps) The bandwidth of a given video format is simply a product of the Pixel Clock Frequency and Pixel Size in bits. The total data rate of the CMOS sensor interface must match the bandwidth. Total Data Rate (Bandwidth) = Pixel Clock Frequency * Pixel Size (in bits) Data Rate per Lane (Mbps/Gbps) The per-lane data rate (a.k.a. Line Rate) is the total data rate (bandwidth) divided by the number of lanes. CSI-2 can support up to 4 data lanes. Data Rate per Lane = Total Data Rate (Bandwidth) / Number of Data Lane Bit Clock (MHz) Because the MIPI data lane is a Double Data Rate interface, the CSI-2 Bit Clock frequency is ½ of the Data Rate per Lane Bit Clock Frequency = Data Rate per Lane / 2 Examples Example 1: 1920x1080p@60Hz, RAW10, 2-lane Total Horizontal Samples = 2200, Total Vertical Lines = 1125 Pixel Clock Frequency = 2200 x 1125 x 60 = 148.5 MHz Bandwidth (Total Data Rate) = 148.5 MHz * 10-bit = 1.485 Gbps Line Rate (Data Rate per Lane) = 1.485 Gbps / 2-lane = 742.5 Mbps MIPI Bit Clock Frequency = 742.5 / 2 = 371.25 MHz Example 2: 3840x2160@30Hz, RAW8, 4-lane Total Horizontal Samples = 4400, Total Vertical Lines = 2250 Pixel Clock Frequency = 4400 x 2250 * 30 = 297 MHz Bandwidth (Total Data Rate) = 297 MHz * 8-bit = 2.376 Gbps Line Rate (Data Rate per Lane) = 2.376 Gbps / 4-lane = 594 Mbps MIPI Bit Block Frequency = 594 /2 = 297 MHz 9 MIPI D-PHY Bandwidth Matrix Table User Guide Device Selection Hardware Features Table 3 highlights the features of MIPI D-PHY hardware implementation using Lattice MachXO2, MachXO3L, LatticeECP3 and ECP5 device families. For more details of MIPI D-PHY Receiver and Transmitter resource utilization and design performance, please refer to RD1182 – MIPI D-PHY Interface IP as listed in the Reference section of this document. Table 3. MIPI D-PHY RX/TX Hardware Comparison MachXO2/MachXO3L MIPI D-PHY Rx Implementations LatticeECP3 EA ECP5 HS Mode: • LVDS25 for MachXO2/MachXO3L/LatticeECP3, ECP5 has dedicated MIPI IO type • VCCIO = 2.5 V or 3.3 V • Internal Termination; dependent on external circuit LP Mode: • LVCMOS12 • VCCIO = 1.2 V MIPI D-PHY Tx HS Mode: • LVDS25E for MachXO2/MachXO3L; LVCMOS33D for LatticeECP3 • Slew Rate = “FAST” LP Mode: • LVCMOS 12 • VCCIO = 1.2 V DDR Gearing Ratio X4 Number of D-PHY Up to two RX D-PHYs; Bank 2 only. X2 X2 Up to two RX D-PHYs. Only two clock divider primitives, one on bank 2 or 3 (right), one on bank 6 or 7 (left) Up to 4 RX D-PHYs (left and right sides) Four dedicated Clock Divider (CLKDVI) available TX D-PHY max limited by PIO TX D-PHY maximum limited TX D-PHY maximum limited A/B pirs; Bank 0 only by IO available in bank 2, 3, 6 by IO available in the bank and 7 if CLKDIV is shared on each side. If TX D-PHY on side, can only have RX D-PHY on the other Number of Lanes Depends on data rate and number of PIO A/B pairs available. DDRX4 requires A/B pair and Edge clock RX Performance 900 Mbps 550 Mbps 550 Mbps TX Performance 900 Mbps 550 Mbps 550 Mbps MIPI D-PHY Lane Number Selection Matrix Table Table 4 lists the selection of MIPI D-PHY Lane number and Line rate vs the Total Data Rate required by each video format. For clarity, this Matrix table only chooses three common resolutions and the major color depths as examples. The lane number and line rate for other video formats can be calculated using the equations listed in Bandwidth and Data Rate section. Table 4. MIPI D-PHY Interface Lane Number and Line Rate Selection Matrix Table MachXO2 and MachXO3L (900 Mbps I/O) Resolution Frame Rate Pixel Clock Color Depth Total Data Rate Hz MHz Bits Mbps # of Lane Line Rate Mbps 10 LatticeECP3 and ECP5 (550 Mbps I/O) Bit Clock # of Lane MHz Line Rate Bit Clock Mbps MHz MIPI D-PHY Bandwidth Matrix Table User Guide MachXO2 and MachXO3L (900 Mbps I/O) HD 1280x720p (1650x750) 60 120 240 FHD 1920x1080p (2200x1125) 60 120 UHD 3840x2160p (4400x2250) 30 60 74.25 148.5 297 148.5 297 297 594 8 594 10 16 297 LatticeECP3 and ECP5 (550 Mbps I/O) 1 594 2 297 148.5 742.5 1 742.5 371 2 371 185.6 1188 2 594 297 4 297 148.5 18 1336.5 2 668.25 334 4 334 167 24 1782 2 891 445.5 4 445.5 223 8 1188 2 594 297 4 297 148.5 10 1485 2 742.5 371 4 371 185.6 16 2376 4 594 297 18 2673 4 668.25 334 24 3564 4 891 445.5 8 2376 4 594 297 10 2970 4 742.5 371 16 4752 18 5346 24 7128 8 1188 2 594 297 4 297 148.5 10 1485 2 742.5 371 4 371 185.6 16 2376 4 594 297 18 2673 4 668.25 334 24 3564 4 891 445.5 8 2376 4 594 297 10 2970 4 742.5 371.25 16 4752 18 5346 24 7128 8 2376 4 594 297 10 2970 4 742.5 371 16 4752 18 5346 24 7128 8 4752 10 5940 16 9504 18 10692 24 14256 Figure 7 and Figure 8 illustrate the relationship between the Total Data Rates, lane numbers and line rates of the MIPI D-PHY interface over different video formats. The X axis shows the pixel clock rate, the Y axis shows the Total Data Rate, the yellow dash lines mark the aggregated bandwidth of the selected number of MIPI D-PHY data lanes. Any video formats (Resolution x Frame Rate x Color Depth) positioned above the yellow marker of the 4lane will not be supported by the target FPGA device family. Because MachXO2 and MachXO3L differential IOs can support double data rate up to 900 Mbps with x4 gearing ratio, the MachXO2 and MachXO3L are preferable to LatticeECP3 and ECP5 as MIPI D-PHY bridge device. 11 MIPI D-PHY Bandwidth Matrix Table User Guide Figure 7. MIPI D-PHY Total Data Rate vs Lane Number Selection for MachXO2/MachXO3L Device Total Data Rate (Mbps ) 4752 8-bit 10-bit 16-bit 18-bit 24-bit 4158 4 lanes 3.6 Gbps 3564 2970 3 lanes 2.7 Gbps 2673 2376 2 lanes 1.8 Gbps 1782 1485 1336.5 1188 1 lane 900 Mbps 742.5 594 HD FHD 74 .25 148 .5 297 60 Hz 120 Hz 240 Hz 60 Hz 120 Hz UHD 60 Hz 12 Pixel Clock (MHz ) MIPI D-PHY Bandwidth Matrix Table User Guide Figure 8. MIPI D-PHY Total Data Rate vs Lane Number Selection for LatticeECP3/ECP5 Device Bandwidth 8-bit 10-bit 16-bit 18-bit 24-bit (Mbps ) 4752 4158 3564 2970 2673 2376 4 lanes 2.2 Gbps 1782 3 lanes 1.65 Gbps 1485 1336.5 2 lanes 1.1 Gbps 1188 742.5 1 lane 550 Mbps 594 HD 74 .25 148 .5 297 60 Hz 120 Hz 240 Hz 60 Hz 120 Hz FHD UHD Pixel Clock (MHz ) 60 Hz Reference RD1182, MIPI D-PHY Interface IP Technical Support Assistance Submit a technical support case via www.latticesemi.com/techsupport. Revision History Date Version June 2015 1.0 Change Summary Initial release. 13