<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Mozilla/4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) [Netscape]"> <title>Iosim DV Environment</title> </head> <body> <center> <h2> IOSIM DV Environment</h2></center> <h3> <b> </b>IOSIM Component</h3> <img SRC="iosim.gif" ALT="" height=557 width=1141> <p><font size=+1>1. IOSIM Test</font> <p> Test itself, you can write it in .tst file format(you can use tst2c to convert your tst file into "C" file later) or write in "C". <p> The ".tst" file format: <br> command [parameters] <br> The line which starts is not command will be treat as comments(not runable), to make less confusion and later extension, plese use "//" at the beginning of the each comment line. <p> The common used commands are: <p> <b>s <stall cycles></b> <br> Ask bcp to move forward certain cycles. <br> In "C", BCP_STALL(stall_cycles); <p> <b> t #id parameter0 -3</b> <br> call the test function according to given id(which is defined as function table in iotestcmd.c) with given four paramters. <br> The prototype of test function is int Test_name(int, int, int, int). <br> In "C", Test_name(p1, p2, p3, p4); <i><font size=-1>/* return -1 if test fail */</font></i> <p> <b> k 0/1</b> <br> Keep/Close persist socket connections. <br> Persist socket connect will save socket setup overhead times, so if you do a lot of IOs with simulator, please use persistent connection. <br> Please remember to close it when test is done or switching between tests. <br> In "C", do_keep_alive_socket(1/0); <p> <b> d string</b> <br> Ask simulator to display any message(<64 byte) for debugging purpose. <br> In "C", displayMsg("message body"); <p> <b>dump 0/1</b> <br> Turn on/off verilog dump <p> <b> q</b> <br> Stop simulator, in "C", IoCmd(REQ_QUIT, 0). <br> <p><font size=+1>2. Test APIs</font> <p> In theory, we can write tests only based on atomic APIs, but it is very hard if we do not have loop/condition mechanisms. Test APIs are routines written in "C" to call atomic APIs to achieve certain functions. <p><font size=+1>2.1 General Test APIs</font> <p> Those APIs cab be used for testing different components. <p> <b><a href="#InitDDR">InitDDR( )</a></b> <br> Initialize DDR memory controller. <p> <b><a href="#register_test">register_test( )</a></b> <br> General register test. <br> If you use .tst file, test id is 202. <br> Note : <br> This test might not fit all registers. <br> For example, SP_STATUS(0x4040010), <br> but you still can use it to test bit from 2 to 31, <br> then use MemWriteRead or MemReadCompMask to test bit 0 and 1. <p> <a href="#MemRead">MemRead( )</a> <br> Memory/register/sram read(From RCP). <br> .tst id is: 100 <p> <a href="#MemReadCompare">MemReadCompare( )</a> <br> Memory/register/sram read and comparison. (From RCP) <br> .tst id is: 101 <p> <a href="#MemWrite">MemWrite( )</a> <br> Memory/reg/sram write. (From RCP) <br> .tst id is: 102 <p> <a href="#MemWriteRead">MemWriteRead( )</a> <br> Memory/reg/sram write, read back and compare. (From RCP) <br> .tst id is: 103 <p> <a href="#MemReadCompMask">MemReadCompMask()</a> <br> Memory read and compare with given mask. (From RCP) <br> .tst id is: 108 <p> More will be add here. (some from old RCP) <p><font size=+1>2.2 Specific Test APIs</font> <p> Those APIs are written for specific components. For examples, AiDmaTests for AI component only. <p><font size=+1>3. Atomic API</font> <p> You are highly recommended to use those functions to build your tests. <p> The most common ones are: <br> (a) <b><a href="#IO_READ">IO_READ( ) </a> & <a href="#IO_WRITE">IO_WRITE( )</a></b> <br> Read or write a single word(4 bytes) into memory or register. Please note, those API will handle endian(as integer) for you. <p> (b) <b><a href="#SIM_TIME">SIM_TIME( )</a></b> <br> Get simulator uptime in ns. You might need this for timeout function or debug. <p> (c) <b><a href="#BD_IO_READ">BD_IO_READ( )</a> & <a href="#BD_IO_WRITE">BD_IO_WRITE( )</a></b> <br> Backdoor memory read/write a single word(4 bytes) <p> (d) <b><a href="#BCP_STALL">BCP_STALL( )</a></b> <br> Let BCP move forward the given system clks. <p> (e) <b><a href="#CHECK_INTERRUPT">CHECK_INTERRUPT</a></b> <br> Return interrupt info at last i/o operation. <p> (f) <b><a href="#_TRACE">_TRACE( )</a></b> <br> Iosim trace functions. <p> If you want to handle x/z, you can use the following functions: <br> V_IO_SREAD_BYTE( ), V_IO_SREAD_HWORD( ) and V_IO_SREAD_WORD( ) <br> V_IO_SWRITE_BYTE( ), V_IO_SWRITE_HWORD, V_IO_SWRITE_WORD( ) <br> with prefix BD, it will change to backdoor memory access functions. <br> To handle x,z, a new data structure is introduced, <br> <i><font size=-1>struct {</font></i> <br><i><font size=-1> int data_part, xz_part;</font></i> <br><i><font size=-1> } V_INT, *PV_INT;</font></i> <table BORDER COLS=3 WIDTH="200" NOSAVE > <tr> <td> <center>data_part</center> </td> <td>xz_part</td> <td> <div align=right>Result</div> </td> </tr> <tr> <td> <div align=right>0</div> </td> <td> <div align=right>0</div> </td> <td> <div align=right>0</div> </td> </tr> <tr> <td> <div align=right>1</div> </td> <td> <div align=right>0</div> </td> <td> <div align=right>1</div> </td> </tr> <tr> <td> <div align=right>0</div> </td> <td> <div align=right>1</div> </td> <td> <div align=right>z</div> </td> </tr> <tr> <td> <div align=right>1</div> </td> <td> <div align=right>1</div> </td> <td> <div align=right>x</div> </td> </tr> </table> <p> There are also block read/write functions if you have to read/write big chunk of data(Say, > 64Kbytes <current less than 1sec via backdoor single I/O>). <br> V_IO_BREAD( ), V_IO_BWRITE( ), BD_V_IO_BREAD( ) and BD_V_IO_BWRITE( ) <p> <font size=+1>4. PLI function</font> <p> In general, you do not need to worry about those APIs unless you want to change ipc mechanism. <p><font size=+1>5. Misc</font> <p><font size=+1> 5.1 <a NAME="General Rule"></a>General Rule</font> <p> * If the test failed, return -1. (.tst file request) <br> Please also use _TRACE(DERROR, ...) to report error <br> * All new component test (like pi, si, usb, etc) should be in directory(iosim/src/test_name) as Andy suggested. <br> * Please use _TRACE as log mechanism. <br> I will port all others(like fprintf(stderr...) in all existing tests. <br> * If Error occur, please write "ERROR" in log file. <br> After test is done, grep ERROR or Failed(.tst generated) to make sure all test are passed. <p><font size=+1>Reference:</font> <p><a NAME="_TRACE"></a><b>_TRACE</b> <br>Macro _TRACE(type, code) <br>Description: <br> If certain type is set, execute the code. <br> In general, the code will be fprintf(LogFp, ...) <br>Header file: trace.h <br>Parameter: <br> type -- trace type <br> <font size=-1>DALL (0xFFFFFFFF) : All debug types</font> <br><font size=-1> DERROR(0x00000001): Error tracing</font> <br><font size=-1> DREAD(0x00000002 ): Read tracing</font> <br><font size=-1> DWRITE(0x00000004): Write tracing</font> <br><font size=-1> DSIGNAL(0x00000008): Signal tracing</font> <br><font size=-1> DINST(0x00000010): Instruction tracing</font> <br><font size=-1> DREGS(0x00000020 ): Register tracing</font> <br><font size=-1> DLOG (0x00000040): Log tracing</font> <br><font size=-1> DTRANS (0x00000080) IO R/W tracing</font> <br><font size=-1> DSTATUS(0x00000100) Status tracing</font> <br><font size=-1> DCOMPARE(0x00000200) Data compare tracing */</font> <br> code -- "C" code <br>Note: <br> If you use .tst file, specify "-d trace_type(hex) -l logfile". <br> In "C", set global varible: <br> Dflags --- Your trace type <br> LogFp = fopen("your log file name here", "w"); <br> If you do not specify log file, it will output to stderr. <p>Examples: <br> <font size=-1>if (timeout)</font> <br> <font size=-1>_TRACE(DERROR, fprintf(LogFp, "ERROR: BCP timeout"));</font> <p><font size=-1> dma_addr = IO_READ(Address_of_DMA_current);</font> <br><font size=-1> _TRACE(DCOMPARE, fprintf(LogFp, "Info: current dma addr=%x", dma_current));</font> <p><a NAME="BCP_STALL"></a><b>BCP_STALL</b> <br>Macro: BCP_STALL(cycles) <br>Description: Let simulator move forward given cycles. <br>Header file: bcp_util.h <br>Paramter: number of BB cycles <br>Examples: <br><i><font size=-1> /* write to memory in x36 mode, backdoor read back in x64 mode */</font></i> <br><font size=-1> IO_WRITE(0x00000000, 0xbabecafe);</font> <br><font size=-1> BCP_STALL(10); /* stall to wait for writing is done */</font> <br><font size=-1> ret = BD_IO_READ(0x01000000);</font> <br><font size=-1> if (ret != 0xbabecafe) /* Error occured*/</font> <p><a NAME="BD_IO_READ"></a><b>BD_IO_READ</b> <br>macro: BD_IO_READ( address) <br>Description: <br> Read data at given memory address via memory backdoor. <br>Header file: bcp_util.h <br>Parameter: <br> address --- BB memory space. (x36/x64 mode) <br>Examples: <br> <i> <font size=-1>/* write to memory in x36 mode, backdoor read back in x64 mode */</font></i> <br><font size=-1> IO_WRITE(0x00000000, 0xbabecafe);</font> <br><font size=-1> BCP_STALL(10); /* stall to wait for writing is done */</font> <br><font size=-1> ret = BD_IO_READ(0x01000000);</font> <br><font size=-1> if (ret != 0xbabecafe) /* Error occured*/</font> <p><a NAME="BD_IO_WRITE"></a><b>BD_IO_WRITE</b> <br>macro: BD_IO_WRITE( address, data) <br>Description: <br> Write data to given memory address via memory backdoor. <br>Header file: bcp_util.h <br>Parameter: <br> address --- BB memory space. (x36/x64 mode) <br> data --- writing data <br>Examples: <br> <i> <font size=-1>/* write to memory in x64 mode via backdoor, then read back */</font></i> <br><font size=-1> BD_IO_WRITE(0x010000000, 0xbabecafe);</font> <br><font size=-1> ret = BD_IO_READ(0x00000000);</font> <br><font size=-1> if (ret != 0xbabecafe) /* Error occured*/</font> <p><a NAME="CHECK_INTERRUPT"></a><b>CHECK_INTERRUPT</b> <br>Macro: CHECK_INTERRUPT <br>Description: <br> BB interrupt at last ipc call. <br> Bit 5 : NMI <br> Bits 4-0: BB interrupts <br>Examples: <br> <font size=-1>int i, int_l, j;</font> <p><font size=-1> <i>/* checkout interrupt info every interval or timeout*/</i></font> <br><font size=-1> for (i=j=1; i<timeout; i+=interval, j++) {</font> <br><font size=-1> int_l = CHECK_INTERRUPT;</font> <br><font size=-1> if (int_l & 0x02) return 1;</font> <br><font size=-1> bcp_stall(interval);</font> <br><font size=-1> if (j % 250 == 0 ) displayMsg("* Wait for interrupt *");</font> <br><font size=-1> }</font> <p><a NAME="InitDDR"></a><b>InitDDR</b> <br>Function: int InitDDR(int, int, int, int) <br>Description: <br> Initialize DDR memory controller <br>Header file: bcptest.h <br>Parameter: not used <br>Return: 0 <br>Examples: <br> <font size=-1>InitDDR(0, 0, 0, 0);</font> <p><a NAME="IO_READ"></a><b>IO_READ</b> <br>Macro: IO_READ( address) <br>Description: <br> Read data at given memory address,register or sram . <br>Header file: iomap.h <br>Parameter: <br> address --- BB memory map space <br>Examples: <br> <i> <font size=-1>/* write to memory in x36 mode, then read back in x64 mode */</font></i> <br><font size=-1> IO_WRITE(0x00000000, 0xbabecafe);</font> <br><font size=-1> ret = IO_READ(0x01000000);</font> <br><font size=-1> if (ret != 0xbabecafe) /* Error occured*/</font> <p><a NAME="IO_WRITE"></a><b>IO_WRITE</b> <br>macro: IO_WRITE( address, data) <br>Description: <br> Write data to given memory address/register/sram. <br>Header file: bcp_util.h <br>Parameter: <br> address --- BB memory map space. <br> data --- writing data <br>Examples: <br> <i> <font size=-1>/* write to memory in x64 mode via backdoor, then read back */</font></i> <br><font size=-1> IO_WRITE(0x010000000, 0xbabecafe);</font> <br><font size=-1> ret = IO_READ(0x00000000);</font> <br><font size=-1> if (ret != 0xbabecafe) /* Error occured*/</font> <p><a NAME="MemRead"></a><b>MemRead</b> <br>Function: <br> int MemRead(int addr, int a2, int a3, int a4); <br>Description: <br> call IO_READ to read data from reg/memory/sram. <br>Header file: <br> iotest.h <br>Paramter: <br> addr --- BB memory map space. <br> a2, a3, a4 --- extra <br>Return 1 <br>Example: <br><font size=-1> /* in .tst <i>t 100 00000004 00000000 00000000 0000000 */</i></font> <br><font size=-1> MemRead(0x4, 0, 0, 0);</font> <p><a NAME="MemReadCompMask"></a><b>MemReadCompMask</b> <br>Function: <br> int MemReadCompMask(int addr, int data, int mask, int failExpected); <br>Description: <br> call IO_READ to read data from reg/memory/sram and compare it with data. <br>Header file: <br> iotest.h <br>Paramter: <br> addr --- BB memory map space. <br> data --- Expect data <br> mask --- Compare mask <br> failExpected --- supposed to fail? <br>Return -1 if failed(mismatch(&mask) && failExpect==0). <br>Example: <br><font size=-1> /* in .tst <i>t 108 04040010 00000000 00000001 0000000 */</i></font> <br><i><font size=-1> /* Read Sp status and compare only on bit 0 */</font></i> <br><font size=-1> MemReadCompMask(0x4040010, 0, 1, 0);</font> <br><font size=-1> </font> <br><a NAME="MemReadCompare"></a><b>MemReadCompare</b> <br>Function: <br> int MemReadCompare(int addr, int data, int a3, int failExpected); <br>Description: <br> call IO_READ to read data from reg/memory/sram and compare it with data. <br>Header file: <br> iotest.h <br>Paramter: <br> addr --- BB memory map space. <br> data --- Expect data <br> a3 --- extra <br> failExpected --- supposed to fail? <br>Return -1 if failed(mismatch & failExpect==0). <br>Example: <br><font size=-1> /* in .tst <i>t 101 00000004 0000ffff 00000000 0000000 */</i></font> <br><i><font size=-1> /* Read memory 4, and check if it equal 0xffff */</font></i> <br><font size=-1> MemReadCompare(0x4, 0xffff, 0, 0);</font> <br><font size=-1> </font> <br><a NAME="MemWrite"></a><b>MemWrite</b> <br>Function: <br> int MemWrite(int addr, int data, int a3, int a4); <br>Description: <br> call IO_WRITE to write data into reg/memory/sram. <br>Header file: <br> iotest.h <br>Paramter: <br> addr --- BB memory map space. <br> data --- data <br> a3, a4--- extra <br>Return 1 <br>Example: <br><font size=-1> /* in .tst <i>t 102 00000004 0000ffff 00000000 0000000 */</i></font> <br><i><font size=-1> /* write 0xffff into memory 4 */</font></i> <br><font size=-1> MemWrite(0x4, 0xffff, 0, 0);</font><b></b> <p><a NAME="MemWriteRead"></a><b>MemWriteRead</b> <br>Function: <br> int MemWriteRead(int addr, int data, int exp, int failExpected) <br>Description: <br> Memory/reg/sram write, read back and compare. <br>Header file: <br> iotest.h <br>Paramter: <br> addr --- BB memory map space. <br> data --- data write to memory/reg/sram <br> exp --- expect read back data <br> failExpected --- supposed to fail? <br>Return -1 if failed(mismatch & failExpect==0). <br>Example: <br><font size=-1> /* in .tst <i>t 103 00000004 0000ffff 0000ffff 0000000 */</i></font> <br><i><font size=-1> /* write/read 0xfffff to/from memory 4, and check if it equal 0xffff */</font></i> <br><font size=-1> MemReadCompare(0x4, 0xffff, 0xffff, 0);</font> <br> <br> <font size=-1>/* <i>t 103 04040010 00000001 00000000 00000000</i></font> <br><i><font size=-1> Clear halt bit in SP then check , then check if it cleared.</font></i> <br><i><font size=-1> t 103 04040010 00000001 00000001 00000001</font></i> <br><i><font size=-1> The same but expect failure.</font></i> <br><i><font size=-1> t 103 04040010 00000002 00000001 00000000</font></i> <br><i><font size=-1> Set halt bit, then check if halt get set.</font></i> <br><i><font size=-1> Those tests at reset time, otherwise you should use MemReadCompMask</font></i> <br><font size=-1> */</font> <br><font size=-1> MemReadCompare(0x4040010, 1, 0, 0);</font> <br><font size=-1> MemReadCompare(0x4040010, 1, 1, 1);</font> <br><font size=-1> MemReadCompare(0x4040010, 2, 1, 0);</font> <br> <br><a NAME="register_test"></a><b>register_test</b> <br>Function: int register_test(int addr, int rw_mask, int ronly_mask, int extra) <br>Description: <br> Register test. <br> * Walk through bit from 0 to 31 <br> if rw_mask of this bit is set, write 0,1 to it, then read back, and check if they are the same. <br> if ronly_mask is set, read this register to old_v(only read once), write 0,1 to it, then read back, and check if it equals to the same bit in old_v. <br> * put the random number in this register, check if <br> (write_data & rw_mask ) == (read_data & rw_mask) <br> (read_data & ronly_mask) == (old_v & ronly_mask) <br>Header file: bcptest.h <br>Parameters: <br> addr --- BB register address <br> rw_mask --- read/write bit mask <br> ronly_mask --- read only bit mask <br> extra --- not used <br>Return: <br> -1 if failed. <p>Examples: <br> <font size=-1>.tst file</font> <br><font size=-1> t 202 4001000 FFFFFFFF 00000000 00000000</font> <br><font size=-1> t 202 4080004 00000003 00FFFFFC 00000000</font> <p> <font size=-1>In "C" file:</font> <br><font size=-1> register_test(0x4001000, 0xffffffff, 0, 0);</font> <br><font size=-1> register_test(0x4080004, 3, 0x00fffffc, 0);</font> <p><a NAME="SIM_TIME"></a><b>SIM_TIME</b> <br>Macro: SIM_TIME(ns_pointer) <br>Description: <br> Store current simulator uptime(in ns) into ns_pointer <br>Header file: bcp_util.h <br>Parameters: <br> ns_pointer : long long pointer <br>Return: 0 <br>Examples: <br> <i><font size=-1>/* delay 8000 ns */</font></i> <br><font size=-1> long long st, end;</font> <p><font size=-1> SIM_TIME(&st);</font> <br><font size=-1> while (1) {</font> <br><font size=-1> SIM_TIME(&end);</font> <br><font size=-1> if ((end-st) > 8000) break;</font> <br><font size=-1> BCP_STALL(1);</font> <br><font size=-1> }</font> <br> <br> <br> <br> <br> <br> <br> <br> </body> </html>