This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Wiki encyclopedia > macro


  1. A slightly out-of-date term for a component made of nets and primitives, FFs, or latches that implement midlevel functions, such as add, increment and divide. Soft macros and relationally placed macros (RPMs) are types of macros.

  2. A universal control embedded into the RTL and visible from any point during compilation. Often defined in Verilog using `define command.



What is a macro

Excel office software automatically integrates the "VBA" high-level programming language, and the programs written in this language are called "macro". The use of "VBA" requires a certain programming foundation and consumes a lot of time. Therefore, most users only use the general tabulation function of Excel, and rarely use "VBA".

The interpreter or compiler automatically replaces this mode when it encounters a macro. For compiled languages, macro expansion occurs at compile time, and tools that perform macro expansion are often referred to as macro expanders. The term macro is also often used in many similar environments. They are derived from the concept of macro expansion, which includes keyboard macros and macro languages. In most cases, the use of the word "macro" implies the conversion of small commands or actions into a series of instructions.

The purpose of macros is to automate frequently used sequences or to obtain a more powerful abstraction capability-but this is often the same thing.

Computer languages such as C or assembly language have a simple macro system, which is implemented by the preprocessor of the compiler or assembler. The job of C's macro preprocessor is simply text search and replacement. Using additional text processing languages such as M4, C programmers can obtain more sophisticated macros.

Lisp-like languages such as Common Lisp and Scheme have a more elaborate macro system: macros behave like functions that deform their own program text, and all languages can be used to express this deformation. A C macro can define a grammatical substitution, but a Lisp macro can control the calculation of a section of code.

The ability to control the execution order of code (see lazy calculations and unrestricted functions) is obtained, making the newly created grammatical structure indistinguishable from the language's built-in grammatical structure. For example, a Lisp dialect with cond but no if can use macros to define the latter. The main extension of the Lisp syntax, such as the object-oriented CLOS system, can be defined by macros.

typical application

Speed up daily editing and formatting

Combine multiple commands

Make the options in the dialog box more accessible

Automate a series of complex tasks

Avoid nested calls of function libraries, for example: the A program and the B library are included in the main program, and the A library is included in the B library. Calling the same library multiple times will cause waste of resources. At this time, you can #define a macro in the A library, and use the #ifndef or #ifdef statement to check whether the macro has been defined every time you compile the A library, so as to avoid referencing the same library repeatedly.

Introduction to programming

When macro programming is performed in an unfamiliar macro language, this can be done by first recording what the user wants the macro to accomplish, then opening the macro file and trying to understand how the command structure works. You can also modify the command to adjust the macro. Some macro languages, such as the Great Plains Accounting (?accounting) software's Dexterity runtime engine, cannot import data from other data sources (such as comma-delimited text files). This limitation can be solved by using a more powerful programming language, such as VBA, to create a computer program to generate a special macro in this weak programming language. For example, you can macroprogram Microsoft Excel to read data from an extended style sheet or text file and create a Great Plains .mac file, which is used to import specific data into Great Plains. You need to claim for each new data set New .mac file.

Keyboard macro

Keyboard macros and editor macros are used interactively in graphical user interfaces and editors, respectively. Use them to replace lengthy command sequences with short keystrokes and provide a simple form of automation for repetitive tasks.

The programmer's text editor Emacs (short for "Editing MACroS") is the product of this idea. In fact, most editors are composed of macros, and Emacs was originally designed as a macro set of the editing language TECO, and was later ported to Emacs Lisp, a Chinese dialect of Lisp.

Macro language

A macro language is a type of programming language, and all or most of its calculations are performed by expanded macros. Macro language is not widely used in general programming, but it is widely used in text processing programs. E.g,

C preprocessor C preprocessor

Internet Macros(iOpus)

M4 (as mentioned above, derived from AT&T, bundled with Unix)

Macro definition

One of the preprocessing functions provided by the c program. Including macro definitions with parameters and macro definitions without parameters. Specifically, it refers to using a specified identifier to perform simple character string replacement or elaborate replacement. The form is:

#define marker (parameter table) string

Another method of macro definition is:

#define string

For example: c++ library yvals_core.h:


#define _NODISCARD

Macros of this type will replace these strings with "", which is the null character, when the compiled macro is expanded. The replacement has no practical effect.

Macro name

The identifier in the above definition is called "macro name".

Macro expansion

The process of replacing the macro name with a character string when the C program is compiled is called "macro expansion".


Visual Basic for Applications (VBA) is a programming language in Microsoft Office. But as defined above, it is not a macro language at all. However, its functions have evolved from it and eventually replaced the macro ideas of user applications, so he is widely mistakenly called a macro language.

VBA can access many operating system functions and supports macro execution automatically when the document is opened. This makes it possible to write computer viruses in this language. In the mid to late 1990s, macro viruses became one of the most popular types of computer viruses. Other projects that include macro languages, such as openoffice org, deliberately exclude some functions (such as: automatic execution) from their macro languages to avoid breaking the program. However, this feature is welcomed in many transactions.


  • XCS10XL-3VQ100I


    Spartan and Spartan-XL Families Field Programmable Gate Arrays

  • XC3S500E-5PQG208C


    FPGA Spartan-3E Family 500K Gates 10476 Cells 657MHz 90nm Technology 1.2V 208-Pin PQFP

  • XC2C32A-6VQ44C


    CPLD CoolRunner -II Family 750 Gates 32 Macro Cells 200MHz 0.18um, CMOS Technology 1.8V 44-Pin VQFP

  • XC2C384-10FG324I


    CPLD CoolRunner -II Family 9K Gates 384 Macro Cells 125MHz 0.18um Technology 1.8V 324-Pin FBGA

  • XC2C384-10FTG256C


    CPLD CoolRunner -II Family 9K Gates 384 Macro Cells 125MHz 0.18um Technology 1.8V 256-Pin FTBGA

FPGA Tutorial Lattice FPGA
Need Help?


If you have any questions about the product and related issues, Please contact us.