# DFT: Storing scan chain information in odb Tool: Design for Test Subcategory: Scan chain representation ## Conversation ### fgaray Hello everyone, To support drawing scan chains in OpenROAD in the gui and CTL ([Core Test Language](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=966626)) parser/generator we need to make the scan info available in odb. Here I describe a DB schema to represent CTLs in odb. ## Objective * Make scan chains available to the gui to be able to highlight scan structures and display information related to scan. * Provide a common source of true for other commands to query and find scan structures on the design. * Provide support for a future parser for CTLs files. ## Out of scope * Parsing and writing a CTL file at this time. * Handling test patterns. ## CTLs CTLs are files based on the [STIL standard](https://grouper.ieee.org/groups/1450/dot1/p1450.1-D14.pdf) that allow us to share information between DFT tools for optimizations and interoperability between different vendors. They describe the internal scan structures and they are useful too to share information between internal commands inside OpenROAD, like scan insertion and the GUI. ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/1619948/b513ec9c-4575-45c4-bac0-0401ab164da2) Source: CTL for Test Information of Digital ICs, Rohit Kapur **The schema described here is not a 1:1 map of a CTL file but should be enough to create one or to store the information coming from a CTL.** ## dbScanChain * name: string * length: uint * cells: list\ * scanIn: dbScanPin * scanOut: dbScanPin * scanClock: dbScanPin * scanEnable: dbScanPin * testMode: string * partitions: list\ * scanInsts: list\ ## dbScanPin Wrapper to handle either dbBTerm or dbITerm: * bterm: dbBTerm * iterm: dbITerm ## dbScanPartition * start: dbScanPin * stop: dbScanPin * name: string ## dbScanInst * scanIn: dbScanPin * scanOut: dbScanPin * bits: uint * type: enum [OneBit, ShiftRegister, BlackBox] ## Flow At the end of *insert_dft* we will be storing the scan chain information into odb using the created dbCTL object. The gui will be able to query this information and display it. dbScanChain will be attached to the dbBlock that contains the scan chains that are inside it. ## Open Questions * Where can I add a new dbObject (dbCTL) to dbBlock? * How can I represent maps (will std::map work?) string-> dbObject in the json db format? * I am creating a wrapper for dbBTerm and dbITerm for cases where the scan pins are not coming from the block, is there any way to handle this in the json db format? ### fgaray Hi @maliberty , who do you think is the right person to review this? Specially the open questions at the end. Thanks! ### maliberty Scan chain is used in both CTL and in DEF. Can dbScanChain accommodate both or do we need to consider having two classes? If the later, how would you suggest naming them ? ### maliberty Looking at DEF: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/761514/6a7a39c4-e9b0-44e5-8beb-0fe450c7928d) It looks like the dbScanPartition needs a way to store MAXBITS. Each element of the chain also has a BITS field which seems hard to represent here. Perhaps we need a dbScanInst? How would you infer FLOATING or ORDERED from the design? ### fgaray Hi @maliberty , Do you think we are ready to start the implementation? Thanks!, Felipe ### QuantamHD LGTM. Thanks for the contirbution @fgaray