14 ms·
Show HN: I made a discrete logic network card
- precompute 2y agoVery cool! How long did it take you? It's really impressive!
- ynoxinul 2y agoBuilding the network module took about a month, but writing the compiler took much more time.
- gigatexal 2y agoimpressive work! a lot of it went over my head but still i could appreciate it being a real feat
- magicalhippo 2y ago> writing the compiler took much more time Impressive stuff. I've dabbled wuth making my own ISA and softcore CPU in FPGA, but getting C code to compile has been a bit of a blocker. I know there are some compilers one could try to port but my ISA is kinda esoteric so not straight forward, and so I considered just writing from scratch like you have.
- ynoxinul 2y ago> I know there are some compilers one could try to port but my ISA is kinda esoteric so not straight forward Same. I tried digging into exsiting compilers, but they are either unsuitable at all or too complicated (clang).
- artirdx 2y agoVery impressive! Could you share some books, training, experiences that helped you reach this stage so a hobbyist could catch up? There are so many parts - compiler design, basic electronics, computer architecture etc. Maybe a blog post.
- ynoxinul 2y agoI have a CS/applied math background, my main job is software development, so I don't have problems with the software part. If you are interested in compiler design specifically, you can find a lot to read or to watch online. When building my system, I was inspired by 8 bit retro computers like ZX Spectrum. Their architecture is straightforward and easy to understand. Electronics just fascinates me, but I can't really point out a single source which gave me the insight. A lot of playing around with transistors, microcontrollers, logic gates gives the intution how to design stuff.
- hubraumhugo 2y agoSuper impresssive! I would absolutely love to work on such projects and admire the passion and countless hours that went into understanding and then building the system. Retirement is not something desirable for me, so maybe that's when I'll spend my time on hardware and software projects like this.
- MrGilbert 2y agoWhat's stopping you from starting today?
- frabert 2y agoLack of motivation to work on more technical stuff after having done the same all day at work? Mental exhaustion? Wanting to spend the remaining free time with loved ones instead?
- pbronez 2y agoI’ve found it empowering to say “this is fascinating to me, and I would enjoy spending significant time diving into it, but I choose not to prioritize that right now.” This works much better for me than simply griping that “I don’t have time to X”. It acknowledges that I COULD make time for X, but it isn’t worth the current cost.
- dspillett 2y agoAs I slowly dig myself out of a little burn-out rut, I am trying to develop this sort of reaction as a habit.
- shiroiushi 2y agoYeah, same here: after a day of staring at code on a screen, it's hard to get motivated to look at more code at home. I'd rather watch a movie with my family.
- deleted 2y ago[deleted]
- actionfromafar 2y agoSo, is it better or worse than the Etherlink 3c501 ? :-D https://mirror.math.princeton.edu/pub/oldlinux/Linux.old/net/tcpip/ne2000/3c501.c https://mirror.math.princeton.edu/pub/oldlinux/Linux.old/net... IIRC it over-wrote the buffer the CPU tried to read with new packets from the network or something like that. I had it for a while in Linux and the performance really was bad. :-D
- tech2 2y agoI remember the 3c590 (https://github.com/torvalds/linux/blob/20cb38a7af88dc40095da7c2c9094da3873fea23/drivers/net/ethernet/3com/3c59x.c#L1187 https://github.com/torvalds/linux/blob/20cb38a7af88dc40095da...) doing something awful too which required changing the PCI latency setting from 32 to 248 to avoid some catastrophic errors. It's amazing how much stuff is hidden from view by drivers and firmware updates.
- ynoxinul 2y agoI've found the description of the thing: https://www.os2museum.com/wp/emulating-etherlink/ https://www.os2museum.com/wp/emulating-etherlink/ Mine is better because it has two buffers :) But still, only one received frame is kept.
- jiveturkey 2y ago> Fixing the frame length doesn’t have any effect on higher-level protocols because they encode the packet size in their headers and do not rely on the actual Ethernet frame length. Interesting. I just wrote a packet decoder and I specifically verify at each layer that the lower layer length matches. So for IP, in my decoder the IP datagram length must match exactly the ethernet frame length + link layer header. I didn't do this to be pedantic but rather to detect short frames, and then I decided that long frames were also errors. You (author) are using uIP but I wonder what Linux or any other modern OS does. You don't specifically mention interoperability but I wonder if you've tested that.
- ynoxinul 2y agoI'm sending my long frames out to the network and no OS I have has any problem with that. I've read somewhere that long frames are actually used by some routers to store metadata after the packet.
- jiveturkey 2y agowireshark doesn’t complain either?
- ynoxinul 2y agoOf course not. Long frames are totally valid.
- darrin 2y agoTimestamps and other types of in-band network telemetry are sometimes inserted in the frame as a trailer (with a new FCS). If an application isn't looking for the L2 data, it's just ignored by the Linux IP stack.
- amelius 2y agoCool. Now waiting for a WiFi implementation :)
- nonrandomstring 2y agoBeautiful work to share. > I needed a hardware MAC address filtering. What I really love is the stack trace of reasoning, that's very pedagogical, and that you either worked out lots of things from first principles or felt the need to explain them is if from naive perspective. Also, while impractical for real world networking I don't think this is just idle play. What with backdoors turning up in over-complex network network chips you may find a more serious readership/project motive in the future.
- cchance 2y agoI do wonder how many exploits are hidden in modern day silicon, i mean we find exploits almost daily in code of a few thousand lines of code, meanwhile we've got microchips that are basically the equivalent of billions of lines of code in hardcoded silicon
- cushychicken 2y agoMan, that is really, really cool. I just went back and reread the 10BASE-T write up as well. That’s super cool you can even get 2.6kB out of it.
- RetroTechie 2y agoVery cool stuff! Only nitpick I'd have is that author decided to use a custom-design cpu. Ok, "discrete logic only!" is a valid choice. And then keeping complexity to a minimum weighs heavily. But the downsides of that choice are also considerable: -No interrupts (which are very useful) -No existing software base to tap from. Somewhat-useful C compiler helps.. somewhat. But who am I to question author's choices for a hobby project like this? Great stuff in any case.
- ynoxinul 2y agoI started with a CPU and then built everything else around it. Using something like a Z80 just doesn't seem fun for me.
- heinrichhartman 2y agoWhat does "discrete logic" mean in this case? Why would this prevent interrupts?
- RetroTechie 2y ago> What does "discrete logic" mean in this case? 74xx series ICs (eg. 74ACT family in case of the cpu, if I read correctly). More generally, it may refer to "basic logic elements whose function is easily inspected". > Why would this prevent interrupts? Not at all - in theory. In practice, interrupt support tends to complicate cpu designs. Complicate = more logic = more ICs. So builder decided against it & chose not to implement interrupts on the cpu.
- dboreham 2y agoJust to clarify: CPUs built with discrete logic can definitely have interrupts (e.g. PDP-11/45, VAX 11/780).
- jfbenson 2y agoThis is truly impressive, not just the work, but the way you have laid it out so simply and effectively. Huge kudos!
- JonChesterfield 2y agoTowards the end is a link to a C compiler built for this project. https://github.com/imihajlow/ccpu-cc https://github.com/imihajlow/ccpu-cc. Seems to have a linker and a libc as well. I have no real understanding of how complicated the hardware design part is but casually throwing a C compiler together is great.
- lionkor 2y agoA C compiler written in Rust, in which the lang_c crate is used to parse the language.
- formerly_proven 2y agoPhysically a lot smaller than DEC's first SSI Ethernet card(-set): https://i.ebayimg.com/images/g/NEYAAOSw-mZlg0lZ/s-l1600.jpg https://i.ebayimg.com/images/g/NEYAAOSw-mZlg0lZ/s-l1600.jpg (DEC DEUNA, those boards are over a foot long), though also a lot fewer features. DEUNA is a "real" NIC, it has tx/rx queues and handles all that autonomously. Does DMA, too. It of course comes with it's own on-card PDP-11 to run it.
- _factor 2y agoA network card with opaque firmware is a 0-day away from becoming a global catastrophe. Even RISC-V based switches like the Vega use proprietary switch chips (Wuhan China designed FSL91030M specifically), which is no better. You can verify input/output to a certain extent, but this doesn’t preclude a timer based function call or a tailored packet activation. I wonder why our society tolerates these unknowns. With the push towards WiFi replacing the majority of home networking, I’m not confident it will change any day soon.
- nonrandomstring 2y ago> these unknowns Sorry to throw a Rumsfeld at you, but I think these are "unknown unknowns". If people were aware of the presence and significance of such critical knowledge voids I do not believe they would tolerate them. I see it as the job of civic cybersecurity to bring precisely these sorts of things to wider attention and educate folk on why they are are problematic.
- _factor 2y agoI think visibility is one aspect, but not the whole story. An average home user runs Windows and doesn’t necessarily care if a hypothetical backdoor could exist in their hardware/software stack. They browse the web, do their banking, and share photos on SM after checking their mail and searching for Tiramisu recipes. The existential threat to themselves is low, so they don’t dig further into the ramifications. Journalists, whistleblowers, activists, “undesirables”, those are the primary concerned parties. The civic cybersecurity aspect needs to lay out a clear benefit to free speech and oppression which makes tangible sense to day to day life. I’m not quite sure how to spread this level of awareness, or highlight the importance of such measures in a way that hits home.
- j33zusjuice 2y agoI get the sense it isn’t possible. “What do I have to hide?” “Who would target me?” “I have nothing worth stealing.” Sadly, all those are common replies to what you’re saying needs more awareness.
- amelius 2y agoThis shows how easy it is to put a backdoor inside a chip that is connected to a network port.
- mogoh 2y agoSorry for this naive question, but isn't every network card build out of discrete logic components?
- retrac 2y agoDiscrete is the opposite of integrated, as in integrated circuit. In practice, it means using multiple components. In a strict sense it means no integrated circuits at all, I suppose. But it's also a relative thing. So while a 7400 series chip is not a "discrete" component as most would think of it, using a hundred 7400 series chips to implement a processor is relatively more discrete than a microprocessor. (It's certainly not as integrated.) Since the early 1980s, Ethernet interfaces have used used custom chips, because the amount of logic required would need dozens of gate-level chips otherwise (as seen here!)
- mogoh 2y agoah, that makes sense. Thanks!
- __d 2y agoIn the early 1980s, an Ethernet adaptor required a lot of board space. They were often of similar complexity to the main CPU board. For example, this is DEC's first Unibus Ethernet: https://gunkies.org/w/images/1/16/DEUNA.jpg https://gunkies.org/w/images/1/16/DEUNA.jpg, which occupied two boards. The software required to run a TCP/IP stack was also large, limiting the system to a handful of active sockets, and consuming large parts of the available CPU power to run something like Telnet or FTP. It took a few years for CPUs to get more powerful, more RAM to become affordable, and for network hardware to become integrated onto the smaller boards like ISA or NuBus.
- cfn 2y agoNo, network cards use chipsets, meaning, most of the logic is inside one or two large ICs (Integrated Circuits). What the poster is doing is creating a card using the simplest existing ICs which contain simple logic circuits such as NANDs, multiplexers, etc.
- 2y ago
- whartung 2y agoSo, I read this as a “discrete logic network” “card” rather than “discrete logic” “network card”. All set to learn what a discrete logic network was.
- arnon 2y agoIn Communication Systems Engineering studies we implemented ethernet signalling, then the TCP/IP stack including ARP and switching in Motorola 68k QUIC assembly. Longest 18 months of my life.
- samtho 2y agoThis is really cool, I also love the modularity of this computer setup.
- yjftsjthsd-h 2y agoSo this is for an all-custom computer, which is rather more impressive on its own (to say nothing of "So I made a C compiler."), but now I'm curious what the minimal implementation of an ethernet card for a "normal" PC would be. I suspect a lot of it would be very similar, up to that you could do checksums on the PC's CPU (probably just baked into the driver). It'd need to be attached - either bare serial or more usefully USB? And then you'd either need to write a "real" driver for it or else plumb through to userspace and do it there. For similar things I've eyeballed having the device implement https://en.wikipedia.org/wiki/USB_communications_device_class https://en.wikipedia.org/wiki/USB_communications_device_clas... so it "just works" without needing to do your own driver, but I don't think that would play nice with things like doing all the checksums host-side. Or... while searching for that, I stumbled across https://en.wikipedia.org/wiki/Ethernet_over_USB https://en.wikipedia.org/wiki/Ethernet_over_USB , which maybe suggests that you can just build an adaptor that translates the physical connection to USB and then let the computer magically handle all the rest for you? Dunno, over my head.
- pjc50 2y agoUSB is arguably much more complicated than 10base2 internet, which pre-dates it by a long way. In fact, if you're trying to use either PCIe or USB to connect to a 10base2 ethernet network, either of those will be far more work than the Ethernet side. You might be able to persuade a FTDI-style USB device to bit-bang 10base2 Ethernet for you. You'd implement a "PHY" side which translates the wire traffic to a clean bitstream and aligns the frame start and then just have the PC handle all of it in software for you.
- yjftsjthsd-h 2y agoOh, good point. I guess it depends on your usecase. I was thinking from the angle of not trusting premade network cards but trusting your USB chips.... which now that you point out, is also not a given. Maybe bare serial (just a wire per tx/rx), but it suddenly occurs to me that I don't know how that's actually connected to the CPU, and I think that approaching this from a security angle is a quick road to madness. OTOH... connecting a microcontroller to serial probably is the simplest option and as an engineering exercise is perfectly reasonable, if not exactly fast, but hey it's not like this was ever going to be performant.
- Bvlynicole 2y ago[dead]
- Cittly87 2y ago[dead]
- Cowan64 2y ago[flagged]
- 2sk21 2y agoGreat work! Quite an interesting collection of hardware you have built!
- tranxen 2y agoI often use ENC28J60 chips which are converting SPI <=> 10Base-T, they are very fun to work with and not so expensive ($4). But reading (https://qdiv.dev/posts/eth-to-spi/ https://qdiv.dev/posts/eth-to-spi/) about somebody that made that chip from basic components is really awesome. Thanks a lot !
- asdefghyk 2y agoI would like to see a hard disk with all open source software. This sounds extremely challenging, even just the physical construction. My thought is to take an EXISTING hard disk and replace the software. I think one problem is may some of the chips , it is hard / challenging to obtain programming information.
- ynoxinul 2y agoYou can replace the controller board all together, the electrical interface should not be that hard. You have to spin the spindle, jiggle the heads and send/receive the data. The main problem I see here is that modern hard drives have enormous, unimaginable information density. There must be so many tricks how they achieve that (and do that reliably!). You have to re-trace the steps the hard drive industry has made in the last 50 years.
- jsjohnst 2y ago> I would like to see a hard disk with all open source software. You’ve got me curious of the use case, is it fascination or some other reason? From a security perspective, it seems straightforward to just encrypt the bytes before sending to the drive. That would ensure you can detect data being maliciously changed and/or protect against the drive somehow misusing the data.