========== Subtractor [TOC] ========== In this section we will build an integer subtractor. Actually we will not really build new hardware here because the adder can be used for this. We just have to do some minor modifications. Assignment ========== Build an 8-bit subtractor by using an 8-bit adder. Make sure that the $c_{\text{out}}$ indicates that the result of the operation can be represented with 4 bits as an unsigned integer, i.e.: ---- LATEX --------------------------------------------------------------------- c_{\text{out}} = 0 \quad \Leftrightarrow \quad a - b \in \{0, \dots, 2^8-1 \} -------------------------------------------------------------------------------- In __Assignment 2.3__ hand-in a link to your project. Video tutorial ============== ---- VIDEO ------------------------------ https://www.youtube.com/embed/HJ4o1_lwP0g ----------------------------------------- Supplements: Formal description of an Adder and Subtractor ========================================================== We so far just gave a rather technical description of the functionality implemented by an adder/subtractor. We are now able to describe these devices more general: - An $n$-bit adder/subtractor inputs has $a_{n-1}, \dots, a_0$ and $b_{n-1}, \dots, b_0.$ Furthermore, it has an input $c_{\text{in}}$ which (for our purpose) is - fixed to $c_{\text{in}} = 0$ for an adder and - fixed to $c_{\text{in}} = 1$ for a subtractor. - Both, an $n$-bit adder and an $n$-bit subtractor, have outputs $s_{n-1}, \dots, s_{0}$ and $c_{\text{out}}$. - For both devices the inputs are interpreted as unsigned integers ---- LATEX ------------------------------------------------------------------- a := (a_{n-1}, \dots, a_0)_2, \quad b := (b_{n-1}, \dots, b_0)_2 ------------------------------------------------------------------------------ and hence we have ---- LATEX ------------------------------------------------------------------- a, b \in \{0,\dots,2^n-1\} \subset \mathbb{N}_0. ------------------------------------------------------------------------------ - The adder computes its outputs such that ---- LATEX ------------------------------------------------------------------- s = (a + b) \bmod 2^n \quad\text{for}\; s := (s_{n-1}, \dots, s_0)_2 ------------------------------------------------------------------------------ and ---- LATEX ------------------------------------------------------------------- c_{\text{out}} = 0 \quad \Leftrightarrow\quad s = a+b. ------------------------------------------------------------------------------ - The subtractor computes its outputs such that ---- LATEX ------------------------------------------------------------------- s = (a - b) \bmod 2^n \quad\text{for}\; s := (s_{n-1}, \dots, s_0)_2 ------------------------------------------------------------------------------ and ---- LATEX ------------------------------------------------------------------- c_{\text{out}} = 0 \quad\Leftrightarrow\quad s = a-b. ------------------------------------------------------------------------------ :links: Assignment 2.3 -> https://moodle.uni-ulm.de/mod/assign/view.php?id=203392 :navigate: up -> doc:index next -> doc:session02/page04 back -> doc:session02/page02