It's extremely common to need to know if one device can be directly replaced with another.
With Standard Logic devices, this is generally an easy process.
The part number, for example SN74LVC1G32DCKR, consists of a prefix (SN74), a family (LVC), a function (1G32), a package designator (DCK), and sometimes additional information (R - means the part ships on a reel).
For most logic devices, the function number also indicates a specific pinout. For example, all '00' function devices are quad 2-input NAND gates that have this pinout:
With the above information out of the way, here's the steps to determine if a device is pin to pin compatible:
(1) Open the datasheets of both devices
(2) Verify that both devices are available in the desired package. For TI devices, this information is available in the "Package Option Addendum" that typically looks like this:
(2a) If you are not certain if the packages are an exact match, you may need to look further in the datasheet into the package drawings to determine if the packages have similar dimensions. The important factors to note here are the pin pitch and width, highlighted here:
(3) Verify the pinouts match. For logic gates, the input designators typically do not make a difference - for example, one manufacturer may label the inputs to an AND gate as A1 B1, while another may label them as 1A 2A. As long as the inputs are on the same pins for the same gate, the naming convention doesn't affect pin to pin compatibility.
(4) At this point we know that the devices will physically fit on the same pads and the functions of the pins all match. All that's left is the electrical capabilities of the device. This is where it's good to have a full understanding of your application. Many logic devices can be used across a wide voltage range, however not all devices work at all voltages, and even when they do, they may have timing or output impedance differences that would affect the final application. We recommend comparing only the specs critical to your application -- no two devices will have _exactly_ the same specs for all electrical and timing specifications... otherwise they would have the same part number!
The most critical specs for most applications are:
Recommended Supply Voltage
Output voltage and current (VOH @ IOH, VOL @ IOL)
(5) If everything matches, the two parts can be considered "pin to pin compatible" and can be swapped directly.