Method, processor, and program storage medium for solving the bit padding problem in the creation of a virtual controller

By checking for bit padding and adjusting byte sizes in source code, the method addresses memory issues in virtual controllers, ensuring stable and compatible operation across environments.

DE102024137458A1Pending Publication Date: 2025-06-18HYUNDAI AUTOEVER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
DE102024137458
Authority / Receiving Office
DE · DE
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-13
Filing Date
2024-12-12
Publication Date
2025-06-18

AI Technical Summary

Technical Problem

Bit padding during the creation of virtual controllers can lead to improper functioning, especially in different environments, due to variable alignment and memory optimization issues in source code compilation.

Method used

A method to check for bit padding in source code structures, split bit-filled variables, and adjust the maximum number of bytes to prevent memory gaps, ensuring proper virtual controller operation across environments.

Benefits of technology

Ensures the creation of functional virtual controllers by eliminating memory gaps and preventing abnormal operations caused by bit padding, providing stable and compatible solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000009_0000
    Figure 00000009_0000
  • Figure 00000009_0001
    Figure 00000009_0001
  • Figure 00000010_0000
    Figure 00000010_0000
Patent Text Reader

Abstract

A method, a processor, and a program storage medium for solving a bit padding problem in the creation of a virtual controller are provided. In particular, a technique is provided that enables a virtual controller to function properly in any environment. The technique may involve resizing a structure in source code and partitioning a variable to prevent abnormal operation of the virtual controller that may be caused by bit padding.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNOLOGY AREAThe present disclosure relates to a method, a processor, and a storage medium for solving a bit padding problem in creating a virtual controller.BACKGROUNDSource code is the plain text code used in writing a computer program. Typically, source code, i.e., a series of instructions written in a programming language, is a form of code that can be understood and written by humans. Source code includes grammars and rules for communication to give instructions to a computer.A variable is a storage space having a name used for storing and managing data used in a program. A variable can be used to store, reference, or manipulate data. A variable may store various types of data, e.g., numbers, text, and objects. The value of the variable may vary with the size of the stored data.A structure refers to a concept used in combining a number of variables to define a single new type of data in programming languages. By means of a structure, variables of different data types can be grouped and managed as a unit.A bit field refers to a structure having bits as members.The variables contained in a structure are stored in succession in the memory and can have a specific value depending on the data type of the individual variables and the basic alignment strategy of a compiler. However, there are cases where the values of the variables are changed or the orientation of variables are adjusted to adjust the size of the structure and optimize memory usage.In cases where there is some space left when storing data in memory, additional bits may be inserted into the memory to fill the remaining space, which may be referred to as bit padding.Virtual control refers to a control system implemented in software in a computer system or a simulation environment, rather than in actual hardware. Such virtual control may replace or mimic physical hardware to control a particular task or process and be used in simulations or the like.Such a virtual controller may be created by a process of creating source code. However, when creating source code, the occurrence of bit padding may depend on which build tool is used, so the virtual controller may not function properly.SUMMARYAn aspect of the present disclosure is to provide a technique capable of creating a virtual controller that functions properly in each environment.Another aspect of the present disclosure is to provide a technique capable of preventing bit padding caused by variables in a structure.Another aspect of the present disclosure is to provide a technique applicable to a controller area network database (CAN DB).According to an embodiment of the present disclosure, a method is provided. The method includes checking whether bit padding occurs when source code is compiled that includes a structure having one or more variables. The method also includes, when the occurrence of bit padding (bit padding) is verified, dividing a bit padded variable into the source code.The division of the bit-filled variables may also include the division of the bit-filled variables such that there is no empty space in memory.Split bit-filled variables may be packed into one variable.The method may further include compiling and associating source code that has undergone the partitioning and creating a virtual control.The virtual controller may be a virtual model of an electronic controller unit (ECU).According to an embodiment of the present disclosure, another method is provided. The method includes checking whether bit padding occurs when source code is compiled that includes a structure having one or more variables. The method also includes, when the occurrence of bit padding is verified, changing a maximum number of bytes in the structure. The method further includes checking whether bit padding occurs in the source code by changing the maximum number of bytes in the structure. The method additionally includes, when an occurrence of bit padding is verified, dividing a bit padded variable into the source code by changing the maximum number of bytes in a structure declaration.The division of the bit-filled variables may also include the division of the bit-filled variables so that there is no empty space in memory.The method may further include compiling and associating source code that has undergone the partitioning and creating a virtual control.The virtual controller may be a virtual model of an electronic controller unit (ECU).The change in the maximum number of bytes may also include an increase in the maximum number of bytes.Split bit-filled variables may be packed into one variable.According to still another embodiment of the present disclosure, there is provided a computer-readable storage medium storing a program. The program, when executed by a processor, causes the processor to: check whether bit padding occurs when source code is compiled including a structure including one or more variables; when an occurrence of bit padding is verified, change a maximum number of bytes in the structure; check whether bit padding occurs in the source code in which the maximum number of bytes in the structure is changed; and when an occurrence of bit padding is verified, divide a bit padded variable in the source code in which the maximum number of bytes in a structure declaration is changed.The program, when executed by a processor, may cause the processor to split the bit-filled variable so that no empty space arises in memory.The program, when executed by a processor, may also cause the processor to compile and associate the source code subject to the partitioning and create a virtual controller.The virtual controller may be a virtual model of an electronic controller unit (ECU).The program, when executed by a processor, may cause the processor to change the maximum number of bytes by increasing the maximum number of bytes.Split bit-filled variables may be packed into one variable.According to another embodiment of the present disclosure, a processor is provided. The processor includes a checking part configured to check whether bit padding occurs in compiling source code including a structure having one or more variables. The processor also includes a processing portion configured to perform one or more of the following methods: changing the maximum number of bytes in the structure, or dividing a bit-filled variable among the one or more variables when bit padding occurs.The processor portion may be configured to split the bit-filled variable so that there is no empty space in memory.The processor may be configured to change the maximum number of bytes by increasing the maximum number of bytes.According to another embodiment of the present disclosure, another method is provided. The method includes checking whether bit padding occurs when source code is compiled that includes one or more bit field declarations, and the method also includes, when an occurrence of bit padding is verified, dividing bits where bit padding occurs in the bit field.The division of the bits may include a division of the bits where bit padding occurs so that no empty space is created in the memory.Divided bits where bit padding occurs may be packed into a variable.The method may further include compiling and associating the shared source code and creating a virtual control.The virtual controller may be a virtual model of an electronic controller unit (ECU).As described above, according to embodiments of the present disclosure, it is possible to create a virtual controller that functions properly in each environment.According to embodiments of the present disclosure, it is also possible to prevent abnormal operation of a virtual controller that may be caused by bit padding.Moreover, according to embodiments of the present disclosure, it is possible to solve problems caused by bit padding in a highly stable and compatible manner.BRIEF DESCRIPTION OF THE DRAWINGSFIG. 1 is a view for explaining a method of creating a virtual controller according to an embodiment of the present disclosure. FIG. 2 is a view for explaining a construction process according to an embodiment of the present disclosure. FIG. 3 is a view for explaining a method for solving a bit padding problem according to a first embodiment of the present disclosure. FIG. 4 is a view for explaining a method for solving a bit padding problem according to a second embodiment of the present disclosure. FIGS. 5-7 are diagrams of examples for explaining bit padding according to embodiments of the present disclosure. FIG. 8 is a diagram illustrating implementation of a method for solving a bit padding problem according to a second embodiment of the present disclosure. FIG. 9 is a view for explaining a processor performing a method for solving a bit padding problem according to an embodiment of the present disclosure.DETAILED DESCRIPTIONHereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. With respect to the reference numerals of the components in the respective drawings, it should be noted that the same reference numerals are assigned to the same components, even though the components are illustrated in different drawings. Moreover, in describing the present disclosure, detailed descriptions of known configurations or functions have been omitted so as not to obscure the spirit of the present disclosure.Moreover, terms such as "first", "second", "A", "B", "(a)", "(b)", or the like can be used to describe the constituent elements of the present disclosure. These terms are intended only to distinguish a corresponding constituent element from other constituent elements, and the kind, order, or sequence of the corresponding constituent element is not limited to the terms. In a case where a component is described as being "coupled", "combined", or "connected" to another component, it is understood that the corresponding component may be directly coupled or connected to another component, or the corresponding component may also be "coupled", "combined", or "connected" to the component via another intermediate component.Moreover, terms such as "module", "part", "device", etc. in the present specification may refer to hardware or a functional or structural combination of software controlled by corresponding hardware or used for controlling hardware. The hardware may be, for example, a computing device having a central processing unit (CPU) or other processor. Moreover, software controlled by hardware may refer to a running process, an object, an executable, an execution thread, a program, etc.When a component, device, module, element, or the like of the present disclosure is described as following a purpose or executing an operation, function, or the like, the component, device, or element should be considered herein as being "configured" to accomplish that purpose or execute that operation or function.FIG. 1 is a view for explaining a method of creating a virtual controller according to an embodiment of the present disclosure.Referring to FIG. 1, a virtual controller may be created using written source code.Specifically, the source code may be written in a variety of programming languages. The source code may include various variables and various structures with various variables.In addition, the source code may include a bit field having one or more bits.In addition, the source code may include grammars and rules for issuing instructions to a computer.Such source code can be created by a build tool. Here, the term "build" may refer to a process in which the source code is converted into software, libraries, etc., that may be executed by a computer. The term build tool may refer to software used to compile or generate source code.The source code may be created and converted into a virtual control file. Here, the virtual controller may be a virtual electronic controller unit (vECU) which is a virtual model of an electronic controller unit (ECU).DLL is an abbreviation for Dynamic Link Library, and a vECU may create a DLL file as a functional mock-up unit (FMU) file using a functional mock-up interface (FMI).Virtual control can be used, for example, in the development phase of automobile software. The virtual controller may form a hardware independent development environment. The virtual controller may be used in logic verification. The virtual controller may be used as a simulation tool.FIG. 2 is a view for explaining a construction process according to an embodiment of the present disclosure.Referring to FIG. 2, the written source code may be preprocessed by a preprocessor. In this case, the preprocessing may refer to a process in which the source code is additionally processed before being compiled by a compiler.In the pre-processing phase, macro extensions, header file insertion, conditional compilation, the use of pre-processor instructions, etc. may be performed.Pre-processed source code may be compiled by a compiler.Here, compilation may refer to the process of converting source code into assembler code or to the process of translating source code into a machine language that can be understood by a computer. Software that performs compilations may be referred to as a compiler.During compilation, for example, code optimization and conversion of the code into assembler code can be carried out.Alternatively, the compilation process may refer to a process of directly converting source code into a machine language, and an executable program may be created directly by this process.Assembly code, also called assembly language, is a language that is encoded to correspond to a machine language with strong association with the instruction functions, rather than a machine language that is difficult for users to understand.The assembler code written by the compilation process may be written by an assembler in a machine language.Machine code written in a machine language may be created as an object file, and the object file may be changed to an output file by a linker.Such build process may be applied differently depending on the environment in which it is performed. Bit padding, i.e., filling an empty location in memory with bits, may or may not occur depending on the environment in which the creation process is performed.The occurrence of bit padding may therefore depend on the environment in which the program is executed, and bit padding may result in abnormal operation of the virtual controller. To solve this problem, the source code may be changed in advance.FIG. 3 is a view for explaining a method for solving a bit padding problem according to a first embodiment.Referring to FIG. 3, the method for solving a bit padding problem according to the first embodiment may include a step or operation S 210 of preparing source code, a step or operation S 220 of checking whether bit padding occurs, and a step or operation S 230 of dividing a bit-filled variable.Step or operation S 210 of preparing the source code may include preparing source code written in a plurality of programming languages. In this case, the source code can contain data both about an actual control unit (ECU) and data about a virtual control unit (e.g. vECU).Step or operation S220 for checking whether bit padding occurs may include checking whether bit padding occurs when compiling source code. In the step or operation S220 for checking whether bit padding occurs, it is possible to check for bit padding by checking a structure included in the source code and variables included in the structure and checking the maximum number of bytes in a structure declaration. It can also be checked whether bit padding occurs by checking the maximum number of bits in the bit field.The step or operation S 230 of dividing a bit-filled variable may include dividing and declaring a variable that causes bit padding among the variables included in the source code.If a bit field is the target to be processed, step or operation S 230 may also include dividing and declaring bits that cause bit padding among the bits included in the bit field of the source code.Here, the division of a bit padding variable may refer to the division and declaration of a variable so that there is no empty space in memory. This will be described in more detail below with reference to Figures 5-8.In addition, the method for solving a bit padding problem according to the first embodiment may include a step or operation of compiling source code and constructing a virtual controller.Here, compiling the source code may include converting the source code into a machine language that may be understood by a computer, or formulating the source code into an assembly language. The virtual controller may also refer to a virtual model of an electronic controller unit (ECU).The method for solving a bit padding problem according to this embodiment can be applied to a controller area network database (CAN DB). As an example, the method for solving a bit padding problem according to this embodiment may also be applied to a generator that generates a CAN DB in C code.FIG. 4 is a view for explaining a method for solving a bit padding problem according to a second embodiment.Referring to FIG. 4, the method for solving a bit padding problem according to the second embodiment may include a step or operation S 310 for preparing the source code, a step or operation S 320 for checking whether bit padding occurs, a step or operation S 330 for changing the maximum number of bytes in a pattern, a step or operation S 340 for checking whether bit padding occurs, and a step or operation S 350 for dividing a bit-filled variable. The step or operation S 310 of preparing the source code may include preparing the source code written in a plurality of programming languages. In this case, the source code can contain data both about an actual control unit (ECU) and data about a virtual control unit (vECU).The step or operation S 320 of checking whether bit padding occurs may include checking for bit padding when compiling source code. In the step or operation S 320 of checking whether bit padding occurs, it may be checked whether bit padding occurs by checking a structure included in the source code and variables included in the structure and checking the maximum number of bytes in a structure declaration.It is also possible to check whether bit padding occurs by checking the maximum number of bytes in the bit field.The step or operation S330 for changing the maximum number of bytes in a structure may also be referred to as a step or operation for changing the size of a structure.The size of a structure may represent the overall size of the space occupied by a structure in memory. The larger the structure, the higher the values of the variables which are stored successively in the memory.The step or operation S 330 of changing the maximum number of bytes in a structure may include, for example, increasing the maximum number of bytes, which may mean increasing the structure. In this way, the bit padding problem can be solved.In addition, the size of a pattern can be reduced to prevent bit padding.For example, the size of a structure can be increased from 32 bits to 64 bits or reduced from 32 bits to 16 bits. In various embodiments, the size of a structure may be varied as needed as long as bit padding of bits can be avoided.Moreover, in processing a bit field, the step or operation of a declaration may be performed to change the maximum number of bits in the bit field in the source code.The step or operation S 340 of checking whether bit padding occurs may include re-checking whether bit padding occurs when the source code is compiled by changing the maximum number of bytes in a structure declaration.It is also possible to recheck whether bit padding occurs by checking the maximum number of bits in the bit field.Accordingly, the step or operation S 340 may include checking whether bit padding occurs despite a change in size of the structure.The step or operation S 350 of dividing a bit padding variable includes dividing and declaring a bit padding variable among the variables included in the source code.Sharing a bit-filled variable may include sharing and declaring a variable so that there is no empty space in memory. This will be described in more detail below with reference to Figures 5-8.If a bit field is the target to be processed, bits that cause bit padding among the bits included in the bit field in the source code may also be divided and declared.In addition, the method for solving a bit padding problem according to the second embodiment may include a step of compiling source code and constructing a virtual controller.Here, compiling may include converting the source code into a machine language that may be understood by a computer, or the step of printing out the source code into an assembly language. The virtual controller may also refer to a virtual model of an electronic controller unit (ECU).The method for solving a bit padding problem according to this embodiment can be applied to a controller area network database (CAN DB). As an example, the method for solving a bit padding problem according to this embodiment may also be applied to a generator that generates a CAN DB in C code.FIGS. 5 and 6 are diagrams of an example for explaining bit padding according to an embodiment.FIGS. 5 and 6 are diagrams of examples for explaining a case where a variable is divided to prevent bit padding that occurs in a structure having a size of 32 bits (4 bytes).Referring to FIGS. 5 and 6, one or more variables may be arranged in the structure in a particular order. For example, as illustrated in FIGS. 5 and 6, variable 1 may have a size of 16 bits, variable 2 may have a size of 8 bits, variable 3 may have a size of 14 bits, variable 4 may have a size of 12 bits, and variable 5 may have a size of 12 bits. In addition, the variables 1 to 5 may be arranged in the structure in a certain order.When the variables 1 and 2 are allocated, an 8-bit memory space remains in the memory, and since the variable 3 to be declared next is 14 bits in size, the 8-bit space can be filled up with bits and the variable 3 allocated to a new memory. Next, when the variable 4 is declared, a 4-bit memory space remains in memory. Since variable 5 is 12 bits in size, the 4-bit space can be filled in with bits and variable 5 allocated to a new memory.The variable 5 can thus be allocated to a new memory, which can be referred to as a padding byte.In this case, the program may not be able to function properly due to bit padding.Thus, the variable 3, which is a bit-padded variable, may be split-e.g., split and packed-to avoid a space so that the bit-padding does not occur. Accordingly, the program can function properly in any environment.Referring to FIG. 6, the variable 3, which is a bit-filled variable, may be divided into 8 bits and 6 bits and packaged, and accordingly, the bit padding in the compilation process may be omitted.If a bit field is a target to be processed, padding of bits can be prevented by dividing and packing the bits causing the padding.FIG. 7 is a diagram for explaining bit padding according to an embodiment. FIG. 8 is a diagram illustrating implementation of a method for solving a bit padding problem, according to an embodiment.Referring to Figure 7, a structure named test_s contains the variables a, b, c, e, f, g, h and i and is 4 bytes (32 bits) in size.Int and UInt represent the type of variable. Int may denote an integer and Uint may denote a non-negative integer, i.e. 0 and positive integers.Variable a has a size of 16 bits, variable b has a size of 8 bits, variable c has a size of 14 bits, variable e has a size of 14 bits, variable f has a size of 12 bits, variable g has a size of 16 bits, variable h has a size of 16 bits, and variable i has a size of 16 bits.When these variables are arranged in order in a 32-bit structure, bit padding is performed. In this way, the method shown in FIG. 8 can be carried out.First, bit padding can be prevented by changing the size of the structure. Although the variable c is a bit-filled variable in a 32-bit structure, the bit padding caused by the variable c can be avoided by changing the size of the structure to 64 bits.In this case, however, the variable f becomes a bit padding variable due to the changed size of the structure. In this case, bit padding can be prevented by dividing the variable f. As illustrated in FIG. 8, the variable f may be divided into the variable f_ 1 and the variable f_ 2 each having a size of 8 bits, and the two variables may be packed into one variable, thereby preventing bit padding.Bit padding can therefore be prevented by dividing and packing a variable filled with bits.FIG. 9 is a view for explaining a processor performing a method for solving a bit padding problem according to an embodiment of the present disclosure.Referring to FIG. 9, a processor 400 according to this embodiment may include a control part 410 and a processing part 420.The processor 400 may also be a central processing unit (CPU) capable of performing arithmetic, control, execution, and input / output operations. In other words, the processor may be a relevant device used for a program or software to execute instructions and process data.The checking part 410 may be a component that checks whether bit padding occurs. In an example, the checking part 410 may be a component that checks whether bit padding occurs in compiling source code including a structure having one or more variables.The processing part 420 may be a component that modifies the source code. For example, if the occurrence of bit padding is verified, the processing portion 420 may make one or more changes to the maximum number of bytes in the structure and divide a bit padded variable into the one or more variables.In this case, the partitioning may refer to partitioning the bit padding variables so that no void is created in the memory.The change in the maximum number of bytes may also include an increase or decrease in the maximum number of bytes.The processor 400 may, in this embodiment, take on the task of changing the source code such that no bit padding occurs during compilation of the source code.In addition, the processor 400 according to this embodiment may perform the step of compiling the source code and creating a virtual controller.Here, the compiling may refer to the step of converting the source code into a machine language that can be understood by a computer, or the step of representing the source code in an assembly language. The virtual controller may also refer to a virtual model of an ECU (Electronic Control Unit).The processor according to this embodiment can be applied to a controller area network database (CAN DB). As an example, the processor according to this embodiment may also be applied to a generator that generates a CAN DB in C code.Terms such as "include", "contain", "comprise" or "have" mean that the corresponding constituent may be present unless otherwise indicated, and therefore should be construed so that the terms do not exclude other constituents but may also include other constituents. All terms, including technical or scientific terms, have the same meaning as commonly understood by one of ordinary skill in the art to which the present disclosure pertains, unless otherwise defined. Generally used terms, such as terms defined in the dictionary, should be construed to conform to the contextual meaning of the subject art, and should not be interpreted in an ideal or excessively formal meaning unless expressly defined in the present disclosure.The above description is merely for illustrating the technical idea of the present disclosure, and persons having ordinary skill in the art to which the present disclosure pertains may make various modifications and changes within the scope that do not depart from the essential features of the present disclosure. Accordingly, the embodiments described in the present disclosure are not intended to limit the technical idea of the present disclosure but to explain, and the scope of the technical spirit of the present disclosure is not limited by these embodiments. The scope of the present disclosure should be interpreted by the following claims, and all technical spirits within the scope corresponding to the scope of the claims should be interpreted as being included in the scope of the claims of the present disclosure.

Claims

A method comprising: checking whether bit padding occurs during compilation of source code containing a structure having one or more variables; and if occurrence of bit padding is verified, partitioning a bit-filled variable into the source code.A method comprising: when bit padding occurs in compiling source code that includes a structure having one or more variables, changing a maximum number of bytes in the structure; and when bit padding occurs in the source code in which the maximum number of bytes in the structure has been changed, dividing a bit-filled variable in the source code in which the maximum number of bytes in the structure has been changed.A method comprising: checking whether bit padding occurs in compiling source code containing one or more bit field declarations; and if the occurrence of bit padding is verified, dividing the bits where bit padding occurs in the bit field.The method of claim 1 or claim 2, wherein sharing the padded variables includes sharing the padded variables such that there is no void in memory.The method of claim 1 or claim 2, wherein the split bit-filled variable is packed into a variable.The method of any of claims 1 to 3, further comprising compiling and associating the source code subject to partitioning and generating a virtual controller.The method of claim 6, wherein the virtual controller is a virtual model of an electronic control unit (ECU).A processor comprising: a checking part configured to check whether bit padding occurs in compiling source code including a structure having one or more variables; and a processing part configured to perform one or more of changing a maximum number of bytes in the structure or dividing a bit-filled variable among the one or more variables when occurrence of bit padding is verified by the checking part.The processor of claim 8, wherein the processing portion is configured to split the bit-filled variable such that there is no empty space in the memory.The processor of claim 8, wherein the processing part is configured to change the maximum number of bytes by increasing the maximum number of bytes.