
<PAGE>   1
                                    EXHIBIT 5

                               OPINION RE LEGALITY


                                        9
<PAGE>   2
[GRAY CARY WARE FREIDENRICH LOGO]




ATTORNEYS AT LAW                                                       EXHIBIT 5
4365 EXECUTIVE DRIVE, SUITE 1600
SAN DIEGO, CA 92121-2189
TEL (619) 677-1400
FAX (619) 677-1477
                                                                    OUR FILE NO.
                                                                     08203-92001

                                November 15, 1996



Cohu, Inc.
5755 Kearny Villa Drive
San Diego, CA  92123

      RE:         REGISTRATION STATEMENT ON FORM S-8 REGISTERING SHARES ISSUABLE
                  UNDER THE 1996 STOCK OPTION PLAN

Ladies and Gentlemen:

            We are rendering this opinion in connection with the registration
under the Securities Act of 1933, as amended, of 450,000 shares of the Common
Stock, $1.00 par value, of Cohu, Inc., a Delaware Corporation (the "Company")
which may be issued pursuant to the exercise of options granted under the Cohu,
Inc. 1996 Stock Option Plan (the "Plan").

            We have examined all instruments, documents and records which we
deemed relevant and necessary for the basis of our opinion hereinafter
expressed. In such examination, we have assumed the genuineness of all
signatures and the authenticity of all documents submitted to us as originals
and the conformity to the originals of all documents submitted to us as copies.

            We are admitted to practice only in the State of California and we
express no opinion concerning any law other than the law of the State of
California, the corporation laws of the State of Delaware and the federal law of
the United States.

            As to matters of Delaware corporation law, we have based our opinion
solely upon our examination of such laws and the rules and regulations of the
authorities administering such laws, all as reported in standard, unofficial
compilations. We have not obtained opinions of counsel licensed to practice in
jurisdictions other than the State of California.

            Based on such examination, we are of the opinion that the 450,000
shares of Common Stock which may be issued upon exercise of options granted
under the Plan

                SAN DIEGO - LA JOLLA - SAN JOSE - IMPERIAL VALLEY
                              MEXICO CITY - TIJUANA


                                       10
<PAGE>   3
Securities and Exchange Commission
Page 2


are duly authorized shares of the Company's Common Stock, and, when issued
against receipt of the consideration therefor in accordance with the provisions
of the Plan, will be validly issued, fully paid and non-assessable.

            We hereby consent to the filing of this opinion as an exhibit to the
Registration Statement referred to above and the use of our name wherever it
appears in said Registration Statement.

                                       Respectfully submitted,


                                       /s/ Gray Cary Ware & Freidenrich

                                       GRAY CARY WARE & FREIDENRICH
                                       A Professional Corporation

                SAN DIEGO - LA JOLLA - SAN JOSE - IMPERIAL VALLEY
                              MEXICO CITY - TIJUANA


                                       11
