Mostek Corp., a suburban semiconductor firm, has filed a suit to b lock the purchase of 21 percent of its stock by Gould Inc., a suburban Chicago based electrical products firm.

The suit, filed in the U.S. District Court of the Southern District of New york, charged that the stock purchase proposed by Gould would violate federal antitrust laws.

Gould has said it plans to buy from Sprague Electric Co., a subsidiary of GK Technologies of Greenwich, Conn., 1.2 million shares of Mostek for $51.5 million, or $42 per share. Under a 1971 shareholders agreement with Sprague, Mostek has 60 days to buy the stock or find another buyer on the same terms that Gould offered.

On Thursday, Gould said the stock purchase could lead to an attempt to acquire Mostek, but today a company spokesman refused comment on the suit.

In a prepared statement, Mostek said its board of directors on Thursday had determined that the purchase by Gould of the shares held by Sprague "would not be in the best interest of Mostek shareholders and that the company would . . . promptly explore the desirability of exercising the repurchase rights" under the 1971 agreement.

In the statement, Mostek said Gould ownership of the shares would have a significantly adverse effect on the company's business, hampering future growth.

L. J. Sevin, chief executive officer of Mostek, declined to speak with reporters but in a prepared statement said the company is a direct competitor of Gould in the production of programmable controllers for industrial process equipment. Sevin also said Gould competes with Mostek in the manufacture and sale of semiconductor products.

Gould's purchase of Mostek stock could result in a refund to Mostek under a U.S. Securities and Exchange Commission rule governing profits from insider trading.

Sprague bought 235,000 shares of Mostek's stock from the company last June, at $22 per share. Under the SEC rule, which governs capital gains on stock sales by insiders within six months of purchase, Sprague will apparently have to repay some money to Mostek. A Sprague official said his company would still make a capital gain of about $16 million on the transaction.