The HTM Spatial Pooler: a neocortical algorithm for online sparse distributed coding

You may want to look through this thread and see if it helps with understanding the SP operation.