TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to Build Your Own Discrete 4-Bit ALU

64 pointsby elijahparkerover 8 years ago

4 comments

ChuckMcMover 8 years ago
Seriously? A 1 bit &quot;full adder&quot; is too complicated to build with discrete gates? If you are going to show people how to build a <i>discrete</i> 4 bit ALU then you really need to own it and at least build it with simple gates, if not transistors if you want to <i>seriously</i> own the discrete bit. As you can see in this reference (<a href="https:&#x2F;&#x2F;en.wikibooks.org&#x2F;wiki&#x2F;Microprocessor_Design&#x2F;Add_and_Subtract_Blocks" rel="nofollow">https:&#x2F;&#x2F;en.wikibooks.org&#x2F;wiki&#x2F;Microprocessor_Design&#x2F;Add_and_...</a>) a single bit full adder is 2 xor, 2 and, and an or gate. For for a four bit addr, that is 8 XOR (2 chips), 8 AND (2 chips), and 4 OR (1 chip), so 5 chips instead of one MSI 4 bit adder.
评论 #12371947 未加载
评论 #12371186 未加载
SloopJonover 8 years ago
I like projects like this. I started reading <i>Code</i> a while back, and thought it would be fun to make a computer out of relays, light bulbs, tinker toys, or whatnot. Then I started reading <i>The Elements of Computing Systems</i>, and thought about building something in a FPGA. One of these days.
评论 #12370017 未加载
评论 #12371686 未加载
hatsunearuover 8 years ago
The ALU is arguably one of the most simplest parts of a usable CPU.<p>The more nuanced stuff is memory management (caches, etc), IO, branch prediction, and pipelining.
评论 #12371690 未加载
评论 #12370660 未加载
tzsover 8 years ago
For software people who find this interesting and would like a great introduction, consider taking the course &quot;Computation Structures&quot; from MITx on EdX.<p>It&#x27;s in three parts. The next run of part I, &quot;Digital Circuits&quot;, starts September 6th. Here&#x27;s the link: <a href="https:&#x2F;&#x2F;www.edx.org&#x2F;course&#x2F;computation-structures-part-1-digital-mitx-6-004-1x-0" rel="nofollow">https:&#x2F;&#x2F;www.edx.org&#x2F;course&#x2F;computation-structures-part-1-dig...</a><p>Part I cpvers basic logic gates, at both a high level (how you use them) and a lower level (how you build them on a chip), their characteristics (propagation delay, contamination delay, and things like that), combinatorial logic, sequential logic, state machines, pipelining, and probably more that I don&#x27;t remember. The labs are done via a browser-based simulator, and by the end of the course you will have designed and implemented a 32-bit ALU with add, subtract, logical and arithmetic shifts in both directions by up to 31 bits, all the boolean operators, and the usual comparison operators.<p>Part II builds on that, taking you through designing and implementing a full 32-bit processor. Caching is discussed in the lectures, but not used in the processor.<p>Part III (which I did not have time to take), I believe, adds caching and pipelining to the processor, and covers parallel processing and device handling, and also operating system stuff.<p>For a while I wanted to actually build the processor from Part II using discrete 7400 series logic, but the chip count came in too high for me. My gate counts were: 295 AND2, 8 AND3, 3 NOR2, r OR2, 96 OR3, 20 OR4, 226 XOR2, 6 NOT, 563 MUX2, 161 MUX4. (That&#x27;s not counting whatever I&#x27;d need for the control ROM and the 32 x 32-bit register file).<p>At 4 MUX2s per chip, and 4 AND2s per chip, that&#x27;s 215 chips. Another 81 for the MUX4s and 57 for the XOR2s brings it up to 353. Without even tossing in the rest, I&#x27;m way over my limit.<p>I could cut this down quite a bit by taking out the shift unit (which uses 353 MUX2s), making the shift instructions generate an illegal instruction trap, and have the trap handler emulate the shift instructions. That would save 88 chips. (Well, not quite 88 chips...I think I&#x27;d have to add a &quot;logical right shift by 1&quot; instruction to make it so this approach would not be too slow, but a dedicated &quot;logical right shift by 1&quot; unit is a lot simpler than a &quot;shift logical or arithmetic in any direction by any amount&quot; unit).<p>The cool thing though, is that <i>I</i>, a software guy, <i>could</i> could actually make those hardware changes now. A lot of things about computers now make a lot more sense to me. I highly recommend it to those curious about what goes on at a lower level than we software guys normally deal with (even if we are writing software that interfaces with devices).
评论 #12372783 未加载