Just like the rest of the stock market, the chips are down. I'm talking about semiconductors, of course, not Pringles or poker.

While it's not unexpected that semiconductors have been hit recently, it is surprising that chip stocks are only down as much as they are. Usually, semiconductors are extremely cyclical, with soaring highs and crashing lows. Yet semiconductor stocks have actually held up slightly better than the overall market for the past month, even amid the scary coronavirus sell-off.

SPY 1 Month Total Returns (Daily) Chart

SPY 1 Month Total Returns (Daily) data by YCharts

Why are semiconductors doing relatively OK in this crashing market? Well, chip stocks were actually already in a recession in early 2019, when the trade war and oversupply decimated demand. Semiconductors were actually primed for an upswing in 2020, just before coronavirus threw a wrench into the machine.

When the coronavirus scare passes, the semiconductor sector could very well resume the strong upcycle it appeared to be having. While a deep recession would cause chips to fall even more, a mere temporary delay in orders by a quarter or two wouldn't be so bad.

In that light, which of these two semiconductor stocks -- Western Digital (WDC 0.03%) or Taiwan Semiconductor Manufacturing (TSM 3.26%) -- makes for the better buy at this opportunistic moment?

An engineer working in a laboratory wearing a special uniform and protective gloves holds new processor in hands and examines it.

Western Digital and Taiwan Semiconductors are both semiconductor leaders. Image source: Getty Images.

Memory chips versus logic

Each company makes two distinct types of chips. Western Digital is a producer of hard disk drives (HDDs) and NAND flash chips, which encompass basically all of the main storage technologies used today. The prices of storage components can fluctuate wildly -- especially NAND flash -- leading to huge ups and downs in Western Digital's results. Still, the industry is fairly consolidated; Western Digital is one of only three companies that make HDDs and one of only six large companies that produce NAND flash.

Meanwhile, Taiwan Semiconductor is the largest and most advanced outsourced foundry. It manufactures logic chips, encompassing both central and graphics processing units, for many of the top chip companies today. Importantly, Taiwan Semi doesn't produce its own chips. It's just a manufacturer for others. Therefore, its results are tied to volumes of chips produced, leading to less exciting but steadier results than other chip companies. In addition, by producing a wide array of chips, Taiwan Semi has been able to turn that wide knowledge into a competitive advantage, becoming the manufacturing leader and passing Intel (INTC 4.08%) in the race to produce a 7nm chip last year.

Weathering the storm

In 2019, Western Digital had to deal with a crash in NAND flash prices. The crash was caused by the trade war slowdown, as well as the industry's move from 2D to 3D NAND chips, in which flash companies began stacking storage modules vertically for the first time. Though the process is difficult to execute, going from a one-layer to two-layer NAND increases bits by 100%, so there was a huge flood of supply in 2019 just as demand was softening.

That led to a huge loss for Western Digital last year, though some of that loss came from restructuring charges as it closed down an extra plant. Still, adjusted results yielded basically no profits last year.

WDC Revenue (TTM) Chart

WDC Revenue (TTM) data by YCharts

Yet despite the chip slump, Taiwan Semi was not only able to weather the storm, but actually grow revenue in 2019. That's because the build-out of 5G and demand for high-performance computing led to a surge in demand for advanced logic chips in the second half of last year. Taiwan Semi doesn't produce storage or memory chips, and the demand for leading-edge 7nm logic was a boon to its results. The company even raised its dividend handsomely.

Speaking of dividends

Taiwan Semi has a set policy to pay out about 70% of its free cash flow out to shareholders as dividends. Confidently, the company just recently switched from a one-time annual dividend to a quarterly dividend, indicating management's belief in steady, rising cash flows. The stock's dividend yield is currently about 3%.

Meanwhile, Western Digital also pays out a dividend, though in light of the memory and storage downturn, the company hasn't raised it for quite some time. Currently, Western Digital's dividend yield is 3.4%, by virtue of its rapid recent sell-off. So you'll be getting a slightly higher dividend with Western Digital, but you'll also be taking on more risk.

Western Digital is also cheaper

While Western Digital's official GAAP (generally accepted accounting principles) earnings were negative last year, things are expected to bounce back in a big way in 2020, as demand returns and NAND flash producers pull back on production growth. Western Digital's forward P/E ratio, based on this year's earnings estimates, is just 8.1. That compares with Taiwan Semi's forward P/E ratio of 19.7.

So, while there is more risk in Western Digital's stock, there's also much more upside. In fact, Western Digital's stock still sits about 50% below its all-time high set all the way back in 2015. Meanwhile, Taiwan Semi is less than 10% below its all-time high set just recently.

WDC Chart

WDC data by YCharts

Aggressive upside versus Steady Eddie

The choice between Taiwan Semiconductor and Western Digital depends on if you're looking for big upside with more risk, or relatively steady results. Western Digital is also in the middle of a CEO transition, recently hiring ex-Cisco (CSCO 1.51%) executive David Goeckeleras to replace outgoing CEO Steve Milligan. That puts a bit more risk on the table as well.

I still own Taiwan Semiconductor, but I sold off my Western Digital position for now, as I've been seeking to limit risk in my portfolio (I still own plenty of semiconductor stocks). However, I'd also be looking to add Western Digital once again when the coronavirus panic passes. It's quite cheap, and the long-term demand for memory and storage is still one of the more robust growth drivers in the technology industry.

Aggressive investors going bargain-hunting therefore may want to keep Western Digital on their radar for bigger upside once the current sell-off is exhausted. Memory markets can be volatile on the way down and the way up.

However, for those looking to limit risk and sleep better at night, and for whom a steady and growing 3% dividend is just fine, Taiwan Semi is definitely the safer pick.