Logical (boolean) functions (OR, AND, XOR etc.) can be modeled using macro models. Here, each input gets the transfer characteristic and its derivative described as follows:
The resulting voltages for each input are combined to create the wanted function for a device with inputs:
The above-mentioned functions model devices with 0V as logical low-level and 1V as logical high-level. Of course, they can be easily transformed into higher voltage levels by multiplying the desired high-level voltage to the output voltage and dividing the input voltages by the desired high-level voltage. Note: The derivatives also get divided by the desired high-level voltage, but they are not multiplied by the desired high-level voltage.
To perform a simulation on these devices, the first derivatives are also needed:
A problem of these macro models are the numbers of input ports. The output voltage levels worsen with increasing number of ports. The practical limit lies around eight input ports.
With that knowledge it is now easy to create the MNA matrix. The first port is the output port of the device. So, for a 2-input port device, it is:
The above MNA matrix entries are also used during the non-linear DC and transient analysis with the 0 in the right hand side vector replaced by an equivalent voltage
With the given small-signal matrix representation, building the S-parameters is easy.
These matrices can easily extended to any number of input ports.