Make Room For A New Arduino Competitor – With Native Brainf*ck!

With so many smaller and more capable microcontroller boards on the market it’s now fairly safe to say that the classic Arduino footprint and form factor is rather outdated. That’s not to say that there’s no fight left in the old contender though, and to prove it here’s a new platform in the familiar style set by the venerable Atmel-based board. [Eduardo Corpeño]’s Brainfuino is an Arduino competitor that runs everyone’s favourite esoteric programming language, Brainf*ck. (Keeping it SFW, folks.)

And in case you mistake it for a Brainf*ck emulator on a PCB then stand ready to be corrected, for this board runs the language natively in a Brainf*ck softcore on a Lattice MachXO2 FPGA. This is the real deal, on which only a true genius or masochist would dare to code.

The board itself is very neatly executed with a graphical style that presents more than a nod to the original Arduino. On this board is the FPGA, 256 kB ROM and 138 kB RAM, an STM32 to provide a USB serial port and an analogue input, and a level shifter to provide Arduino-style 5 V logic on the pins. We can see it’ll provide hours of fun to anyone interested in learning Brainf*ck, but besides that it has potential as an Arduino-shaped FPGA board. We like the joke, we like the graphical and engineering design, but underneath that lies quite the technical achievement.

Brainf*ck has made it to Hackaday before, not least in this jaw-dropping relay computer.

70 thoughts on “Make Room For A New Arduino Competitor – With Native Brainf*ck!

      1. Oh, but it is! The STM32 is arguably overkill, at best. I’m using tons of interrupts and about 75% of its GPIO.
        And the STM32 is NOT connected to the FPGA through a serial interface. It’s acting as brainfuck_uP’s outside world through its input and output parallel ports \m/

    1. We’re running computers which perform zillions of toggles per microsecond, consuming a hell lot of precious electrical power and being composed from valuable materials scratched out of rocks by poor people we never come to know. All for representation of a PCB image that shows another hightech system running an esoteric turing complete language. All this is solely performed to supply our self-impression of nerdiness as if it was a universal currency. Me might think so, but it is _not_ better than watching cat videos.

      Which is pretty cool.
      Fetch the powerpoint kitten animations.

      1. Your sense of humor may get masked by the main comment. Who did you get to transcribe your smoke-signals into HTML? Yes, our civilization is extractive and very hard on the Earth but how much do you want to un-do? The wheel?

        1. Hi, I agree with Rumpel. About un-do – not so much but that consuming-oriented economics… I believe humans could use computing power more effectively – it is not so necessary all that 8-core CPUs for smartphones and PCs. Software is not ideal yet =)
          It is good to have progressed with technology, but putting it to anything and “upgrading” much before it works out its margin of safety not looks good at consuming resources point. The same with other branches… I mean cars for example =) Maybe it is not exactly what I wanted to say, but I hope it is able to be understood.

          P.S. still using Core i5 3rd gen and feeling good =)

    2. My eyes went right to the LATTICE chip, which sparked the memories of early year/s 2000’s past, the glorious JKEYS by Dave2 and JTAG’n Sat and FTA receiver’s first thru a PC parallel port then stepping My game up etching 2 sided copper clad boards for My first LATTICE chip driven Serial Port race car style JTAG’n monster that took full flashing anything with an eJTAG/JTAG PINOUT from hours of computer resource hogging time to in most cases just minutes and more than likely seconds read and write/erase operations, I had found, downloaded and converted the schematic to a CAD/CAM file and printed to an overhead transparency inkjet NEGATIVE IMAGE and hot air soldered the SMD components using pennies/dimes for heatsinks and was up and running just weeks before Dave2 posted his Serial Port JTAG’n device for sale/use with His software JKEYS, I regret never having purchased/tried His device which from what I understand was essentially the one I built as I was under the assumption that design or similar was actually from Him as I found it in a section where He had posted things for example how He had used a 100,000.00 yes A 100 thousand dollar LOGIC ANALYZER for the better part of 10 hours straight to dump all of the Sat receiver’s flash memory to get what was needed to make JKEYS software and JTAG’n one happen to begin with, so I immediately searched this board for the pinouts/pads named with the tell tale TMS/TCK/ETC LABELS, I can’t wait to buy some of these BrainDuino boards, YEAY!!!!

    3. Well, the STM32 is doing some other stuff: It’s overriding the intput/output for the user to interact through the serial port in the host computer through a Virtual COM port (lots of interrupts for this), it’s providing the ADC for the analog input, and it’s programming the brainfuck_uP’s parallel flash memory, which is a very specific procedure. I needed tons of I/O for this (an 18-bit wide address bus and an 8-bit data bus). Overall, I ended up using about 65 out of the total 87 GPIO pins in the STM32 chip.

  1. But here’s the thing about architectures like BF; I’ve actually seen this done: once you spend a weekend creating macros that do simple things, then you can use those macros as if THEY were the instruction set. What might be interesting to see, is whether there is a speed or cost advantage inherent in the architecture that offsets the waste that comes from doing everything in macros, that may be dupicating a lot of work. But the fact that there is an easy out, where you don’t even have to deal with the language itself, removes the masochism element that would have made it impressive. It’s kind of like building a Pentium out of individual MOSFETs, but then using a pick and place machine to do all the repetitive work.

    1. Assembly started as a shorthand for CPU opcodes. Higher-level languages began as a way to replace set of assembly instructions with single instruction so a programmer won’t have to copy and paste the same code over and over again to perform routine tasks, like accessing hardware or performing operations on data. Sometimes when I compile XC8 programs I look at assembly code generated by the compiler, and it is just bunch of macros with different variable names and some optimization for IF-THEN-ELSIF or SWITCH-CASE blocks.

      I would also suggest looking up microcode. The idea behind it is that hardware-level execution of a given instruction is controlled by programmable structure, like EEPROM, so instruction set can be improved, extended or completely replaced in some cases. Historically first computers were programmed by switches and patch cables the way modular synths work…

      1. AMD and Cyrix used to make a lot of noise about their 6th gen CPUs being RISC core with CISC implemented in microcode. I guess that’s “how it be” with all x86 family since the late 90s though. One thing is though that PII through PIII seemed to have a lot microcode loaded at runtime from BIOS, I don’t know if that was patches or the whole kaboodle. Would be interesting to know the “real” RISC CPU under all that and then maybe write your own microcode that’s tuned for implementing Forth or BF, or Lisp or python or however you want to talk to the machine at higher level.

      2. Phil Koopman in his book Stack Computers describes a computer with a writable instruction set(WISC) and in this particular implementation, had Forth primitives as microcode. There’s nothing stopping someone from using that concept today with FPGA’s. Whereas the WISC Computer was implemented in TTL chips.

        BTW IMS there is a video controller chip that uses Forth primitives as well.

    2. I’ve had this feeling too, not with BF but with other languages. (Looking at you Forth!)

      The lower-level the language is, the more you’re encouraged to code up your own project-specific metalanguage, which then ends up making the job of coding up the real problem a lot easier. When you get it right. And you find out pretty quickly when you’ve got it wrong…

      I’ve taken a lot of this insight into my Python programming, but somehow it feels wrong/harder. It’s not just writing shorter functions, but there’s something more. The Python never just abstracts away. C on microcontrollers kinda falls in the middle — I can do it sometimes, but it still feels “C-y”.

      Should you build your own machine / language for every project? Probably not. Lots of wheel reinventing. But it’s revelatory to have gone through the whole experience a few times.

      1. Then it gets to a point where you wonder if the Arduino Language really bears any resemblance to C or is in fact composed of all the function names you call from all the libraries.

        1. The same could be said about Python. The love people have for Python seems to be more about the wealth of libraries available, making it possible to get real things done without actually knowing the language.

    1. LOL! It’s still in the prototype phase, so I’m not pushing the frequency so far up. It’s running decently at 8MHz. If one brainf*ck instruction is regarded as one f*ck, then the average CPI of 4 yields about 2 million f*cks per second, sir.

  2. I never fully understood the American attitude towards certain words. From an outside perspective, it doesn’t seem to match other cultural aspects. Is it “not safe for work” to see a particular word on your computer monitor? What could be the consequences? (serious question!)

    1. Many workplaces have offensive/obscene content filters — we don’t want to get blocked by them.

      (Or get our readers in trouble b/c they’re reading Hackaday while at work!)

      But also: languages have arbitrary hierarchies of which words are offensive and which not. Some of these are like little landmines for the non-native speaker / cultural outsider. For instance, there are many equivalent ways to say that someone is being “dumb” in German — but then there’s another that will get your lights punched out. Pick wisely!

        1. I realize you are probably talking about some corporate variation of their software but I just want to add that Sophos home is absolutely f*cking obnoxious.

          Web based interfaces for on machine AV software is a trend that needs to die in a horrible fire and all those involved need to be sacked. Also blocking installscript based installers for widely published software is just f*cking dumb.

    2. Are there no words in your culture that you would not want your employer seeing on your screen? Maybe when potential clients are being shown around? That you would not want your young children seeing Daddy reading? That you would not want in big letters on your screen in a coffee shop (in normal times)?

      1. @BT to be honest, if my children learn “an asterisk disguises a bad word”, they will look for * everywhere and shout “daddy reads mean stuff”. Same if customers see F*ck or F*ck (haha, replace one * with u) doesn’t make a f*cking difference IMO. Read stuff with or without bad words. But I don’t understand disguising them with *.
        Same goes for bleeping stuff out on TV. You see people tearing down democracy on TV, being hurt and tear gassed, but thank god the kids don’t hear foul language.

        1. I question the maturity of people who need to use look at me language to name their programming language variant. If you want to grow the user base, why the need to offend some with the name?

          1. You must not be familiar with Brainf*ck. It’s a member of a class of programming languages known as “esoteric languages”. Sometimes called “Turing tarpits”. Yes, the language is Turing complete, hence you could technically write any program in it that you could write in a more mainstream, reasonable language. But it would be a masochistic effort. Brainf*ck isn’t meant for actual use. It’s an extremely minimal, intentionally difficult and obfuscated language meant only for funsies.

          2. I have to question the maturity of people who can’t see past a word or how loudly it is said, to the underlying intent. which seldom is to offend but rather because it succinctly expresses feelings like frustration, anger. So focusing on the word rather than why or what is being said perpetuates the reason for using it in the fist place.

          3. So, this is a line of code…

            ++++++++[>++++[>++>+++>+++>+<<<+>+>->>+[<]>.>—.+++++++..+++.>>.<-.>+.>++.

            Now do you get it, it IS a Brainf*ck, totally appropriate name.

      2. Coffee shop has different meanings in different parts of the world. From what you are arguing, coffee shop is one of those sequences of letters that you would find difficult to explain to you employer why they appears on you monitor.

          1. Well in the Netherlands, if you like your starbucks, you should make sure to get directed to a CoffeeHouse. Otherwise you end up in a less salubrious part of town smelling the wacky backy.

            In other parts of the world, coffee shops have had a long tradition of open debate, therefore in some either political or religious authoritarian regimes they carry the connotation of sedition or blasphemy.

            Then also I have heard there are parts of the world where coffee shop may also have the same connotations as bath house in the Western world, due to originally collecting intellectuals and intelligentsia who had more libertarian views, thus becoming a haven for those with non conformist sexual preferences.

          1. Here in Germany we’re still confused by the hundret ways to spell “coffee to go”. We never had “coffee shops”, but there are “back shops” where “back” is a short form of the german verb for “to bake”.
            What do you expect from a world where “handy” as a noun meaning “cellphone” / “mobile phone”. Amazon is pronounced “uhmah-tsohn”. Fortunately “brainfuck” is still “brainfuck”.

            Now say “Luftaufsichtsbaracke”. We rule ze world, don’t we?

    3. Americans regard puritans as their cultural forebears, that seems to have a continuing impact on their outlook on the world. Curiously there are now words in American that were originally bowdlerised forms of other swear words that now mean (to Americans) the rude thing more than the original, for example ass (meaning donkey) in place of arse. I wonder how long until f*ck will be regarded as the more rude alternative.
      Reminds me of this little (NSFW) aside by Tim Minchin – https://www.youtube.com/watch?v=9nVBZieBmXI

      1. There’s the cutesy doggo pages pretending words like heck and darn are swears, but there’s a real life hyper-religious crowd who are actually frigging serious about it. I accidentally strayed onto one of their forums and let go a heck, and caught an earful from the moderator.

        There’s a really annoying package for I think vBulletin, or maybe another common forum software, or both, that’s a filter for the George Carlin seven, but then also filters every last instance of cock and ass, yes, in the middle of other words. You can’t say assistant or cockpit. Then some double down on that folly by not only blanking them, but if you try to make a couple of posts in a row with blanked words, even though nobody else is seeing them, it’s an auto 24 hour ban.

          1. Haha, indeed. Stupid substitutions are something I’ve tripped over too, one place, trying to discuss a CD-ROM drive went like..
            “It’s a matsupoopa”
            “A what?”
            “matsupoopa”
            “..”
            “what the hell, matsusheeta matsush*ta matsush!ta”

            Then I got a warning for trying to get round the swear filter :-/

    4. It really depends on the workplace. Some places you could be looking at lewd pictures and no one would say anything, other places you can’t even browse outside of the company’s intranet. In my experience, most professional settings don’t mind occasional cussing, but if you make it a habit, you may be asked to consider your words more carefully. In english, there are always many different words and many different phrases to communicate the same thing. If someone is always choosing the most harsh, well, then the other kind of lose their meaning. I work with a gentleman who is always describing things as “the worst fu*king thing” and “this will never fu*king work” etc etc. So, no one likes working with him, because you can never determine the actual severity of the issue or defect.

      1. You absolutely nailed it. Language can contribute to a toxic workplace. We had an amazingly bright EE, who routinely cussed in situations that never demanded it (conference calls with clients and random banter whenever you worked with him). It got old and like you said, no one wanted to work with him. Professionalism counts on some level and lack of it can hurt the bottom line. Just ask WeWork.

      2. Don’t remember the name of the series, but it was (obviously) on a cable network around ten years ago, that was a police procedural. In one episode, all of the dialogue was either “f*ck” or variations on the word, or expressions containing the word, such as “f*ck me”. The episode was 100% coherent, that is, no other words would need to be added to fully understand what was going on.

        1. That was The Wire but being on HBO they did it because they actually could and it was a one episode thing, plus they were solving a murderer in the projects so not like they were barging into shareholder meetings like that

          1. What does “barging into shareholder meetings” have to do with this discussion? I’m just pointing to a case where use of obscenities adds value to the discourse.

          1. While liberally sprinkled with f-bombs as punctuation, and being practically every third word out of Ricky’s mouth, I don’t think they had quite such a f*ck dense episode as described. I’ve watched all the episodes through a couple of times.

            My guess would be it would be something Reno 911 might do, but haven’t watched enough of it.

        2. RW: My mistake – I thought it was the whole episode because someone showed it to me, and that was all they showed me. It was indeed the “The Wire” episode you named.

      1. Whose purpose? Hardware folks design CPUs (and their architectures) to make things easier in hardware (although they DO take suggestions from software folk), and software folks use whatever tools they have to make it easier for themselves. So regardless of the reason someone might want to make a BF-architecture CPU or MC, it’s the programmer’s prerogative to find the best way to use that CPU or MC.

        If the purpose is for programmers to show off, then they could write programs in BF source, and run it through a compiler or interpreter to run on a PC.

        Again, the real question is, would there be a performance or cost advantage to having a BF-architecture CPU.

        1. Sure, brainf*ck is inferior to most assembly languages for so many reasons. One of them being the inability to load immediate values. For example, if you want to load 37 to a memory slot in brainf*ck, you have to go [-]>[-]+++++++[-]<++ while in some assembly language it's just LDA #37 or something similar.
          That said, here's a nice paper on brainfuck High Performance Computing: https://people.csail.mit.edu/wjun/papers/sigtbd16.pdf

  3. “classic Arduino footprint and form factor is rather outdated”

    You mean this horrible spacing which prevent you to connect a standard 2.54mm pin spacing protoboard on top of an Arduino?:

    https://forum.arduino.cc/index.php?topic=163580.0

    “it was an admitted error in their rush to market for their first boards. After that they were (and still are) reluctant to change it because it would make all existing shields incompatible then and now. So not a design choice, just an error not caught in time.”

    Bad designs not made by consensus should go to hell!

    1. Parrt of the issue is the alleged “original” Arduino project was just highjacked from a grad student by the guys advisor. They forked it and cut him out of the whole thing. I think his original “wiring boards”” are a more sensible layout, and had used ATMEGA64 or 128 he had planned to use smaller micros later It esplains some of the issues the “original” arduino cre has had, since they are all piratesd in teh first place, and ended up stabbing each other in the back , as well as the creater of “wiring” the actual ORIGINAL arduino, and “processing” . His name is Hernando Barragán. Look up his “the untold history of arduino” it is enlightning and probably better explains why the knockoff of his project was a poor design. There is no “original” arduino, the origiinal is “wiriing” and “processing”

      1. Wow that actually makes a lot of sense with how similar processing and wiring are to the editor, but crazy how they did that to him makes me feel a bit better about all the aliexpress clones I buy, not that I could’ve afforded the original uno anyway

  4. I hope this could be re-programmed, to use other languages etc. because this board actually has a very important – but unfortunately rare – feature.

    It has ” a level shifter to provide Arduino-style 5 V logic on the pins”.

    The two major FPGA dev board producers I know of are: Digilent, and Terasic. Both have products with Arduino header pins (Arty series for Digilent, DE10-Nano for Terasic) but, on the schematics I have found, level shifting seems curiously absent.

    The presence of a 5V signal on a line expecting a lower voltage won’t causes flashes and sparks unless you are in a Hollywood movie. It will, however, kill your FPGA board – and they aren’t THAT cheap.

    So forget about the soft core, and say bravo for bothering to provide protection on the IO pins.

    1. Thanks Alan! Yeah, the 5V logic is, like pretty much every other feature of the Brainfuino, just part of the elaborate joke this is, with the punchline that it works.
      Now, about running other languages, well, as long as you stick to the harvard architecture (a 256kB program ROM, and a 128kB RAM), you may replace the brainfuck_uP for the soft processor of your choice, provided that it fits in the modest MachXO2 FPGA :)

Leave a Reply to zoobabCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.