Method for intelligently generating custom chip symbols in LTspice circuit simulation platform
By obtaining and processing coordinate information from the circuit schematic diagram, it automatically determines and divides the edges to which the chip pins belong, solving the problem of cumbersome self-built chip symbols in the LTspice simulation platform, realizing efficient and accurate automatic generation of chip symbols, and simplifying the user experience. operating procedures.
Patent Information
- Application Number
- CN202410590148.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2024-10-11
AI Technical Summary
The process of self-creating chip symbols in the LTspice simulation platform is cumbersome and time-consuming, and existing technology cannot efficiently customize chip symbols.
By obtaining the coordinates of the chip center point and the end corner coordinates of the rectangular frame from the circuit schematic picture, calculate the distance value between the external rectangular frame of the chip pin and the original chip rectangular frame, determine and divide the edge to which the chip pin belongs, and combine the background color and pixel value Expand the rectangular frame, automatically construct chip symbol related information and write it to the file.
Intelligent automatic generation of chip symbols based on circuit schematics is realized, reducing the manual creation process, improving accuracy and efficiency, and simplifying the construction process of chip symbols.
Smart Images

Figure CN118761373A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of chip symbols, and in particular relates to a method for intelligently generating custom chip symbols in an LTspice circuit simulation platform. Background Art
[0002] LTspice is a powerful and efficient free SPICE simulator software, schematic acquisition and waveform viewer. For the pre-sales and after-sales technical support work of technical support engineers in the chip industry, easy-to-use SPICE simulation software plays an important role in the work. The built-in component library of LTspice is very rich and can meet most simulation needs. When the built-in component library cannot meet the needs, users need to build their own components and store them in the library for subsequent simulation calls.
[0003] Taking the example of building a chip symbol in the LTspice simulation platform, users need to perform the following steps to complete it: manually create a rectangular frame, manually add chip pins and set multiple parameter information. This manual process of creating chip symbols is cumbersome, time-consuming and laborious. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention provides a method for intelligently generating custom chip symbols in the LTspice circuit simulation platform, which solves the above problems.
[0005] To achieve the above objectives, the present invention is implemented by the following technical scheme: a method for intelligently generating custom chip symbols in an LTspice circuit simulation platform, comprising the following steps:
[0006] S1. Obtain the center point coordinates and the corner coordinates of the rectangular frame of the original chip, the center point coordinates of each chip pin and the corner coordinates of its circumscribed rectangular frame from the circuit schematic image, and calculate the distance values between the circumscribed rectangular frame of each chip pin and the corresponding sides of the original chip rectangular frame based on the above coordinate information;
[0007] S2, take the two smallest distance values in S1, and obtain their maximum ratio, and then compare the maximum ratio with a preset multiple threshold;
[0008] S3. For chip pins whose maximum ratio is greater than the multiple threshold, take the minimum distance value in S1, and the edge of the original chip rectangular frame corresponding to the minimum distance value is the edge to which the chip pin belongs;
[0009] S4. For chip pins whose maximum ratio is less than the multiple threshold, first obtain the pixel value of the background color of the circuit schematic image, expand the original chip rectangular frame, obtain the corner coordinates of the new chip rectangular frame, and determine the corner area to which the chip pin belongs based on the center point coordinates of the new chip and the center point coordinates of each chip pin, and take the corner coordinates of the new chip rectangular frame and the corner coordinates of the chip pin external rectangular frame in the corner area to form a rectangular area;
[0010] S5, taking the rectangular area formed by the corner coordinates of the chip pin external rectangular box and the corresponding end points of the circuit schematic image in the corresponding corner area, obtaining the coordinates of all pixel points in the area that are not equal to the pixel value of the background color, obtaining all horizontal and vertical lines formed by these pixel points, and selecting the longest line that intersects with the new chip rectangular box, and determining which side of the line and the new chip rectangular box has an intersection, and this side is the side to which the chip pin belongs;
[0011] S6. Create a file, write the chip rectangle and chip pin related information into the file, and save and install the file.
[0012] Furthermore, the corner coordinates of the rectangular frame of the original chip include upper left corner coordinate information and lower right corner coordinate information, and the corner coordinates of the rectangular frame of the chip pin include upper left corner coordinate information and lower right corner coordinate information.
[0013] Furthermore, the distance values between the external rectangular frame of each chip pin and the corresponding sides of the original chip rectangular frame are respectively recorded as dtop, dleft, dright and dbottom, where the minimum value of the above four distance values is recorded as dmin, the second smallest value in the distance is recorded as dsecmin, and the maximum ratio is recorded as times, times = dsecmin / dmin.
[0014] Furthermore, the multiple threshold is recorded as thre, and the parameter is set to 2.2. If the chip pin times is greater than thre, then the chip pin belongs to set A, otherwise it belongs to set B, until all chip pins are divided into set A or set B.
[0015] Furthermore, in the S3, it is specifically to determine the edge to which each chip pin in the set A belongs. If dmin=dtop, then the chip pin belongs to the top edge of the chip; if dmin=dleft, then the chip pin belongs to the left edge of the chip; if dmin=dright, then the chip pin belongs to the right edge of the chip; if dmin=dbottom, then the chip pin belongs to the bottom edge of the chip.
[0016] Furthermore, the original chip rectangular frame is expanded outwards to an intersection with the chip pin external wire.
[0017] Further, the corner area in S4 includes four categories: upper left corner area, lower left corner area, upper right corner area and lower right corner area. The range of the corner area is a rectangular area formed from point M to point N, wherein point M is the coordinate of the farthest end point from the external rectangular frame of the chip pin to the new chip rectangular frame in the corresponding corner area, and point N is the coordinate of the end point of the new chip rectangular frame corresponding to the corner area;
[0018] And all the pixels in the rectangular area formed by the corner coordinates of the new chip rectangular frame and the corner coordinates of the chip pin external rectangular frame in the corresponding corner area are set to black.
[0019] Furthermore, the coordinates of all pixels with unequal background color pixel values are obtained by traversing the contents of the rectangular area formed by the corner coordinates of the chip pin external rectangular box and the corresponding endpoints of the circuit schematic image, and all unequal pixel coordinates are summarized into a set P, and the horizontal and vertical lines formed by all the pixels in the set P are obtained, and it is determined whether there is an intersection with the new chip rectangular box. If there is an intersection, then the longest line among these horizontal and vertical lines is taken, and the rectangular box edge is the edge to which the chip pin belongs.
[0020] Furthermore, the file in S6 is specifically a file with the suffix .asy, and the chip rectangular frame related information includes the coordinates of the upper left corner and the lower right corner and the chip name, and the chip pin related information includes the pin coordinates, pin name, pin side, pin offset distance and pin number information.
[0021] A machine-readable storage medium stores a program, which, when executed by a processor, implements the above distribution method.
[0022] Beneficial Effects
[0023] The present invention provides a method for intelligently generating custom chip symbols in an LTspice circuit simulation platform, which has the following beneficial effects compared with the prior art:
[0024] The present invention can automatically generate chip symbols based on an input circuit schematic diagram, so that users can build circuit diagrams and call them in the simulation platform, eliminating the tedious manual creation process, reducing time consumption, improving accuracy, and achieving the purpose of improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a schematic diagram of the distances from the four sides of the rectangular frame circumscribing each pin of the chip of the present invention to the corresponding sides of the rectangular frame of the chip.
[0026] Figure 2 The present invention intelligently generates LTSPICE chip symbol effects based on circuit schematic pictures Figure Ⅰ .
[0027] Figure 3 The present invention intelligently generates LTSPICE chip symbol effects based on circuit schematic pictures Figure II .
[0028] Figure 4 The present invention intelligently generates LTSPICE chip symbol effects based on circuit schematic pictures Figure III . DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0030] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.
[0031] See also Figure 1-4 , provided in one embodiment of the present invention, is a method for intelligently generating custom chip symbols in an LTspice circuit simulation platform, comprising the following steps:
[0032] S1. Obtain the coordinate information of the center point of the chip, the coordinate information of the upper left corner of the chip rectangular frame, the coordinate information of the lower right corner of the chip rectangular frame, the coordinate information of the center point of each chip pin, the coordinate information of the upper left corner of the external rectangular frame of each chip pin, and the coordinate information of the lower right corner of the external rectangular frame of each chip pin from the circuit schematic image through a deep learning method, wherein the name of each chip pin is also obtained through deep learning;
[0033] S2. Based on the information obtained in step S1, calculate the distances between the four sides of the rectangular box surrounding each pin name of the chip and the corresponding sides of the rectangular box of the chip, and record them as dtop, dleft, dright and dbottom respectively, as follows: Figure 1 As shown, dtop is the top distance value, dleft is the left distance value, dright is the right distance value, and dbottom is the bottom distance value;
[0034] Wherein dtop is the absolute value of the difference between the ordinate of the upper left corner of the chip rectangular frame and the ordinate of the upper left corner of the chip pin circumscribed rectangular frame in step S1;
[0035] dleft is the absolute value of the difference between the horizontal coordinate of the upper left corner of the chip rectangular frame and the horizontal coordinate of the upper left corner of the chip pin circumscribed rectangular frame in step S1;
[0036] dright is the absolute value of the difference between the horizontal coordinate of the lower right corner of the chip rectangular frame and the horizontal coordinate of the lower right corner of the chip pin circumscribed rectangular frame in step S1;
[0037] dbottom is the absolute value of the difference between the ordinate of the lower right corner of the chip rectangular frame and the ordinate of the lower right corner of the chip pin circumscribed rectangular frame in step S1;
[0038] S3. For each chip pin, select the minimum value of the four distances in step S2 and the second smallest value of the four distances in step S2 and record them as dmin (minimum distance value) and dsecmin (second smallest distance value), respectively. Calculate the multiple of dsecmin relative to dmin, recorded as times, where times = dsecmin / dmin (i.e., times is the maximum ratio of dsecmin to dmin);
[0039] S4. If the chip pin times obtained in step S3 is greater than thre, the chip pin is divided into set A, otherwise it is divided into set B. Based on the above judgment, all chip pins are divided into set A or set B, where thre is a multiple threshold value and its specific value is set by relevant personnel. In the embodiment of the present invention, thre=2.2;
[0040] S5. Combine step S2 and step S3 to determine the edge to which each chip pin in set A belongs, specifically:
[0041] If dmin=dtop, the chip pin belongs to the top edge of the chip;
[0042] If dmin=dleft, the chip pin belongs to the left edge of the chip;
[0043] If dmin=dright, the chip pin belongs to the right edge of the chip;
[0044] If dmin = dbottom, the chip pin belongs to the bottom edge of the chip;
[0045] S6. Obtain the pixel value of the background color of the circuit schematic image (the pixel value of the background color is the pixel value that appears most frequently in the entire image);
[0046] S7, such as Figure 2-4 As shown, the original chip area is expanded to the intersection with the chip pin external line, and the upper left corner coordinates and the lower right corner coordinates of the new chip rectangular frame are obtained;
[0047] Assuming that expanding by x pixels can make the original chip area expand to an intersection with the chip pin external line, the horizontal and vertical coordinates of the upper left corner of the original chip rectangular box decrease by x, and the horizontal and vertical coordinates of the lower right corner of the original chip rectangular box increase by x (in the coordinate system of the algorithm, the coordinates increase to the right and downward).
[0048] S8. Based on the coordinates of the center point of the chip rectangular frame and the coordinates of the center point of the chip pin, determine the corner area to which each chip pin in set B belongs, and set all pixels in the corner area to black;
[0049] Among them, the alternative corner areas include the upper left corner, lower left corner, upper right corner and lower right corner of the new chip rectangular frame. If the horizontal coordinate of the chip center point is greater than the horizontal coordinate of the pin name center point and the vertical coordinate of the chip center point is greater than the vertical coordinate of the pin name center point, then the chip pin belongs to the upper left corner area; if the horizontal coordinate of the chip center point is greater than the horizontal coordinate of the pin name center point and the vertical coordinate of the chip center point is less than the vertical coordinate of the pin name center point, then the chip pin belongs to the lower left corner area; if the horizontal coordinate of the chip center point is less than the horizontal coordinate of the pin name center point and the vertical coordinate of the chip center point is greater than the vertical coordinate of the pin name center point, then the chip pin belongs to the upper right corner area; if the horizontal coordinate of the chip center point is less than the horizontal coordinate of the pin name center point and the vertical coordinate of the chip center point is less than the vertical coordinate of the pin name center point, then the chip pin belongs to the lower right corner area;
[0050] The range of the corner area is a rectangular area formed from point M to point N, where point M is the farthest point on the circumscribed rectangle of the chip pin name to the chip endpoint in the corresponding corner area, and point N is the endpoint coordinate of the new chip rectangular frame corresponding to the corner area;
[0051] S9, obtaining a rectangular area image formed by the point M in S8 and the corresponding circuit schematic image endpoints;
[0052] The known point M is the coordinate (x1, y1) of the farthest point from the chip endpoint in the corresponding corner area on the chip pin circumscribed rectangle, the schematic diagram endpoint coordinate (x2, y2) corresponding to the corner area, and the content C in the picture with the horizontal coordinate range between x1 and x2 and the vertical coordinate range between y1 and y2 is the result to be obtained in step S9, where: the upper left corner area corresponds to the upper left endpoint of the schematic diagram, the lower left corner area corresponds to the lower left endpoint of the schematic diagram, the upper right corner area corresponds to the upper right endpoint of the schematic diagram, and the lower right corner area corresponds to the lower right endpoint of the schematic diagram.
[0053] S10, traverse each pixel point in the content C obtained in step S9, if the pixel value corresponding to the pixel point is not equal to the background color pixel value in S6, record the coordinates of the pixel point and summarize it into set P. Obtain the horizontal and vertical lines formed by all the pixel points in set P (where the horizontal and vertical lines are lines obtained by neatly arranging a number of pixel points in set P), and determine whether there is an intersection with the new chip rectangular frame. If there is an intersection, then take the longest line among these horizontal and vertical lines, and the rectangular frame edge is the edge to which the chip pin belongs;
[0054] S11, repeat steps S7 to S10 until all chip pins in set B have acquired their edges;
[0055] S12. Create a file with the .asy suffix, and write the coordinates of the upper left corner and the lower right corner of the chip rectangle, the chip name, the pin coordinates, the pin name, the side to which the pin belongs, the pin offset distance, the pin number and other information into the file in a specific format, wherein the pin offset distance is a self-set hyperparameter (wherein the hyperparameter is also a manually set value), and the pin number is to number the pins 1, 2, 3... according to the number of pins;
[0056] S13. Store the .asy file in S12 in the lib\sym\AutoGenerated folder under the LTSPICE simulation platform installation path, and then call the chip to build a simulation circuit.
[0057] The present invention designs a series of algorithm flows based on a circuit schematic image and the chip (rectangular) area information therein: chip size and coordinates, chip name and its size and coordinates, chip pin name and its size and coordinates, to intelligently generate custom chip symbols without manual effort, with high speed and accuracy.
[0058] A system for using an intelligent method for generating custom chip symbols in an LTspice circuit simulation platform, comprising:
[0059] An information acquisition module is used to obtain the coordinates of the center point of the chip, the coordinates of the upper left corner and the lower right corner of the rectangular frame of the chip, the coordinates of the center point of each pin of the chip, and the coordinates of the upper left corner and the lower right corner of the rectangular frame of each pin of the chip;
[0060] A judgment module, used for dividing the chip pins into a set A and a set B to judge the edge of the chip pins;
[0061] The construction module is used to build a file with the .asy suffix, and write the coordinates of the upper left and lower right corners of the chip rectangular box, chip name, pin coordinates, pin name, pin side, pin offset distance, pin number and other information into the file in a specific format, and store it in the lib\sym\AutoGenerated folder under the installation path of the LTSPICE simulation platform. The chip is called to build a simulation circuit.
[0062] It should be noted that, in this article, the terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus.
[0063] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for intelligently generating custom chip symbols in the LTspice circuit simulation platform, characterized in that: The following steps are involved: S1. Obtain the center point coordinates and the corner coordinates of the rectangular frame of the original chip, the center point coordinates of each chip pin and the corner coordinates of its circumscribed rectangular frame from the circuit schematic image, and calculate the distance values between the circumscribed rectangular frame of each chip pin and the corresponding sides of the original chip rectangular frame based on the above coordinate information; S2, take the two smallest distance values in S1, and obtain their maximum ratio, and then compare the maximum ratio with a preset multiple threshold; S3. For chip pins whose maximum ratio is greater than the multiple threshold, take the minimum distance value in S1, and the edge of the original chip rectangular frame corresponding to the minimum distance value is the edge to which the chip pin belongs; S4. For chip pins whose maximum ratio is less than the multiple threshold, first obtain the pixel value of the background color of the circuit schematic image, expand the original chip rectangular frame, obtain the corner coordinates of the new chip rectangular frame, and determine the corner area to which the chip pin belongs based on the center point coordinates of the new chip and the center point coordinates of each chip pin, and take the corner coordinates of the new chip rectangular frame and the corner coordinates of the chip pin external rectangular frame in the corner area to form a rectangular area; S5, taking the rectangular area formed by the corner coordinates of the chip pin external rectangular box and the corresponding end points of the circuit schematic image in the corresponding corner area, obtaining the coordinates of all pixel points in the area that are not equal to the pixel value of the background color, obtaining all horizontal and vertical lines formed by these pixel points, and selecting the longest line that intersects with the new chip rectangular box, and determining which side of the line and the new chip rectangular box has an intersection, and this side is the side to which the chip pin belongs; S6. Create a file, write the chip rectangle and chip pin related information into the file, and save and install the file.
2. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The corner coordinates of the rectangular frame of the original chip include upper left corner coordinate information and lower right corner coordinate information, and the corner coordinates of the rectangular frame of the chip pin include upper left corner coordinate information and lower right corner coordinate information.
3. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The distance values between the external rectangular frame of each chip pin and the corresponding sides of the original chip rectangular frame are recorded as dtop, dleft, dright and dbottom, respectively, where the minimum value of the above four distance values is recorded as dmin, the second smallest value in the distance is recorded as dsecmin, and the maximum ratio is recorded as times, times = dsecmin / dmin.
4. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 3, characterized in that: The multiple threshold is recorded as thre, and the parameter is set to 2.
2. If the chip pin times is greater than thre, then the chip pin belongs to set A, otherwise it belongs to set B, until all chip pins are divided into set A or set B.
5. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 4, characterized in that: In the S3, the edge to which each chip pin in the set A belongs is determined. If dmin=dtop, then the chip pin belongs to the top edge of the chip. If dmin=dleft, then the chip pin belongs to the left edge of the chip. If dmin=dright, then the chip pin belongs to the right edge of the chip. If dmin=dbottom, then the chip pin belongs to the bottom edge of the chip.
6. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The original chip rectangular frame is expanded outwardly until it intersects with the chip pin external wires.
7. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The corner areas in S4 include four categories: upper left corner area, lower left corner area, upper right corner area and lower right corner area. The range of the corner area is a rectangular area formed from point M to point N, where point M is the farthest end point coordinate from the chip pin external rectangular frame to the new chip rectangular frame in the corresponding corner area, and point N is the end point coordinate of the new chip rectangular frame corresponding to the corner area; And all the pixels in the rectangular area formed by the corner coordinates of the new chip rectangular frame and the corner coordinates of the chip pin external rectangular frame in the corresponding corner area are set to black.
8. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The coordinates of all pixels with different background color pixel values are obtained by traversing the content of the rectangular area formed by the corner coordinates of the chip pin external rectangular box and the corresponding endpoints of the circuit schematic image, and all the different pixel coordinates are summarized into a set P, and the horizontal and vertical lines formed by all the pixels in the set P are obtained, and it is determined whether there is an intersection with the new chip rectangular box. If there is an intersection, then the longest line among these horizontal and vertical lines is taken, and the rectangular box edge is the edge to which the chip pin belongs.
9. The method for intelligently generating custom chip symbols in the LTspice circuit simulation platform according to claim 1, characterized in that: The file in S6 is specifically a file with the suffix .asy. The chip rectangular frame related information includes the coordinates of the upper left corner and the lower right corner and the chip name. The chip pin related information includes the pin coordinates, the pin name, the side to which the pin belongs, the pin offset distance and the pin number information.
10. A machine-readable storage medium having a program stored thereon, wherein when the program is executed by a processor, the above method is implemented.
