Semiconductors have crushed the market so far this year, but one Wall Street firm believes the sector has topped out.

Morgan Stanley lowered its ratings on several chip stocks, citing lower flash memory prices and meager earnings growth next year.

"We think now is the time to reduce exposure to NAND [flash memory] and Asian semiconductor names as the industry has benefitted from sizeable demand tailwinds and unprecedented pricing power, which we see reversing soon," analyst Shawn Kim wrote in a note to clients Sunday entitled "Time For a Pause." "Given our view of the cycle, we cannot recommend the sector until the market recognizes mounting pressure on NAND prices and slowing logic chip growth momentum in the near term. … This reflects our negative view of prospects for the global memory industry, which is currently at a peak."

As a result, the firm lowered its ratings for Western Digital, Samsung Electronics and Taiwan Semiconductor shares to equal weight from overweight.

Western Digital, Taiwan Semiconductor ADR and iShares PHLX Semiconductor ETF closed down 6.7 percent, 4.5 percent and 1.3 percent respectively.

Kim said the firm's analysis of previous memory cycles revealed investors should sell chip stocks three to six months before memory prices peak. He noted that flash memory prices are already falling and his quantitative model predicts DRAM memory prices will top out in mid-2018.

"We would reduce weightings in the memory sector across regions and verticals as getting the industry call right is a lot more important than picking stocks in the memory and logic sector, as these stocks move in a pack," he wrote. "We believe a further positive re-rating of memory shares over the next 12 months will be difficult to achieve considering our view that the industry will not grow earnings materially in 2018."

The iShares PHLX Semiconductor ETF is up 48 percent year to date through Friday compared with the S&P 500's 16 percent return.

If chip stocks do fall, the analyst said, he would recommend shares of Micron as he's more bullish on DRAM's supply-demand fundamentals compared with the flash memory business. The firm maintained its overweight rating for Micron shares.

Western Digital, Samsung Electronics and TSMC did not immediately respond to requests for comment.

— CNBC's Michael Bloom contributed to this story.