{"body":"         void LUT::MergeWith(LUT* other, int pin) {\n             //Note the inputs from the 'other' LUT are put at the start of this one\n             vector<bool> newContent;\n             for(int i = 0; i < lutContent.size(); i++) {\n                //only processing things when the value of the replaced pin is zero prevents the newContent array being duplicated\n                if((i & (1 << pin)) == 0) {\n                    for(int j = 0; j < other->lutContent.size(); j++) {\n                        //evaluate all input combinations in the other LUT\n                        if(other->lutContent[j]) {\n                            //output of other LUT is high, thus pick from row in this LUT equivalent to i but where pin is high\n                            newContent.push_back(lutContent[i | (1 << pin)]);\n                        } else {\n                            //output of other LUT is low, thus pick from row i where pin is low\n                            newContent.push_back(lutContent[i]);\n                        }\n                    }\n                }\n             }\n             inputPorts[pin]->Disconnect();\n             inputPorts.erase(inputPorts.begin() + pin);\n             //add inputs of 'other' LUT to this one at the start but in the correct order\n             for(int i = other->inputPorts.size() - 1; i >= 0; i--) {\n                 DeviceInputPort *port = new DeviceInputPort();\n                 port->pin = i;\n                 port->device = this;\n                 port->connectedNet = other->inputPorts[i]->connectedNet;\n                 other->inputPorts[i]->connectedNet->connectedPorts.push_back(port);\n                 inputPorts.insert(inputPorts.begin(), port);\n             }\n             lutContent = newContent;\n         }\n","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/wryKPtAn","modified":1543948707,"id":"wryKPtAn","size":1768,"lines":31,"own_paste":false,"theme":"","date":1543948707}