Last visit was: Thu Dec 02, 2021 1:01 am
It is currently Thu Dec 02, 2021 1:01 am

 [ 23 posts ]  Go to page Previous  1, 2
 Starting point 
Author Message

Joined: Fri May 05, 2017 7:39 pm
Posts: 22
actionfingers wrote:
I know it might be a little soon to be asking questions, but I'm stumped. Hoping someone can help me out.

I've been reading Understanding Digital Electronics. At the top of page 1-9, it gives an example where if scan line 9 is on and segment lines a,b,c,d,g,h are on, then the number 3 will be displayed. If scan line 9 is being turned on, shouldn't segment lines a,b,c,d,f,g, and h be turned on displaying a "9?" I feel like I'm missing something or that I'm not totally grasping the material.

Thanks in advance for any guidance.

Welcome actionfingers!

The displayed numbers (or symbols!) depends on the turned-on segment lines, the position (where the symbol becomes visible) within a multiple digit display is selected by the scanlines. You should only activate one scanline at once.

The segment line for h is "optional" as you can add a dot/decimal point to all symbols if needed.

You can not only display numbers, some letters are easily recognized as well:

"A" requires a,b,c,e,f,g to be turned on, all others off.
"b" requires c,d,e,f,g to be turned on, all others off.
"C" requires a,d,e,f to be turned on, all others off.
"d" requires b,c,d,e,g to be turned on, all others off.
"E" requires a,d,e,f,g to be turned on, all others off.
"F" requires a,e,f,g to be turned on, all others off.

Some letters are really difficult - that's why there are 14- and 16-segment-displays as well ;-)


You do not have the required permissions to view the files attached to this post.

Last edited by GaBuZoMeu on Thu Sep 06, 2018 11:16 am, edited 1 time in total.

Thu Sep 06, 2018 11:06 am

Joined: Wed Aug 29, 2018 11:07 am
Posts: 10
I appreciate all of the feedback! Thank you!

I believe I was just confused. I finally realized that it was basically just covering how a number gets sent to the display, not what button was pressed to get that number. That's why I kept asking myself why a '3' was being displayed when scan line 9 was energized. Because scan line 9 was energized, I just assumed that the '9' key was being pressed and that's not necessarily the case in this bit of text.

At least I think that's what had me confused. LOL

Thanks again!

Thu Sep 06, 2018 11:14 am

Joined: Sat Jun 16, 2018 2:51 am
Posts: 50
I've found these two resources very helpful as a starting point:
Their emphasis is on building a (simple) CPU if that's the route you want to take at some point.

Mon Mar 25, 2019 11:11 pm

Joined: Wed May 15, 2019 1:17 am
Posts: 21
I'll put in a shameless plug to my own set of beginner videos. Ben Eater's ones are more professional, though.

Crazy Small CPU Playlist: How Does a CPU Work?

Wed May 15, 2019 2:33 am

Joined: Wed Aug 29, 2018 11:07 am
Posts: 10
Hey guys. Sorry for the radio silence.

So, I've been working the nandtotetris curriculum for the past week or so and am about to start project 2 where I'm supposed to build a half-adder, full-adder, adder, incrementer, and alu.

I understand the instructors are trying to keep things as simple as possible for the sake of learning, but I can't help but to think ahead.

The Hack ALU that they have us build has functions built into it that perform operations on the inputs. Below is a snippet from the slide presentation.


My question is, if I wanted to build my own ALU, how would I determine what those functions are? Is there some sort of standard list of functions that are used in ALUs? I'm just trying to figure out how they came up with those functions. It shouldn't hinder my progression through Project 2, but I can't help but wonder where those functions came from.


Tue Jun 16, 2020 2:05 pm

Joined: Mon Oct 07, 2019 2:41 am
Posts: 273
It all depends on the problems you wish to solve.
Computers process information except in Si-Fi where
they seem to want take over the world.
Numbers are important in many problems,a so ALU
has a way to act on that. Logic operations used
less but still important. Selecting what functions a
alu has depends on what you wish to do,but you need
a few basic ones. All other functions are made from the
primary ones. Just what is a primary function is a matter
of great debate because often there is many ways to solve
a problem.The HACK alu is just one solution to this problem.
A computer playing chess might have a very different ALU.

Tue Jun 16, 2020 4:29 pm

Joined: Wed Jan 09, 2013 6:54 pm
Posts: 1647
Good question! I'd say there are normally 3 and in this case 4 considerations:
- what might be useful, in implementing useful opcodes
- what might be affordable, in meeting area, time, and power constraints
- what is normally done
and in this case
- what has educational value

In a way there's a lot of wisdom to distill into the choice, because what can be built (within budget) depends on implementation knowledge, but what will be useful depends on an understanding of how machine code gets used in real programs, whether written by hand or by compiler.

A machine that's a good compiler target would be very different from a machine that's built to be as simple as possible.

I think I'd recommend study of two ALUs
- the 6502's ALU, perhaps in the original NMOS implementation, perhaps in a TTL recreation
- the OM2 ALU from Chapter 5 of Mead & Conway (see page 204)

But both of the those are NMOS transistor-level implementations. A 74-series TTL ALU has different pieces to be built from, as does an FPGA implementation.

Oh, and there's the ARM1 too.

Tue Jun 16, 2020 4:55 pm

Joined: Thu Dec 05, 2019 7:53 am
Posts: 7
Location: Tokyo, Japan
actionfingers wrote:
My question is, if I wanted to build my own ALU, how would I determine what those functions are? Is there some sort of standard list of functions that are used in ALUs?

There's a relatively small set of logic functions you start with.

For those, keep in mind that a multi-bit logic unit (LU) is just a bunch of single-bit LUs running in parallel. Consider a four-bit AND function, e.g.: 0101 ∙ 0011 = 0001. This is simply the 1-bit binary AND function applied separately to each individual bit:

      0011 ∙ 0101 = 0001

      0--- ∙ 0--- = 0---
      -0-- ∙ -1-- = -0--
      --1- ∙ --0- = --0-
      ---1 ∙ ---1 = ---1

So when examining LU functions, we need look at only a one-bit LU; a wider LU will simply be the one-bit LU repeated.

Given two binary inputs, A and B, there are a total of only four possible input combinations AB: 00, 01, 10, 11. Thus, with four possible inputs to a logic function, you have four possible outputs. We can list these as a string; from the example above we can see that the four possible outputs of AND are 0001.

Given that the possible outputs of a binary logic function of two inputs can be viewed as a four-digit binary number, it's clear that there are only sixteen of these functions. Listing all of them gives us the binary truth table:

      0 0 1 1      A
      0 1 0 1  in  B
      0 0 0 0   ₀  FALSE    0                 A∙/A, contradiction
      1 1 1 1   ₀  TRUE     1                 A+/A
      0 0 1 1   ₁  A        A                 projection
      1 1 0 0   ₁  NOTA     /A                negation
      0 1 0 1   ₁  B        B                 projection
      1 0 1 0   ₁  NOTB     /B                negation
      0 0 0 1      AND      A∙B
      1 1 1 0      NAND     /(A∙B)
      0 1 1 1      OR       A+B
      1 0 0 0      NOR      /(A+B), /A∙/B
      0 1 1 0      XOR      A⊕B, A≠B
      1 0 0 1      XNOR     A=B,              A⇔B, iff, biconditional
      0 0 1 0               A∙/B
      0 1 0 0               /A∙B
      1 0 1 1               A+/B
      1 1 0 1               /A+B              A⇒B, implication

(The "in" column above just notes the number of effective inputs, e.g., the for the "project A" function the B input is effectively ignored, so I mark that as having 1 effective input.)

Adding arithmetic functions to this mix makes things more complex since a binary arithmetic function has two outputs from binary inputs A and B: the result and the carry. But the technique used above to list all of the logic functions can be extended to list all of the arithmetic functions. That's probably a good exercise to do before looking at binary adders.

Curt J. Sampson -

Tue Jun 30, 2020 11:59 pm
 [ 23 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: CCBot and 0 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software