One of the most exciting sectors in the market today -- for good and bad -- is semiconductors. These play an increasingly important role in the world, as new technologies like artificial intelligence, machine learning, the Internet of Things, self-driving vehicles, and especially 5G take hold in the market. Yet at the same time, the ongoing U.S.-China trade war has sapped business confidence, leading to extreme caution on the part of chip buyers worldwide. A downturn in demand can wreak havoc on semiconductors, which have oversupplied the market over the past year, leading to many negative-earnings surprises.

This has set up an interesting dynamic where big secular trends are running headlong into a cyclical downturn. Yet starting in the second half of 2019, it appears that one secular trend -- the buildout of 5G networks -- is beginning to overwhelm these macroeconomic fears, sending certain semiconductor-related companies soaring.

Rendering of a city with an arrow pointing to the sky emerging from skyscrapers and 5G written on it.

5G is benefiting semi-cap equipment stocks, despite the trade war. Image source: Getty Images.

Semiconductor equipment stocks are hitting highs

One would think the global slowdown would absolutely kill the stocks of semiconductor equipment manufacturers, who make the machines needed to produce leading-edge chips. However, the opposite has been true, with many such companies hitting 52-week and/or all-time highs in recent weeks.

These include ASML Holding (ASML -0.80%), KLA-Tencor (KLAC -0.63%), Applied Materials, and Lam Research (LRCX -0.71%). In addition, Taiwan Semiconductor Manufacturing (TSM -0.87%), the world's largest foundry and buyer of this equipment, is also up nicely. As you can see, all of these stocks are crushing the market over the past year -- and that's in spite of the sharp December sell-off and ongoing trade war.

TSM 1 Year Total Returns (Daily) Chart

TSM 1-Year Total Returns (Daily) data by YCharts.

Interestingly, as U.S. and China relations continue to get more acrimonious, it seems both countries are stepping on the gas to become the leader in 5G technology. In particular, Taiwan Semi's management, which just had its third-quarter earnings release and conference call, gave some amazing numbers regarding the 5G buildout.

Boosting capital expenditures by 40%

In its earnings release, Taiwan Semiconductor revealed that it would again be boosting its capital expenditures for the year by a whopping 40%. Remember, the company is the world's largest outsourced semiconductor foundry and makes chips for most of the leading fabless semiconductor designers. Though Taiwan Semi had initially anticipated spending $10 billion to $11 billion on capex this year, management is now boosting that figure to $14 billion to $15 billion, with a similar forecast for 2020.

Why such an increase? Taiwan Semi is seeing huge demand for leading-edge chips, which are the high-performance chips that will go into 5G handsets and base stations, well beyond what it had initially anticipated. According to management, about $1.5 billion of the capex increase is for the company's 7-nanometer chips that are just hitting the market, and the other $2.5 billion is to get an early jump on 5-nanometer chips for next year. In semiconductors, the nanometer distance signifies the distance between transistors; the smaller the space, the more transistors can be packed into a chip, making the chip more powerful.

Management said, "Since the middle of this year, we've been seeing an acceleration in the worldwide 5G development. This will speed up the introduction and deployment of 5G network in smartphone in several major markets around the world."

The company now expects 5G penetration to ramp even faster than 4G, with 5G phones reaching a mid-teens smartphone market share next year, up from Taiwan Semi's previous expectations of just mid-single-digit penetration in 2020.

Smaller chips need bigger equipment

Increased 5G demand is thus causing increased demand for smaller chips, yet smaller chips are becoming harder to produce. The smaller the chip, the more manufacturing process steps it must go through, which is why all of these semi-cap equipment makers are seeing such strong demand. In particular, ASML Holding's EUV technology is crucial for the ability to produce 7-nanometer and lower chips. That's why ASML's stock has gone up so much in the past year, and why it trades at a higher multiple than its peers.

TSM PE Ratio (TTM) Chart

TSM P/E Ratio (TTM) data by YCharts.

Another favorite is KLA-Tencor, which has a competitive advantage in process diagnostic and control equipment, which tests wafers and masks for imperfections. This diagnostic tool becomes increasingly important as die sizes shrink, because of the exactness required to produce high-density chips at scale.

Though semi-cap equipment stocks have all had good runs over the past year, these big technological trends don't appear to be slowing down anytime soon. While a global recession may delay the growth of these companies, macroeconomic conditions probably won't hold them back forever. Therefore, investors should look to snap up these winning tech leaders on any big pullbacks. And if trade tensions ever ease up, so much the better.