Keira Knightley is in talks to co-star with Benedict Cumberbatch in biopic “The Imitation Game.”

Pic is being helmed by “Headhunters” director Morten Tyldum with Teddy Schwarzman’s Black Bear Pictures financing.

Script topped the 2011 Black List and is based on the life story of mathematician Alan Turing, the genius responsible for cracking the German “Enigma Code” during World War II that helped the Allies stave off defeat, and who would later be prosecuted by Britain in the early 1950s for being a homosexual.

Schwarzman will produce with Nora Grossman and Ido Ostrowsky of Ampersand Pictures. The pic is still looking for a distributor, but given the cast, it shouldn’t be long before a distrib comes on board.

The details behind the Knightley’s role are vague, but the project looks to be of a similar caliber as her previous pics “Atonement,” “Pride and Prejudice” and “A Dangerous Method.”

She can be seen next in Paramount’s “Jack Ryan.” She is repped by CAA, United Agents and the Schiff Company.