Shares of chipmakers Micron Technology (NASDAQ:MU) and Cypress Semiconductor (NASDAQ:CY) have had great runs during the last few years. The rise of the Internet of Things -- the addition of connectivity, sensors and interactivity to billions of formerly "dumb" objects -- has created significant new demand for the semiconductor companies' products. And given that the number of smart devices in use is forecast to increase by billions every year, shares of Micron and Cypress could continue to generate healthy returns for investors. However, these two companies present two different types of risks.

A side-by-side comparison

Metric

Micron Technology (NASDAQ:MU)

Cypress Semiconductor (NASDAQ:CY)

Market Cap

$62 billion

$5.9 billion

12-Month Revenue

$28 billion

$2.4 billion

Price/Earnings Ratio (TTM)

5.5

N/A

Price/Earnings Ratio (Forward)

4.7

11.9

Total Debt

$7.3 billion

$948 million

Chart by author. Data source: Yahoo! Finance.

A pure play on memory

After a sales slump sent the semiconductor industry reeling in 2015, demand for memory chips has been on a tear as their use in data centers, automobiles, consumer electronics, and other application has soared. Idaho-based Micron has been a big beneficiary. Sales have doubled from their lows in 2016, leading to a better than 1,000% rise in earnings per share, and 300% surge in share price.

MU Chart

MU data by YCharts

Micron isn't without its detractors, though. In spite of the company's work in developing new specialized memory technology -- a joint production with Intel making high-capacity and high-speed chips called 3D XPoint -- most of Micron's sales still fall in the category of commodity chips. That is reflected in its depressed P/E ratio of 5.5, and its forward P/E ratio of 4.7. Considering how quickly Micron has been growing, that valuation implies investors are factoring a lot of risk into the stock price.

Some of those fears were borne out in early July when a court in China restricted the sale some of Micron's products there. China has been trying to nurture its own semiconductor industry, and is mired in a trade dispute with the United States. Micron could be one of the fight's victims, although it's still unknown how the Chinese decision will ultimately affect the company's revenues.

With that said, Micron stock could be worth the risk -- even though its business is highly cyclical, and political spats could weigh on its profits. Management is putting the fantastic returns of the last two years to work, the company is reducing debt, and a $10 billion share repurchase program will start later this year.

An artist's depiction of data and internet connections. Data represented by graphs and charts is shown being shared all over the globe.

Image source: Getty Images.

Migrating to new industries

Cypress Semiconductor is also a leading maker of memory chips, but the company bought its way into new markets a couple of years ago with the purchase of Broadcom's Internet of Things division. It has quickly grown into Cypress' largest segment -- producing 60% of revenue in 2017 -- thanks to fresh chip demand from the auto industry and other industrial applications.

That isn't to say that the memory chip business hasn't been good for Cypress, too. To kick off 2018, its memory segment logged a 15% year-over-year revenue increase while its connected things division was up only 6%. That growth helped the company claw its way back to net profitability just recently, and management expects to continue to benefit through the rest of 2018 from higher profit margins, and the ability to cross-sell its memory and connectivity products. Those improving fundamentals have helped revenues gain 50% since 2016, and shares are up nearly 70%.

CY Chart

CY data by YCharts

In spite of the stock's rise, Cypress is still priced attractively, with a forward P/E of 11.9. Share price gains have stalled of late, after management called for a slowdown in sales in the second quarter; revenue is expected to grow by 2% to 6% year over year.

Over the long term, however, Cypress will likely continue to grow. Its business is well-diversified across memory and connectivity products, and its move to directly compete in the connected device industry is expected to drive high-single-digit percentage sales growth in that segment.

Which stock is better?

Micron still relies on sales of digital memory, which is for the most part a commoditized product. That makes its business sensitive to supply and demand trends, which can cause wild fluctuations in its share price. Cypress has had the same issue in the past, but it attempted to compensate for that with its entry into connection-enabling products for consumer and industrial electronics. The expected steady demand growth ahead for those products could help mitigate the pain from declining sales in its legacy memory segment.

Micron and Cypress' business models are on divergent paths. Both stocks are attractively priced, but I think shares of Cypress will require less babysitting in the years to come, thanks to its diversified product lineup.

Nicholas Rossolillo and his clients own shares of Cypress Semiconductor, Intel, and Micron Technology. The Motley Fool recommends Broadcom Ltd and Cypress Semiconductor. The Motley Fool has a disclosure policy.