From 3619e58266e7231f0c354ab6ef2c84a44fb68e18 Mon Sep 17 00:00:00 2001 From: Medium Fries Date: Tue, 2 Oct 2018 19:46:56 -0700 Subject: [PATCH] asm: base for lec11 --- cst337/lec/lec11.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/cst337/lec/lec11.md b/cst337/lec/lec11.md index 4f526f5..5425808 100644 --- a/cst337/lec/lec11.md +++ b/cst337/lec/lec11.md @@ -1,3 +1,41 @@ # lec11 +At this point I'l mention that just reading isn't going to get you anywhere, you have to try things, and give it a real earnest attempt. +__ALU:__ Arithmetic Logic Unit + +## Building a 1-bit ALU + +![fig0](../img/alu.png) + +First we'll create an example _ALU_ which implements choosing between an `and`, `or`, `xor`, or `add`. +Whether or not our amazing _ALU_ is useful doesn't matter so we'll go one function at a time(besides `and/or`). + +First recognize that we need to choose between `and` or `or` against our two inputs A/B. +This means we have two inputs and/or, and we need to select between them. +_Try to do this on your own first!_ + +![fig1](../mg/fig1llec11.png) + +Next we'll add on the `xor`. +AGAIN: try to do this on your own, the main hint I'll give here is: the current mux needs to be changed. + +![fig2](../img/fig2lec11.png) + +Finally we'll add the ability to add and subtract. +You may have also noted that we can subtract two things to see if they are the same dhowever, we can also `not` the result of the `xor` and get the same result. + +![fig3](../img/fig3lec11.png) + +At this point our _ALU_ can `and`, `or`, `xor`, and `add`/`sub`. +The mux will choose one which logic block to use; the carry-in line will tell the `add` logic block whether to add or subtract. +Finally the A-invert and B-invert line allow us to determine if we want to invert either A or B (inputs). + +## N-bit ALU + +For sanity we'll use the following block for our new ALU. + +![fig4](../img/fig4lec11.png) + +Note that we are chaining the carry-in's to the carry-out's just like a ripple adder. +also each ALU just works with `1` bit from our given 4-bit input.