Chipmaker giant Intel has agreed to buy Altera for $54 a share, or about $16.7 billion, in an all-cash transaction.