__ _ ____ ___ __ _______ ___ ____ ______ _ __________ / /| | / / |/ / / / / / ___// | / __ \/_ __/ | | / / _/ __ \ / / | | / / /|_/ / / / / /\__ \/ /| | / /_/ / / / | | / // // /_/ / / /__| |/ / / / / / /_/ /___/ / ___ |/ _, _/ / / | |/ // // ____/ /_____/___/_/ /_/ \____//____/_/ |_/_/ |_| /_/ |___/___/_/ - Terminology 1 DCD Data Carrier Detect 1 DCD Data Carrier Detect 2 RxD Receive Data 2 TxD Transmit Data 3 TxD Transmit Data 3 RxD Receive Data 4 DTR Data Terminal Ready 4 DSR Data Set Ready 5 GND Ground (Signal) 5 GND Ground (Signal) 6 DSR Data Set Ready 6 DTR Data Terminal Ready 7 RTS Request to Send 7 CTS Clear to Send 8 CTS Clear to Send 8 RTS Request to Send 9 RI Ring Indicator 9 RI Ring Indicator DTE stands for Data Terminal Equipment. A computer is a DTE. DCE stands for Data Communication Equipment. A modem is a DCE. - VIP Configuration - .cfg.mode - Decides whether it works as normal mode or sync mode for usart - List of values: - LVM_USART_SYNC_MODE - CK, TX and RX will be operational for synchronous transfer - LVM_USART_NORMAL - TX, RX, and if flow control are used, then RTS, CTS, DCD, etc pins are operational - .cfg.usart_role - Decides the role of operations for an instance, only for the ASYNC mode - List of values: - LVM_USART_DTE - DTE mode: Data Terminal Equipment - CTS is input - RTS is output - LVM_USART_DCE - DCE mode: Data Communication Equipment - RTS is input - CTS is output - .cfg.role - Decides the role of operations for an instance, only for the SYNC mode - List of values: - LVM_MASTER - Send data via TX, receive data via RX - Provide clock to the bus via CK - LVM_SLAVE - Send data via TX, receive data via RX - Will wait for CK to start driving data - .cfg.data_width - Length of data bits including the parity bits if there is a parity bit - List of values: - LVM_USART_7_BITS - 6 bits data + 1 parity bit OR - 7 bits data - LVM_USART_8_BITS - 7 bits data + 1 parity bit OR - 8 bits data - LVM_USART_9_BITS - 8 bits data + 1 parity bit OR - 9 bits data - .cfg.data_msb_lsb - Controls the data sending order, MSB or LSB comes first - List of values: - LVM_USART_MSB_FIRST : If the TX/RX are having MSB sent first - LVM_USART_LSB_FIRST : If the TX/RX are having LSB sent first - .cfg.start_validation - This defines how is the start bit get validated - List of values: - LVM_USART_START_WITH_1SET : (2/3 of samples of 3,5,7 are 0) OR (2/3 of samples of 8,9,10 are 0) - LVM_USART_START_WITH_2SETS : (2/3 of samples of 3,5,7 are 0) AND (2/3 of samples of 8,9,10 are 0) - .cfg.trk_on - When it is activated, all the TX and RX packet information will be dumped into a tracker file - List of values: - LVM_OFF : Will not dump tracker file - LVM_ON : Dump tracker file - Example file content: --------------------------------------------------------------- Time Parity Data Char --------------------------------------------------------------- [Packet 29 ] 226840.000 ns NA 8'h48 H [Packet 30 ] 233880.000 ns NA 8'h65 e [Packet 31 ] 240920.000 ns NA 8'h6c l [Packet 32 ] 247960.000 ns NA 8'h6c l [Packet 33 ] 255000.000 ns NA 8'h6f o - .cfg.dump_mem - When it is activated, all the TX and RX data will be dumped into a file in binary format - List of values: - LVM_OFF : Will not dump binary file - LVM_ON : Dump binary file - User can open the dumped file via hexdump -C - Example file content: 00000000 01 02 03 04 05 06 01 02 03 04 05 06 01 02 03 04 |................| 00000010 05 06 01 02 03 04 05 06 2d 2d 3e 0a 48 65 6c 6c |........-->.Hell| 00000020 6f 20 66 72 6f 6d 20 44 54 45 0a 44 54 45 20 69 |o from DTE.DTE i| 00000030 73 20 44 61 74 61 20 54 65 72 6d 69 6e 61 6c 20 |s Data Terminal | 00000040 45 71 75 69 70 6d 65 6e 74 0a |Equipment.| 0000004a - .cfg.dump_char - When it is activated, all the TX and RX char data will be dumped into a file - List of values: - LVM_OFF : Will not dump char file - LVM_ON : Dump char file - Example file content: 226840.000000 ns [USART PRINTER] Hello from DTE 423640.000000 ns [USART PRINTER] DTE is Data Terminal Equipment - .cfg.in_line - Define whether the char printing is into sim log or dedicated log file. - List of values: - 0 : it will be printed into a seperate file called .cfg.char_log_name - 1 : all the char printing will be in the simulation log file (together with UVM messages, eg UVM_INFO) - .cfg.prefix - Define the prefix of the characters printed. - .cfg.time_unit - Define the timeunit of the timestamp for the characters printed. - .cfg.RTS_ACTIVE = 1 or 0? - Active value of RTS - Default to 1 - .cfg.CTS_ACTIVE = 1 or 0? - Active value of CTS - Default to 1 - .cfg.DTR_ACTIVE = 1 or 0? - Active value of DTR - Default to 1 - .cfg.DSR_ACTIVE = 1 or 0? - Active value of DSR - Default to 1 - .cfg.DCD_ACTIVE = 1 or 0? - Active value of DCD - Default to 1 - .cfg.RI_ACTIVE = 1 or 0? - Active value of RI - Default to 1 - .cfg.parity - Configure the parity mode, not available for SYNC mode - List of values: - LVM_USART_NO_PARITY : No parity bit (no parity check) - LVM_USART_EVEN_PARITY : 1 even parity, every data transmission will be checked against parity bit - LVM_USART_ODD_PARITY : 1 odd parity, every data transmission will be checked against parity bit - LVM_USART_MARK_PARITY : Always 1 parity - LVM_USART_SPACE_PARITY: Always 0 parity - .cfg.stop_bit - This is the length of the stop bit, not available for SYNC mode - List of values: - LVM_USART_0P5_STP_B : 0.5 clock - LVM_USART_1_STP_B : 1 clock - LVM_USART_1P5_STP_B : 1.5 clocks - LVM_USART_2_STP_B : 2 clocks - LVM_USART_2P5_STP_B : 2.5 clocks (extra support) - LVM_USART_3_STP_B : 3 clocks (extra support) - .cfg.bad_parity, not available for SYNC mode - Allow users to configure on the fly to inject bad parity packet, by toggling the parity bit - List of values: - 0 : Do not inject bad parity - 1 : Inject bad parity - .cfg.flow_control - This decides whether the usart instance has RS-232 flow control protocol, not available for SYNC mode - RTS = Request To Send, CTS = Clear To Send - List of values: - LVM_OFF : Master will not drive RTS, and will ignore CTS Slave will not drive CTS, and will ignore RTS - LVM_ON : RTS and CTS control the traffic flow on usart bus. - .cfg.cpol - During SYNC mode only, control the base value of the clock - List of values: - 0 : base value of clock will be 0 - 1 : base value of clock will be 1 - .cfg.cpha - During SYNC mode only, control the driving and sampling of data, corresponding with cpol value - List of values: ------------------+-------------------------------- CPOL CPHA | Data read Data driving ------------------+-------------------------------- 0 0 | POSEDGE NEGEDGE 0 1 | NEGEDGE POSEDGE 1 0 | NEGEDGE POSEDGE 1 1 | POSEDGE NEGEDGE - .cfg.x_injection - During SYNC mode only, control the driving of data whether with x injection or not - List of values: - 1'b0 : Will not do x injection - 1'b1 : Will inject x - .cfg.sync_setup - .cfg.sync_hold - During SYNC mode only, sync_setup controls how early the data is prepared before the sampling edge of clock - legal values are from 1 to 8 - During SYNC mode only, sync_hold controls how long the data is maintained after the sampling edge of clock - legal values are from 1 to 8 - for example, in posedge sampling case below, says 1 bit of data takes 16 clocks, while sync_setup = 3, sync_hold=5, that means A to E is 16 clocks B to C is sync_setup = 3 / 16 C to D is sync_hold = 5 / 16 A B C D E -----\/----------\/--------------- TX X data X -----/\----------/\--------------- +------------+ +------------ CK -----------| |-----------| - .cfg.OVER8 - this defines the oversampling of the uart wheather it is oversampling by 8 or by 16 - List of values: - 1'b1 : Oversampling by 8 - 1'b0 : Oversampling by 16 - .cfg.auto_baud_rate - Control an instance to do auto baud detection at its RX pin. - Default to 0 - When it is 1, user does not need to program the baud rate. - .cfg.baud_rate - let user to configure the desired baud rate in real value, in the unit of Mbps - eg: .cfg.baud_rate = 1.25; // This means baud rate is 1.25 Mbps - VIP Status - .cfg.vif.TX_NE - .cfg.vif.RX_NE - NOISE ERROR indication for TX and RX - When a sample has different values, it will be asserted - User can clear the status bit on the fly by just assigning it to 0 - .cfg.CK_period - This realtime variable ~CK_period~ returns the period for the CK - .cfg.calculated_CK_period - When it is 1, the value inside .cfg.CK_period is ready to be used - API sending data - .send(); - this API get the VIP to send serial data by excluding the parity bits, e.g .send('h1FF); // sending 9 bits of data Note: if data bits is exceeding the configured width, the excessed bits will be dropped. - .break_frame(); - this API get the VIP to send break frame, e.g .break_frame(); - .print(); - this API takes in string and print its ASCII code into the line - can be called from both dte and dce - Example: dte_env.print("DTE is Data Terminal Equipment\n"); This will get the DTE instance to send "D" --> "T" --> "E" ... - API signal control - These APIs take effect with .cfg.flow_control == LVM_ON - From DTE - . assert_RTS; - .deassert_RTS; - . assert_DTR; - .deassert_DTR; - From DCE - . assert_CTS; - .deassert_CTS; - . assert_DSR; - .deassert_DSR; - . assert_DCD; - .deassert_DCD; - . assert_RI; - .deassert_RI; - API for noise injection - These setting are only applicable for USART normal mode, which is doing noise injection. - .cfg.noise_injection = 1'b1; - This cfg will enable the noise injection, where out of 3 samples, 1 sample will have a toggled value - .cfg.noise_area - This cfg will determine which part of the usart frame to be impacted with noise errors. - List of values: - LVM_USART_START - LVM_USART_DATA - LVM_USART_PARITY - LVM_USART_STOP - NOTE: For 0.5 stop bit, if the total clock per bit >= 16, then it support error injection. - API data checker - .expected_data() - let user to queue the expected data at VIP RX side (DUT TX side) - Example usage: dce_env.expected_data('hF0F0); dce_env.expected_data('h1234); dce_env.expected_data('h8888); dce_env.expected_data('hAAAA); - this will trigger the data self check when dce_env RX side is receiving data - start from F0F0 to AAAA - Debugability - .cfg.vif.tx_line_state - .cfg.vif.rx_line_state - this signal shows the packet fields, values are: - LVM_USART_IDLE Idle state where no packet is available - LVM_USART_START_P Mostly is a start bit, once confirmed via the oversampling, it will transition to LVM_USART_START - LVM_USART_START Confirmed is a start bit, this state last 1 clock. - LVM_USART_DATA This is within the data flow packet. - LVM_USART_PARITY_EVEN It is a even parity bit - LVM_USART_PARITY_ODD It is a odd parity bit - LVM_USART_STOP_P It is a stop state, but not yet verified via oversampling yet. - LVM_USART_STOP A stop state, where oversampling has been done and qualified. - .cfg.vif.tx_packet_data - .cfg.vif.rx_packet_data - this is the hex value of serial data. Only available at stop bit. - Ease user to look at waveform on sent data - .cfg.vif.tx_bit_time_count - .cfg.vif.rx_bit_time_count - It is 1-based counter to show the current data bit number. - Dumping data into a file (writememh) - There are multiple dump file per data pins - Tracker - List of files: - .cfg.trk_on = LVM_ON Tracker log Showing information for time, data value and parity of the packet sent - .cfg.dump_mem = LVM_ON Mem log Showing the total data transferred thru out the simulation in hex dump file format - .cfg.dump_mem = LVM_ON Char log Showing the ASCII content, with timestamp information - Checker - Confirm the parity bit is correct during stop bit is sent - Data x checker - User scoreboard - Demonstrate the sequence item retrieval syntax