[chip, I2C, DV] Top level I2C host test#473
Conversation
fd42f2e to
0c033ce
Compare
dbb8d58 to
16ba0d4
Compare
4da05c4 to
d5d15ad
Compare
f33a9e9 to
3a25ff6
Compare
d5393fb to
a90365e
Compare
6d98478 to
e89e1dc
Compare
a007ff8 to
fb2d82e
Compare
d44829e to
f5bc214
Compare
ddb4891 to
4e61569
Compare
| @@ -0,0 +1,66 @@ | |||
| // Copyright lowRISC contributors (OpenTitan project). | |||
There was a problem hiding this comment.
| // Copyright lowRISC contributors (OpenTitan project). | |
| // Copyright lowRISC contributors (COSMIC project). |
| str = {str, $sformatf("\n timing_cfg.tSetupStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockLow : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockLow)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSetupBit : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupBit)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockPulse : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockPulse)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldBit : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldBit)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSetupStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tTimeOut : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tTimeOut)}; | ||
| str = {str, $sformatf("\n timing_cfg.enbTimeOut : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.enbTimeOut)}; | ||
| str = {str, $sformatf("\n timing_cfg.tStretchHostClock : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tStretchHostClock)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSdaUnstable : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaUnstable)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSdaInterference : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaInterference)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSclInterference : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSclInterference)}; |
There was a problem hiding this comment.
Can you do the following, as we have the right to go up to 120 characters per line in Mocha:
| str = {str, $sformatf("\n timing_cfg.tSetupStart : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldStart : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockStart : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockLow : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tClockLow)}; | |
| str = {str, $sformatf("\n timing_cfg.tSetupBit : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupBit)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockPulse : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tClockPulse)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldBit : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldBit)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockStop : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tSetupStop : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldStop : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tTimeOut : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tTimeOut)}; | |
| str = {str, $sformatf("\n timing_cfg.enbTimeOut : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.enbTimeOut)}; | |
| str = {str, $sformatf("\n timing_cfg.tStretchHostClock : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tStretchHostClock)}; | |
| str = {str, $sformatf("\n timing_cfg.tSdaUnstable : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaUnstable)}; | |
| str = {str, $sformatf("\n timing_cfg.tSdaInterference : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaInterference)}; | |
| str = {str, $sformatf("\n timing_cfg.tSclInterference : %d", | |
| cfg.m_i2c_agent_cfg.timing_cfg.tSclInterference)}; | |
| str = {str, $sformatf("\n timing_cfg.tSetupStart : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSetupStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldStart : %d", cfg.m_i2c_agent_cfg.timing_cfg.tHoldStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockStart : %d", cfg.m_i2c_agent_cfg.timing_cfg.tClockStart)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockLow : %d", cfg.m_i2c_agent_cfg.timing_cfg.tClockLow)}; | |
| str = {str, $sformatf("\n timing_cfg.tSetupBit : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSetupBit)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockPulse : %d", cfg.m_i2c_agent_cfg.timing_cfg.tClockPulse)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldBit : %d", cfg.m_i2c_agent_cfg.timing_cfg.tHoldBit)}; | |
| str = {str, $sformatf("\n timing_cfg.tClockStop : %d", cfg.m_i2c_agent_cfg.timing_cfg.tClockStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tSetupStop : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSetupStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tHoldStop : %d", cfg.m_i2c_agent_cfg.timing_cfg.tHoldStop)}; | |
| str = {str, $sformatf("\n timing_cfg.tTimeOut : %d", cfg.m_i2c_agent_cfg.timing_cfg.tTimeOut)}; | |
| str = {str, $sformatf("\n timing_cfg.enbTimeOut : %d", cfg.m_i2c_agent_cfg.timing_cfg.enbTimeOut)}; | |
| str = {str, $sformatf("\n timing_cfg.tStretchHostClock : %d", cfg.m_i2c_agent_cfg.timing_cfg.tStretchHostClock)}; | |
| str = {str, $sformatf("\n timing_cfg.tSdaUnstable : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSdaUnstable)}; | |
| str = {str, $sformatf("\n timing_cfg.tSdaInterference : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSdaInterference)}; | |
| str = {str, $sformatf("\n timing_cfg.tSclInterference : %d", cfg.m_i2c_agent_cfg.timing_cfg.tSclInterference)}; |
| // Read the timing parameters through SW backdoor load | ||
| sw_symbol_backdoor_read("SysClkPeriodNS", sw_sys_clk_period_ns); | ||
| sw_symbol_backdoor_read("SCLLowTimeNs", sw_scl_low_time_ns); | ||
| sw_symbol_backdoor_read("HoldDataTimeNs", sw_data_hold_time_ns); |
There was a problem hiding this comment.
Where sw_scl_clk_period_ns is populated? I think something like that is missing?
sw_symbol_backdoor_read("SCLClkPeriodNS", sw_scl_clk_period_ns);
There was a problem hiding this comment.
This is already there on L33
| } | ||
|
|
||
| void i2c_init(i2c_t i2c) | ||
| uint16_t i2c_calc_scl_high_cycles(uint16_t rise_cycles, uint16_t fall_cycles, |
There was a problem hiding this comment.
Maybe better to compute in uint32_t, in case the sum exceeds 16 bits. Then maybe check if it's not going over 16 bits and return in 16 bits?
| extern function new(string name=""); | ||
| extern task body(); | ||
| extern virtual task dut_init(string reset_kind = "HARD"); | ||
| extern local function void configure_agent_timing(); |
There was a problem hiding this comment.
Do we really need to restrict this function to be local?
There was a problem hiding this comment.
I will probably move it to the base vseq (top_chip_dv_i2c_tx_rx_vseq) and make it protected
| // "UM10204" Table 10 (rev. 6) / Table 11 (rev. 7). | ||
| // Faster modes will require different/adjustable constants and checking that SCL high/low | ||
| // cycles calculated are sufficient to still allow the clock stretching logic to function. | ||
| // scl_high_time should be atleast 4 cycles to aid correct clock streching |
There was a problem hiding this comment.
| // scl_high_time should be atleast 4 cycles to aid correct clock streching | |
| // scl_high_time should be at least 4 cycles to aid correct clock stretching |
|
|
||
| extern function new(string name=""); | ||
|
|
||
| // Obtain an integer minimum of timing parameter "a" and round up to the next highest integer. |
There was a problem hiding this comment.
Could you reformulate, I feel that the word minimum is confusing, but it might be my comprehension
There was a problem hiding this comment.
I think you are right. I meant spec minimum
| // | ||
| // The values for Rise and Fall times for Fast mode are taken as spec minimum. For Fast plus mode, | ||
| // the values are taken from OT's i2c_host_tx_rx_test.c test. | ||
| i2c_timing_params_t compute_minimum_timing_paramaters(i2c_speed_mode_t speed) |
There was a problem hiding this comment.
Nit:
| i2c_timing_params_t compute_minimum_timing_paramaters(i2c_speed_mode_t speed) | |
| i2c_timing_params_t compute_minimum_timing_parameters(i2c_speed_mode_t speed) |
Also, this function shouldn't be in the header file instead?
There was a problem hiding this comment.
You are suggesting the same thing?
Only function declarations are present in i2c.h here
| // specification "UM10204" Table 10 (rev. 6) / Table 11 (rev. 7). | ||
| // | ||
| // The values for Rise and Fall times for Fast mode are taken as spec minimum. For Fast plus mode, | ||
| // the values are taken from OT's i2c_host_tx_rx_test.c test. |
There was a problem hiding this comment.
| // the values are taken from OT's i2c_host_tx_rx_test.c test. | |
| // the values are taken from OpenTitan's i2c_host_tx_rx_test.c test. |
| #define I2C_FALL_NS (120) | ||
|
|
||
| void i2c_init(i2c_t i2c); | ||
| // All the speed modes supported by OT's I2C block |
There was a problem hiding this comment.
| // All the speed modes supported by OT's I2C block | |
| // All the speed modes supported by OpenTitan's I2C block |
Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
Controller writes multiple bytes to the target's receiver and then reads multiple bytes from the same address. At the end of both read and write transfer, the test checks if the transfer was succesful. If yes, then the test compares all the read bytes with the data bytes that was sent as part of write transfer. Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
2fe1620 to
f152d20
Compare
This vseq: ** reads the SW symbols to get the timing values ** calculates relevant timing parameter use by the agent to send Ack, Nack and Rdata. ** start the reactive sequence Signed-off-by: Kinza Qamar <kqzaman@lowrisc.org>
f152d20 to
e202744
Compare
Close #507