Um. I'm a EE. A few times in my career, I've designed and had built silicon devices, typically as a member of a team. So, regarding all this FAB stuff, I wish to clear the air a bit.
The FAB guys own large buildings, bunny suits, and weirder and more complicated machines that cost more $$$$ than one can shake a stick at, and play with nifto chemicals like Hydrogen Flouride, which will etch its way through glass, silicon, and given half a chance your arm, with predictable results regarding the last.
These people are Not the chip design people. Not normally. The chip designers run around in VHDL, Verilog, and work with the foundry types. Compiled VHDL and Verilog result in netlists involving gates, D-flip flops, dedicated phase locked loops, and what-all, that are constructed from individual transistors. The foundry types take the netlists, convert them to artwork, which is then used to make the actual die on wafers in the foundry.
The foundry/FAB people spend a lot of time characterizing their transistors, logic gates (made out of transistors, but may be custom, depending upon what one is doing), and dumping the data into libraries, which get shipped off to the chip designers.
If you want a garden variety microprocessor with a million gates or so and you'll only need a million or so of these microprocessors, it's not worth your time to build your own FAB. Find a FAB with some spare capacity, sign contracts, get libraries, do a bit of training, do your design, simulate like you stole the simulator, and run back and forth between the FAB guys and the designers, iterating on the layout/timing/I/O until it's done, stick a fork in it, complete the contract that build the first hundred parts. Test the heck out of those, then Let Loose the Gods of the Wafer Build.
If all this sounds Really Expensive: You're right. But a heck of a lot less expensive and time-consuming than building one's own FAB. The only people who do stuff like that are Intel, who're going to build, literally, 100's of millions of cutting-edge microprocessors, or TMC, who're going to have many, many customers for their foundry, and keep things up and going that way.
But that's not what Tesla did this last year. They didn't design any new chips. They redesigned circuit boards to use parts that were in good supply. Yes, software for the devices. Yes, re-layout of a multi-layer circuit board, but likely not the entire circuit board. There are job shops what will give you, upon delivery of the ODB files, brand spanking new ones within two weeks, and we're talking, like, 8 or ten layer circuit boards. That's good for models: But building production boards, well, the limiting factors aren't typically how fast the circuit board can be built on a new design, it's all the bed-of-nails testing, functional test, and all that that take time. But, unlike how long it takes a women to have a baby (9 months, in case you didn't know), things in this line of work can go faster if, and only if, one throws experienced designers at the problem. Which is, apparently, what Tesla did. Ha. Vertical integration for the Win!
Going for a FAB: That's nuts. Unless Tesla is prepping for hundreds of millions of parts to keep the production line going. Maybe not quite that many, but in that range.