[HN Gopher] From ASCII to ASIC: Porting donut.c to a tiny slice ...
       ___________________________________________________________________
        
       From ASCII to ASIC: Porting donut.c to a tiny slice of silicon
        
       Author : a1k0n
       Score  : 149 points
       Date   : 2025-01-12 17:36 UTC (1 days ago)
        
 (HTM) web link (www.a1k0n.net)
 (TXT) w3m dump (www.a1k0n.net)
        
       | binarymax wrote:
       | So great to see this excellent explanation. Have been a fan of
       | donut.c since it first came out. Also I'm way better at golfing
       | js than c so it kinda feels like you wrote this just for me :)
        
       | malux85 wrote:
       | The thing about donut.c is that its source code is shaped like a
       | donut, that's a huge part of its charm.
       | 
       | While altering it to use shifts and adds is a fun exercise, since
       | its source code is no longer shaped like the donut it renders, I
       | would argue that a large part of its charm has disappeared and
       | it's no longer a donut.c
        
         | Zamiel_Snawley wrote:
         | It's trivial to reformat the source code into a donut shape.
        
           | zamadatix wrote:
           | Sometimes it's those trivial changes which add a lot of the
           | overall charm.
        
           | refulgentis wrote:
           | Non-trivial, IMHO - automating it sounds non trivial, and
           | doing by hand is quite non-trivial, right? We gotta go make
           | hand edits line by line?
        
             | mianos wrote:
             | Considering the language, C and the size of the file, I
             | would not argue it is not trivial. The key feature of
             | donut.c is how small the file actually is.
             | 
             | For something larger or in other languages, or having text
             | strings, certainly not trivial.
        
             | omoikane wrote:
             | For a language like C, I would describe the formatting
             | process as "straightforward" as opposed to "trivial". It's
             | straightforward in that it feels very mechanical, but not
             | trivial in the sense that it's difficult to fully automate
             | the process. (The mechanical part is inserting spaces at
             | the right places, the not so mechanical part is swapping
             | tokens and rewriting expressions so that things line up).
             | 
             | You can see an example recording here of how it's done:
             | 
             | https://www.ioccc.org/2019/yang/obfuscation.html
             | 
             | First half of it is writing and golfing, second half is the
             | formatting bits.
             | 
             | For languages like Perl and Ruby, the formatting process is
             | easily automated and mostly trivial.
        
               | refulgentis wrote:
               | That visualizer is incredible, appreciate it and the
               | insight - and 4 hours! Wow.
        
           | qingcharles wrote:
           | We need someone to write pastry.c which takes any C file and
           | reorganizes the code into the shape of delicious bakery
           | products.
        
           | timewizard wrote:
           | mmmmm.. trivial donuts...
        
         | rcxdude wrote:
         | Indeed. I feel like to capture the spirit of it you could make
         | the layout on the chip look like a donut, which would be if
         | anything more of a challenge than the layout of the source
         | code.
        
       | swores wrote:
       | Going slightly off topic, I was interested to learn from this
       | blog about Tiny Tapeout, the service they've used to order their
       | custom chip design. The concept for anyone as unfamiliar with it
       | as me is that lots of people pay a few hundred dollars each to
       | get a small part of a chip being made, and once it's made they
       | receive the chip ready to use with their section everyone else's,
       | too, with a way to choose which bit gets run.
       | 
       | I know basically nothing about chip design, and I'm wondering if
       | anyone could tell me: is this only useful for education purposes,
       | for example learning how to make a chip that creates a donut on a
       | screen, or are there people using Tiny Tapeout for useful
       | projects, too?
       | 
       | For each of their chip runs, they publish a list of the different
       | people's projects that got included -
       | https://tinytapeout.com/runs/ - but it's not easy to spot which
       | ones might be more than somebody just learning how to play with
       | chip design.
       | 
       | Essentially, if someone were to pick this up as a hobby, what is
       | the most interesting thing they could make using this?
        
         | sircastor wrote:
         | I got a tile on TinyTapeout9 (I think) and participated in a
         | workshop for it at the Hackaday Supercon last November.
         | 
         | I had a lot of fun. I had a bit of knowledge from my university
         | digital logic class, but really enjoyed learning how the layers
         | are put down and how they make transistors. If you have an
         | opportunity to do it, I strongly recommend it.
         | 
         | There are some very cool things you can do, but you're limited
         | by the tile size, the inputs provided and it's worth noting
         | that you get _one_ chip on a module. It's probably the 2nd step
         | in getting started making a custom ASIC if you wanted to get
         | into that. (The first being learning how to design with logic
         | gates)
         | 
         | bitlui made a VGA Rickroll with it a while ago. [1]
         | 
         | My tile spells out "Aaron" (my first name) on the output to the
         | seven segment display.
         | 
         | I think there is enough room to make a simple microprocessor.
         | Fun if you've not ever done something like it.
         | 
         | So, to answer your question - yes it could be useful if you had
         | a very specific thing you wanted to do that made sense in
         | silicon. You could buy extra tiles and get space. That said,
         | it's mostly educational. But worth it if you have an interest.
         | 
         | [1] https://youtu.be/DdF_nzMW_i8
        
         | Taniwha wrote:
         | Almost anything you can do on Tiny Tapeout your can do on an
         | FPGA and test it today (not wait 6-9 months to get silicon
         | back) - if you are laying polygons yourself because you want to
         | test out some novel circuit that TT is potentially a great
         | idea.
         | 
         | On the other hand if you've learned logic design and want to
         | spread your wings and make some real chips then TT is an
         | educational experience - not only is the tooling different but
         | often you need to understand stuff in depth that FPGA tooling
         | kind of hides (because essentially FPGAs come pre routed) so
         | it's a great way to take a small step into silicon design.
         | 
         | There's probably a large bunch of people who will make just one
         | design because they can, just to say they did it.
         | 
         | I've taped out 4 CPUs on TT, I'm retired, I used to do chip
         | design, TT has the same sort of scope as the logic blocks I was
         | making 20 years ago - no one is going to be using it for
         | manufacturing (you get just 1 die back)
        
           | tmaly wrote:
           | I have not programmed an FPGA in 26 years.
           | 
           | What do you recommend for a FPGA brand today?
        
         | mystified5016 wrote:
         | Pretty much exclusively educational.
         | 
         | Iirc you pay a large amount for each chip, you only get a
         | couple, and I seem to remember some clause about giving the
         | chip back or something.
         | 
         | The project has some pretty draconian rules, but it seems to be
         | all done with good intent: to make it impossible for
         | corporations to abuse this for cheap ASICS while allowing
         | actual hobbyists to get a foot in the door.
         | 
         | TinyTapeout is NOT for making a custom run of ASICS for your
         | widget, it's the only plausible way for a hobbyist to spin up a
         | single chip design just to see how it's done.
        
       | refulgentis wrote:
       | I've been _deeply_ curious about the sort of speedup you get from
       | doing what was in software, on hardware:
       | 
       | I know the chips hasn't been delivered yet, but, the statements
       | at the beginning re: we can expect a new frame every N
       | nanoseconds, give me hope there's a rough heuristic for what
       | speedup we'd expect in this particular case.
       | 
       | Do we have a rough* understanding of what the speedup will be?
       | 
       | * Within 2 OOMs
        
         | megous wrote:
         | New pixel. Not new frame.
        
         | Someone wrote:
         | Speedup compared to what? You can't compare it to doing it in
         | software on the same machine. So, you need to pick a reference
         | CPU.
         | 
         | Finding a somewhat comparable CPU would be challenging. It
         | would need to run at around 48 MHz and have 16 bit integer
         | addition. I think the fastest Z80 clone would be a candidate
         | (https://en.wikipedia.org/wiki/Zilog_eZ80), but that's a
         | pipelined CPU. You may find that unfair.
         | 
         | If you don't pick something comparable but just something
         | cheap, given the 48MHz clock of this hardware and the limited
         | amount of parallelism, it wouldn't surprise me if the typical
         | modern smartphone could do it faster, even without the use of a
         | GPU.
        
       | still_waiting wrote:
       | When are you going to post part 3 of your Hacker Challenge?
       | 
       | It's been fifteen years and we're still waiting. Thanks.
        
         | a1k0n wrote:
         | lmao! that was so cringe I unlisted it from the main index. who
         | is "we"?
         | 
         | part 3 is to find the secp256k1 private key for satoshi's
         | bitcoins
        
       | amstan wrote:
       | Yay, a1k0n!
       | 
       | Long time since AI Challenge, I see you're dabbling into hardware
       | too!
        
         | glonq wrote:
         | I wonder what it's like to be _ridiculously talented at
         | everything_ ?
        
       | anthk wrote:
       | I suggest you all to compile the C examples with -O3 -ffast-math
       | on legacy systems.
        
       ___________________________________________________________________
       (page generated 2025-01-13 23:03 UTC)