Searched Projects

Tags: subtractor

project.name
23 Stars     4506 Views
User:
User Image me

This is a CPU witch is capable of executing a lot of stuff in one clock cycle, and this CPU can shift left up to 7 times and shift right up to 7 times witch means that it is possible to  multiply and divide in one clock cycle if you program a table in the program memory. it has a 32 bit instruction width and a 8 bit address. it also has 

The ALU has the following operations:

  • ADD
  • SUBTRACT
  • SHIFT_LEFT (up to 7 times per cycle 3 bit)
  • SHIFT_RIGHT (up to 7 times per cycle 3 bit)
  • XOR
  • OR
  • NOT

This Was made by miles


project.name
0 Stars     100 Views
User:

HALF SUBTRACTOR

HALF SUBTRACTOR

project.name
1 Stars     123 Views
User:

FULL SUBTRACTOR

FULL SUBTRACTOR

project.name
0 Stars     130 Views
User:
User Image Tom

project.name
0 Stars     110 Views

combination-circuit

combination-circuit

project.name
0 Stars     88 Views

Full Adder and subtractor

Full Adder and subtractor

I like eating breakfast as any meal of day.


project.name
0 Stars     88 Views

Subtractor circuits

Subtractor circuits

project.name
0 Stars     68 Views

subtractor

subtractor

project.name
0 Stars     145 Views

Full adder,
4-bit Binary Adder-Subtractor


project.name
0 Stars     72 Views
User:

practical

practical

project.name
74 Stars     195173 Views

A 16-bit computer/maybe console inspired thing, the Femto-4. This will be the main branch and backups will be forks from it. This project was started around November 2020.

Currently runs: 

  • Cart A: Flappy Bird 
  • Cart B: Some Pixel Art 
  • Cart C: Screensaver 
  • Cart D: Snake 
  • Cart E: Phemton Demonstrations 
  • Cart F: Competitive Snake 
  • Cart G: Tic Tac Toe 
  • Cart H: Connect 4 
  • Cart I: NIM
  • Cart J: Bad Apple
  • Bundle Cart: All carts in one 
  • Cart 2A: 32x32 Snake
  • Cart 2B: 32x32 Competitive Snake
  • Cart 2C: 32x32 Pixel Art
  • Cart 2D: 32x32 Bad Apple
  • Bundle Cart 2: All 32x32 carts in one 

Assembler: 

Compiler: 

The 256-Series: 

Full screen Notes:

For some reason, the Femto-4v2.6 only is having issues around caching previous subcircuits. Should you need to use something to unbind key entries from the full screen button, toggle the clock. Previous versions are completely unaffected. 

Cart Notes: 

Cart A: 

  • The first cart written for the Femto-4. 

Cart B: 

  • The sprites in the cart are: 
  • A: Femto-4 Logo. 
  • B: Madeline from Celeste. 
  • C: Madeline from Celeste (again). 
  • D: Part of you aka Badeline from Celeste. 
  • E: A strawberry from Celeste.
  • F: Standing Mario from Super Mario Bros. 
  • G: Jumping Mario from Super Mario Bros. 
  • H: Standing Mario from Super Mario Bros 3. 
  • I: Running Mario from Super Mario Bros 3. 
  • J: Sanderokian (my own character). 

Cart C: 

  • Enter anything into the keyboard to randomise the colours. 
  • Enter r into the keyboard to reset the colours. 

Cart D: 

  • WASD Pad is recommended. 
  • Game settings (enter the letter before starting the game to use the setting): 
  • e: toggle whether crashing into the edges results in a game over. 
  • The two modes (with/without edge collisions) have two separate high scores. 
  • w: change the snake's colour scheme to white. 
  • r: change the snake's colour scheme to red. 
  • y: change the snake's colour scheme to yellow. 
  • o: change the snake's colour scheme to orange. 
  • p: change the snake's colour scheme to purple. 
  • a: change the snake's colour scheme to aqua. 
  • g: change the snake's colour scheme to green. 
  • b: change the snake's colour scheme to blue. 
  • m: change the snake's colour scheme to magenta. 
  • 1: change the snake's colour scheme to pink. 
  • 2: change the snake's colour scheme to light blue. 
  • 3: change the snake's colour scheme to the challenge colour scheme with an invisible body. 
  • 0: randomise the snake's colour scheme. 

Cart E: 

  • The test codes in the cart are: 
  • 1: Hello World. 
  • 2: Single Operator Calculator. 
  • 3: Exponentiation Calculator. 
  • 4: Fibonacci Calculator. 
  • 5: Keyboard to TTY Test. 
  • 6: Keyboard to TTY LDI LID Test. 
  • 7: Keyboard to TTY LII Test. 
  • 8: Keyboard to TTY LIA Test. 

Cart F: 

  • WASD Pad is essentially required. 
  • Game settings (enter the letter before starting the game to use the setting): 
  • e: toggle whether crashing into the edges results in a game over. 
  • w: toggle whether the number of wins each player has is tracked. 
  • s: toggle whether the total score each player has scored is tracked. 
  • d: display the total wins and total scored. 
  • r: reset the tracked statistics. 

Cart G: 

  • The small light in the corner indicates which player's turn it is. 
  • When it is dimmed, it means that the computer is processing that player's turn. 
  • Game settings (enter the letter before starting the game to use the setting): 
  • w: toggle whether the number of wins each player has is tracked. 
  • s: toggle automatic start player swapping. d: display the wins each player has. 
  • r: reset the wins each player has. 

Cart H: 

  • The bar at the top indicates which player's turn it is. 
  • When it is dimmed, it means that the computer is processing that player's turn. 
  • Game settings (enter the letter before starting the game to use the setting): 
  • w: toggle whether the number of wins each player has is tracked. 
  • s: toggle automatic start player swapping. 
  • d: display the wins each player has. 
  • r: reset the wins each player has.

Cart I:

  • Game settings (enter the letter before starting the game to use the setting):
  • w: toggle whether the number of wins each player has is tracked. 
  • s: toggle automatic start player swapping. 
  • d: display the wins each player has. 
  • r: reset the wins each player has. 
  • i: display the game instructions. 
  • c: toggle the whether player 2 is played by the computer. 

Cart J:

  • Plays Bad Apple
  • There are no further controls

Cart 2A:

  • The options are the same as Cart D. 

Cart 2B:

  • The options are the same as Cart F. 

Cart 2C:

  • The sprites in the cart are: 
  • A: Femto-4 Logo. 
  • B: Sanderokian (my own character). 
  • C: Alstran (my own character). 

Cart 2D:

  • Plays Bad Apple on the larger screen
  • There are no further controls

Features: 

  • Immediate, direct, & indirect memory access. 
  • Jumps & conditional jumps. 
  • 16-bit address space. 
  • Switchable memory banks, allowing for a standard cart to hold up to 1MB of data. 
  • An ALU capable of logical operators, addition, subtraction, shift left, shift right, multiplying, dividing, & other specialised functions. 
  • Fast execution - can run more than one instruction per clock cycle. 
  • 16x16 pixel display with 32 sprites and 15-bit direct colour. 
  • 32x32 pixel display with 32 sprites which can have up to 18-bit direct colour. 
  • Two controllers, a keyboard mapping for the controllers, & a keyboard for text inputs. 
  • RNG, TTY, stack, & save memory. 
  • Von Neumann Architecture. 
  • Assembler & compiler (written in Python). 
  • Twelve pre-written carts to play with. 

Updates: 

v1.0: 

  • Finished the project and added Cart A. 

v1.1: 

  • Added Cart B, some Pixel Art. 
  • Fixed GRF, & AXR instructions. 
  • Made Bootloader clear TTY, Keyboard, & Controller Pushed. 
  • Updated Cart A & Cart B to make use of AXR instructions. 

v1.2: 

  • Added Cart C, a Screensaver. 
  • Updated Cart B to respond to the start button on both controllers. 

v1.3: 

  • Added Cart D, Snake. 
  • Moved to new project to fix issues around searching for projects branched from private projects. 
  • Removed unnecessary EEPROM banks and write lines from all carts. 
  • Made Reset clear WRAM and the General Registers. 

v1.4: 

  • Fixed Keyboard. 
  • Added a Bundle Cart that allows you to view all the carts without changing carts (you must reset the console to view another cart). 
  • Fixed bug in the standard bank design which wrote data to incorrect addresses. 
  • Fixed contention issue in Mult. 
  • Added Annotations to the In Debug. 

v1.5: 

  • Added Snake Player. 
  • Added Reset & Power labels to the relevant buttons. 

v2.0: 

  • Further optimisation to reduce lag/increase execution speed. 
  • Added more memory access options. 

v2.1: 

  • Further optimisation of the CU. 
  • Added a keyboard to controller mapping. 

v2.2: 

  • Continued optimisation and overhaul of the CU. 
  • Removed old CU & compare circuits. 
  • Added additional stack access instructions. 
  • Updated the debug versions with the changes, as well as fixing bugs in the debug versions. 
  • Designed a Logo for the Femto-4. 
  • Rewrote Cart C to allow the sprites to be viewed in any order, and added the logo to it. 

v2.3: 

  • Introducing Phemton Lite, the first version of the Femto-4's high level languages. 
  • Added a link to Phemton Lite's compiler. 
  • Added Cart E to demonstrate code written in Phemton Lite. 
  • Combined SpecialD & ROMD1, and removed SpecialD & ROMDB. 
  • Updated Snake code & Bundle code to match the new addresses. 
  • Added Cart F, a competitive version of Snake. 
  • Added an additional sprite into Cart B. 
  • Fixed issues with LII, LXA & LXP instructions. 

v2.4: 

  • Fixed alignment of the upper carts. 
  • Added Cart G & Cart H, Tic Tac Toe & Connect 4 written in Phemton Lite. 
  • Added progress lights to Cart G & Cart H. 
  • Reworked bundle cart to make the code shorter and more efficient for large numbers of carts. 
  • Made Cart G & Cart H faster. 
  • Reshuffled Cart E test codes and added 2 Cart E test codes, exponentiation & Fibonacci calculation. 
  • Added game options to Cart D, Cart F, Cart G, & Cart H. 
  • Updated Cart C to allow the colours to be randomised. 
  • Added optional colour schemes for Cart D. 
  • Fixed Snake Player. 
  • Remade the multiply and divide circuits to take advantage of the inbuilt adders. 
  • Removed old MultM and DivM circuits. 

v2.5: 

  • Further optimisation of the CU. 
  • Optimisation of the fast execution clocks for the computer, the graphics, & the WASD Pad. 
  • Fixed debug versions' issues with Phemton conditionals and added optimisations to the debug versions. 
  • Added 32x32 screen PPU. 
  • Added Cart 2A, Cart 2B, & Cart 2C, 32x32 versions of Snake, Competitive Snake, & Pixel Art. 
  • Added Cart I, NIM written in Phemton Lite. 

v2.6

  • Added the ability to directly write sprites to the PPU during execution.
  • Significantly optimised the CU by removing unnecessary subcircuits.
  • Introduced significant quantities of lazy evaluation to further improve performance.
  • Added Cart J, and Cart 2D, which both play Bad Apple.
  • The Femto-4 can now be added to the set of things that plays Bad Apple.

Future Updates: 

  • More pre-written carts. 
  • Bug fixes. 
  • Adding an optimiser to the compiler. 
  • Phemton Full. 
  • Phemton Plus. 

Do fork the project and write your own code for it! If you want more information on how to do so read the Developer Guide in the assembler. 

Note: The Flappy Bird high score and the Snake high score are mine. If you want to save your own scores permanently you will have to fork the project. 

The Femto-4

 Femto-4 Logo

General Architecture: The Femto-4 is a 16-bit, Von Neumann architecture computer with variable length instructions that are comprised of multiple 16-bit words. It has many features associated with CISCs, such as variable length instructions, and multicycle indirect loads, however operates like a RISC, with each instruction taking exactly 1 clock cycle. This was done to give the Femto-4 power whilst keeping its construction simple. First the OP code of the instruction is read, and then depending on the OP code, additional pieces of data may be read for the operands. This allows execution to become incorrectly offset, which can lead to the execution of garbage if the PC is jumped to an incorrect address. This is usually fine, since the OP code space is so empty that the data will likely be passed one at a time until the next valid instruction. Instructions are read from main memory, making this architecture a Von Neumann architecture as opposed to a Harvard architecture. The MAR always specifies the address being read to or written from, whilst the MDR always holds the data being written. Data from the data out bus can be written to most special registers during the instruction. OP codes and operands are all 16-bits. The large OP code size was chosen due to the high number of ALU instructions. There are approximately 500 interpretable OP codes that the computer can handle. 

Memory Mapping: The 16-bit address space of the Femto-4 is memory mapped, with all data being stored somewhere in the address space. The last 48kx16b of memory (all addresses starting with 0b01, 0b10, or 0b11) are dedicated to the cart memory. This is where the interchangeable program would be stored, allowing programs to be easily changed by changing carts. The carts have 32 16kx16b EEPROM/RAM chips, which can be switched between during execution by writing to address 0x00cc. This gives each cart 512kx16b of memory to play with. In theory, additional memory can be added in a cart by creating a similar system on the inside of the cart, which would allow it to swap between even more EEPROM/RAM chips. The initial 16kx16b are therefore mapped to everything else, including a fixed WRAM chip that cannot be switched out, the bootloader, the PPU data, general registers, the stack, inputs, outputs, and a few special registers, such as the protect, mode, and flag registers. 

Fast Execution: Execution at the fastest clock speed (one pulse every 100ms, or 10Hz, which is defined as the clock changing state every 50ms, or at a rate of 20Hz) is terribly slow, and would make reasonable graphics effectively impossible. Due to this, the Femto-4 includes several execution modes that allow the computer to run much faster. There are two registers involved in this, address 0x00ca, the mode register, and address 0x00cb, the protect register. When the two least significant bits of the mode register are low, the computer runs normally, executing 1 instruction per clock pulse. When bit 0 is set high, the computer enters fast execution on the rising edge, where it executes multiple instructions per clock pulse. This is achieved by looping an inverter into itself, producing a loop that will pulse indefinitely until the looping line is stopped by some external factor. Stopping the loop is critical since leaving the loop running will stop CircuitVerse's execution, due to it going over the stack limit of the execution. Fast execution is always paused by a 0x0000 and 0x0001 OP Code. Bit 2 enables falling edge fast execution, which can be done with rising edge fast execution producing dual edge fast execution. Setting the third bit of the mode register high will enable protection. This will ensure that computer only executes as many instructions as the value in the protect register. This protects execution by ensuring that the loop will always pause before the cycle limit is reached. Since some operations are far more complex than other operations, the maximum number of instructions per clock pulse is variable, and testing should always be conducted to ensure that the limit is not reached. Due to this, for games that need regular graphics updates, it is recommended that protection is not used, and instead the pauses are fully code controlled. On the other end of the mode register are the graphics mode. The highest two bits give the graphics update mode, 0b00 for falling edge only (normal speed), 0b01 for dual edge (double speed), 0b10 for every other clock pulse (half speed), and 0b11 for code controlled, where the 0x0001OP Code is required to update the graphics. The third most significant bit is the graphics disable bit. Setting it high stops updating the graphics, reducing lag by prevent the graphics fast execution loop from running. The mode and protection values are only updated on the rising edge of the clock pulse, and therefore there should always be pauses before and after any execution mode or protection change. By default, the Femto-4 executes with a protection value of 16, to allow the carts to run smoothly, however, depending on the instructions being used, that number can be raised to 64. 

Graphics (16x16): The Femto-4 is capable of driving a 16x16 15-bit direct colour screen. It has space for 32 sprites which are rectangles with an assigned colour. All the sprites are drawn to the screen whenever a graphics update occurs, depending on the graphics mode. When using dual-edge fast execution, the falling edge should only be used to execute game code, since writing graphics data as the screen is being drawn may mess up the graphics. These 32 sprites have their data stored in the PPU RAM in the following format: The first 16 bits are the corners of the rectangle, with each coordinate being 4 bits. The coordinates are ordered x coordinate 1 (4), x coordinate 2 (4), y coordinate 1 (4), y coordinate 2 (4). The second coordinates are offset up by 1, to allow the full screen to be drawn to, such that the dimensions of the rectangle are (x2 - x1) + 1 and (y2 - y1) + 1. The next 16 bits are the sprites colour, with the first 15 bits being used for 15-bit direct colour, and the last bit being used to enable or disable drawing the sprite. The last bit is important to ensure that blank sprites are not drawn to the screen. Since the screen is not wiped every time it is refreshed, the background must be a sprite to ensure that the screen is fully wiped before the rest of the sprites are drawn on. Control of this allows carts to draw a single frame over multiple updates, allowing the 32-sprite limit to be bypassed (see how Snake works). The sprites are drawn in memory order, with the sprite with the largest address always being drawn last and therefore on top, of all other sprites. This is achieved by using the exact same system as fast execution, which reads off all the sprite data and draws them to the screen in a single clock pulse. This can loop more times safely than the main CPU since it has less dependencies which dramatically decreases the simulation's stack usage. 

Graphics (32x32): The Femto-4 can also drive a 32x32 screen, with sprites able to be drawn through 3 different modes. The 32x32 screen PPU treats the addresses as one combined 32-bit value, with the value with the smaller address going first. The first 3 bits of the 32 bits define the mode. Only the values 1, 2, 3, correspond to actual sprites, whilst the rest are not drawn to the screen. Mode 1 splits the remaining 29-bit space as the following: unused (1), x coordinate (5), y coordinate (5), red (6), green (6), blue (6). Mode 2 splits the 29-bit space in the following way: x coordinate 1 (5), x coordinate 2 (5), y coordinate 1 (5), y coordinate 2 (5), red (3), green (3), blue (3). Mode 3 splits the 29-bit space in the following way: unused (3), x coordinate (5), y coordinate (5), red (5), green (5), blue (5), alpha/transparency (1). As with the 16x16 screen, Mode 2's second coordinates are offset by 1 resulting in rectangles having the dimensions of (x1 - x2) + 1 and (y1 - y2) + 1. Mode 3 is designed to allow the colours used in the 16x16 screen to be the same, making converting code between the two versions easier. The update mechanism is the same as 16x16 screen. 

ALU: The basic ALU was inspired by the ALU-74LS181. It was designed to flexibly change between various operations by changing an additional piece of data which is bundled in the OP code. This allows a single ALU to handle all the required processes, such as the basic binary logic operations, shift left, adding, and subtracting, reducing the number of circuits required, as well as the logic required to decide which instruction to use. The Femto-4 also can multiply, divide, shift right, shift left/right by a specified number of bits, and perform operations designed to work with the computer's graphics data. 

Conditional Jumps: The Femto-4 can perform immediate and direct jumps depending on the flags, a specified bit of the accumulator, and the clock. The flag jumps allow for comparisons to be made. There are three flags, the carry, the most significant bit in the accumulator, and if the accumulator value is 0, the equals flag. By performing A-B, we can compare A and B by looking at the flags. If the equals flag is true, then A=B, since A-B = 0. If the most significant bit is 0, then the number is positive or 0 (by two's complement) and therefore A>=B. The comparison is not entirely correct for numbers in two's complement (a large positive number and a large negative number when subtracted can yield a positive number), but for small values it works well. Whilst we cannot directly check A<=B using A-B in this design, we can simply flip the subtraction to B-A to do so. The accumulator bit testing is mainly used to check for controller inputs. Since each button in the controller is mapped to one bit, bit testing that bit effectively allows us to check if a button has been pressed. A similar test could be performed using an AND instruction, and checking if the result is equal to 0 or not. Bit testing is most useful for testing an input from both controllers, since it can cut out an additional instruction. The jump on clock is there to ensure that we can jump execution on the right clock pulse, which ensures that graphics can be updated on the edge of execution. 

Timing: The computer is timed using several standard delay chips. The pulse length running in to the computer is about 10k units long. Therefore, different parts an instruction are separated by 20k unit delays. Further control of timings inside these periods is achieved through 1k "On Delays", which have a 1k delay turning on, but a 0k delay turning off, ensuring that pulses do not bleed into the next pulse. These pulses can tell registers to write and what source to write from, enable the read and write lines, update the ALU, and update the stack Each instruction is separate by 600k of delay in fast execution. For more information on how delay works see here: https://circuitverse.org/users/4699/projects/circuitverse-delay-introduction

Keyboard Mapping: The Femto-4's keyboard controller mapping was created using a specialised chip. This chip used the fast execution loop to take 15 inputs from a keyboard and map the inputs to button presses on the controllers. Since the buttons are updated several times in a clock pulse, the keyboard controller cannot handle held buttons. The keyboard mapping is designed to work with both controllers, allowing two player games to be feasible on the computer. 

Assembly: The Femto-4 has an assembler that converts assembly written in a .txt into hex values in a .txt that can be copied and loaded into the EEPROM banks for storage. The assembler can handle symbol assignment, as well as assigning addresses in the code symbols to make handling jumps easier. For full details on the Femto-4's assembly language view the assembly developer guide. 

Phemton: Phemton is the Femto-4's high level language, with a compiler to compile it's code into Femto-4 assembly. Phemton handles variable memory assignment, basic array assignment, if, elif, else statments, while loops, for loops, and functions. Phemton Lite is the only compiler complete, and lacks an optimiser. Phemton Lite has the concept of local scope only when compiling. All uniquely identified variables are given a global address. This reduces the runtime load since the computer does not need to decide where the variables need to go during run time. Future planned additions include generated code optimisations and optimisers, Phemton Full, which has dynamic memory assignment, and Phemton Plus, which adds additional types for floats and longs. For more details view Phemton's developer guide. 

Other Notes: The memory wrappers allow external chips to interact with the main data control system, in this case used for RNG, controllers, the keyboard, and driving the text output. This makes it easy to additional chips to the computer. All assembly and Phemton code can be found in the project for the Femto-4's assembler and compiler respectively. The save data cart must be located outside of the Femto-4 circuit to ensure that its contents are automatically saved. Sorry about all the copies of this computer clogging up the top of the search results. 

For more information, please read the developer guide found in the Femto-4's Assembler, or just post a comment and ask me. 

This is a secret to everybody, unless you found it. 


project.name
1 Stars     287 Views

8-bit full adder

8-bit full adder

A simple 8-bit full adder / substractor.

S will compute the result of A + B or A - B

Use 7 bit numbers in subtraction mode (at least for B, to prevent an overflow).


project.name
0 Stars     61 Views

addSub#

addSub#

An adder and subtractor circuit! Try it out!


project.name
0 Stars     135 Views

Based on TD4, a 4 bit CPU.

Pre-design for Minecraft.


project.name
1 Stars     113 Views
User:

4 operations

4 operations

project.name
0 Stars     74 Views

adder and subtractors

adder and subtractors

project.name
0 Stars     48 Views
User:

half subtractor

half subtractor

project.name
0 Stars     59 Views

project.name
0 Stars     60 Views

full adder and subtractor

full adder and subtractor

I am currently in the process of creating a binary to hexadecimal convertor to show the additions in a decimal form in 2 digits.


help is appreciated just drop me a message and i will add you to the collaborator.


project.name
1 Stars     109 Views
User:

Half and Full Subtractor

Half and Full Subtractor

Full Subtractor: A full subtractor is a combinational circuit that performs subtraction of two bits, one is minuend and other is subtrahend, taking into account borrow of the previous adjacent lower minuend bit. This circuit has three inputs and two outputs. The three inputs A, B and Bin, denote the minuend, subtrahend, and previous borrow, respectively. The two outputs, D and Bout represent the difference and output borrow, respectively. Although subtraction is usually achieved by adding the complement of subtrahend to the minuend, it is of academic interest to work out the Truth Table and logic realisation of a full subtractor; x is the minuend; y is the subtrahend; z is the input borrow; D is the difference; and B denotes the output borrow. The corresponding maps for logic functions for outputs of the full subtractor namely difference and borrow.


project.name
0 Stars     33 Views

Full subtractor

Full subtractor

I 'twas inspired by someone who made a half-subtractor, so I made a full one!


project.name
3 Stars     307 Views

Adder subtractor Circuit detail explanation

Adder subtractor Circuit detail explanation

Circuit Verse should be used only to create the project – online simulator https://circuitverse.org/simulator


All screenshots should include clear evidence for the student names and the date and time taken.

 


Start building the 4-bit adder subtractor circuit from the half adder until you reach the final circuit results.

  1. Build the 1-bit half adder circuit and convert it into symbol (block).

  2. Build the 1-bit full adder circuit and convert it into symbol (block).

  3. Build the 4-bit adder circuit and convert it into symbol (block).

  4. Build the 4-bit adder subtractor and convert it into symbol (block).

  5. Build the final circuit 






  1. Build the 1-bit half adder circuit and convert it into symbol (block).  

Write a detailed explanation about the full adders.

Insert your screenshot and the explanation here

I want to sum 2 binary digits (A,B) and the sum of 2 binary numbers needs (at most) 2 output digits;

so from truth table:

A

B

Sum

Carry

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

Sum:    S = (A.B’) + (A’.B) = A⨁ B

Carry:  C = A.B 



  1. Build the 1-bit full adder circuit and convert it into symbol (block).

Write a detailed explanation about the full adders.

Insert your screenshot and the explanation here

I want to sum 3 binary digits (X  ,Y , Cin) and the sum of 3 binary numbers needs (at most) 2 output digits (S , Cout).


X

Y

Cin

Sum

Carry

0

0

0

0

0

0

0

1

1

0

0

1

0

1

0

0

1

1

0

1

1

0

0

1

0

1

0

1

0

1

1

1

0

0

1

1

1

1

1

1

Sum = (X’ .Y’ .Cin) + (X’ .Y .Cin’) + (X .Y’ .Cin’) + (X .Y .Cin)

= X’ .((Y’ .Cin) + (Y .Cin’))  +  X .((Y’ .Cin’) + (Y .Cin))

= X’ .(Y⨁ Cin)  +  X .(Y⨁ Cin)’

= X ⨁ Y ⨁ Cin


Carry = (X’ .Y .Cin) + (X .Y’ .Cin) + (X .Y .Cin’) + (X .Y .Cin)

= Cin .(X⨁ Y)  + X .Y


since: Sum [from Full Adder (F.A.)] = X ⨁ Y ⨁ Cin

     = Sum1 [from Half Adder (H.A.)]   ⨁  Cin

Carry [from Full Adder (F.A.)] = X .Y +  Cin .(X⨁ Y)

  = Carry1 [from Half Adder (H.A.)] +  Cin .(X⨁ Y)


I can use 1 Half Adder to get [Sum1 from H.A. = X⨁ Y] and [Carry1 from H.A. = X.Y]

then I can use anther 1 Half Adder with (first Sum form H.A.  &  Cin) to get:

===>  Sum =[(Sum1 from H.A.) ⨁ Cin] = X ⨁ Y ⨁ Cin   <=== that’s the final Sum

and Carry2 [from second Half Adder (H.A.)] = Cin .(X⨁ Y)


If I passed the two Carry outputs (Carry1 & Carry2) through OR gate; I will get the final Carry: 

===>   final Carry = Carry1 + Carry2 =  X .Y + Cin .(X⨁ Y)   <=== that’s the final Carry


So, we can use 2 H.A. & OR gate to construct Full Adder. 



  1. Build the 4-bit adder circuit and convert it into symbol (block).  

Write a detailed explanation about how it works.

Insert your screenshot and the explanation here


since Half Adder Circuit (H.A.) can sum 2 digits

since Full Adder Circuit (F.A.) can sum 3 digits at once

It’s generally used Full Adder (F.A.) Circuits to sum 2 digits (1-digit from input x & 1-digit from input y) and add to them the carry (in the third input digit) from previous sum operation.

Ofcourse first 1-bit adder doesn’t need 3 input digits (because of there is no Carry);

So I used H.A. Circuit in first 1-bit Adder.





  1. Build the 4-bit adder subtractor and convert it into symbol (block).  

Write a detailed explanation about how it works.

Insert your screenshot and the explanation here

It’s preferred to subtract binary numbers (Z= X - Y) using the 2’s complement method; Which says that we find the 1’s complement to the -ve number (Y) and then add 1 to it;

After that we can use the new input of Y to sum it normally with X using a 4-bit Adder Circuit.


⇒ The complement of every digit of Y = Y’    ⇒ Y’ = {y0’ , y1’ , y2’ , y3’}

so every digit of Y enters on NOT gate to become Y’

⇒ Then add 1 (as a carry) to the Sum of first 1-bit Full Adder(F.A.)

∴The output Z = X - Y [but X must be >= Y]




  1. Build the final circuit 

  • Include screenshots with 4 different random examples and explain each one:

  • 2 addition

  • 2 subtraction

  • Write detailed explanation about how it works and how you did it.


Insert your screenshots and the explanation here


HOW I DID THIS CIRCUIT:

The Circuit works in 2 options. When I keep [selector = 0] the Circuit is a 4-bit Adder  and when I keep [selector = 1] the circuit is a 4-bit Subtractor.

∵The difference between 4-bit adder & 4-bit subtractor is in

1)the input Y (which is converted to Y’ in a 4-bit Subtractor)

2)& the third input digit in the first bit Full adder.

∴For input Y problem:

we need to find the equation that converts Y to Y’ (the 1’s complement) when the [selector = 1]. (i’ll use y0 digit to explain on)

selector

y0

f(y0)

0

0

0

0

1

1

1

0

1

1

1

0

f(y0) = selector ⨁ y0

⇒ ∴the problem of Y is solved when we connect every digit of Y with selector using X-OR gate.

∴For the problem of the third input digit in the first 1-bit Full adder:

we need to keep [the third input digit = 0] when the wanted operation is sum (selector=0) and keep [third input digit = 1] when the operation is subtraction (selector=1)

⇒ ∴ The third input digit in first bit Full adder = selector


Screenshot 1

When the input X=(0101) :{x3=0  , x2=1  , x1=0  , x0=1}

& when the input Y=(0111) : {y3=0  , y2=1  , y1=1  , y0=1}

∵ selector = 0 ∴ The operation is summing (Z = X + Y)

∴ Z0 = sum of three input digits (x0 , y0 , Cin) 

Z0= x0 + y0 + selector = 1 + 1 + 0    = 0  [& 1-carried to next bit Full Adder]

Z1= x1 + y1 + Cin = 0 + 1 + 1(carry)= 0 [& 1-carried to next bit Full Adder]

Z2= x2 + y2 + Cin = 1 + 1 + 1(carry)= 1 [& 1-carried to next bit Full Adder]

Z3= x3 + y3 + Cin = 0 + 0 + 1(carry)= 1 [& no carry]

Z4= last carry = 0

 ∴  Z = 01100



Screenshot 2

When the input X=(1111)     :{x3= 1   ,x2= 1   ,x1= 1   ,x0= 1}

& when the input Y=(1111) : {y3= 1   ,y2= 1   ,y1= 1   ,y0= 1}

∵ selector = 0 ∴ The operation is summing (Z = X + Y)

∴ Z0 = sum of three input digits (x0 , y0 , Cin) 

Z0= x0 + y0 + Cin = 1 + 1 + selector = 0  [& 1-carried to next bit Full Adder]

Z1= x1 + y1 + Cin = 1 + 1 + 1(carry) = 1 [& 1-carried to next bit Full Adder]

Z2= x2 + y2 + Cin = 1 + 1 + 1(carry) = 1 [& 1-carried to next bit Full Adder]

Z3= x3 + y3 + Cin = 1 + 1 + 1(carry) = 1 [& 1-carried to next bit Full Adder]

Z4= last carry = 1

 ∴  Z = 11110



Screenshot 3

When the input X=(1111)     :{x3= 1   ,x2= 1   ,x1= 1   ,x0= 1}

& when the input Y=(0101) : {y3= 0   ,y2= 1   ,y1= 0   ,y0= 1}

∵ selector = 1 ∴ The operation is subtract (Z = X - Y)

the circuit Subtracts using 2’s complement method:

∴ 1’s complement of Y = Y’ = 1010:  {y3’= 1   ,y2’= 0   ,y1’= 1   ,y0’= 0}


∴ Z0 = sum of three input digits (x0 , y0’ , Cin) 

Z0= x0 + y0’ + Cin = 1 + 0 + selector = 0  [& 1-carried to next bit Full Adder]

Z1= x1 + y1’ + Cin = 1 + 1 + 1(carry) = 1 [& 1-carried to next bit Full Adder]

Z2= x2 + y2’ + Cin = 1 + 0 + 1(carry) = 0 [& 1-carried to next bit Full Adder]

Z3= x3 + y3’ + Cin = 1 + 1 + 1(carry) = 1 [& 1-carried to next bit Full Adder]

Z4= last carry = 1 (note: we ignore last bit (Z4) in subtract operation & it have to = 1)

when [Z4 = 1] that means  [X>=Y] 

 ∴  Z = 1010


Screenshot 4

When the input X=(0111)     :{x3= 0   ,x2= 1   ,x1= 1   ,x0= 1}

& when the input Y=(0111) : {y3= 0   ,y2= 1   ,y1= 1   ,y0= 1}

∵ selector = 1 ∴ The operation is subtract (Z = X - Y)

the circuit Subtracts using 2’s complement method:

∴ 1’s complement of Y = Y’ = 1000:  {y3’= 1   ,y2’= 0   ,y1’= 0   ,y0’= 0}


∴ Z0 = sum of three input digits (x0 , y0’ , Cin) 

Z0= x0 + y0’ + Cin = 1 + 0 + 1(selector)= 0  [& 1-carried to next bit Full Adder]

Z1= x1 + y1’ + Cin = 1 + 0 + 1(carry)     = 0 [& 1-carried to next bit Full Adder]

Z2= x2 + y2’ + Cin = 1 + 0 + 1(carry)     = 0 [& 1-carried to next bit Full Adder]

Z3= x3 + y3’ + Cin = 0 + 1 + 1(carry)     = 0 [& 1-carried to next bit Full Adder]

Z4= last carry = 1 (note: we ignore last bit (Z4) in subtract operation & it have to = 1)

when [Z4 = 1] that means  [X>=Y] 

 ∴  Z = 0000




project.name
5 Stars     113 Views

This is the CTH-10 CPU. By CrEePeRz24321. (most updated version of the CTH Series) This uses all binary to operate. First click on Power to start. Turn Op to 1 and double click the RAM. Then type in the Op code you want. Only put inputs and read outputs of the User Interface. Wait until the Red light turns Green then start. If you want to change operations, then turn Op to 1 and double click the RAM. Then type in the Op code you want. (If you use full screen, and it keeps on kicking you out when you type, click full screen and then look to the bottom right and press + or - and don't touch the full screen after that unless the RAM input kicks you out)

0 is No Operation - Inputs unavailable

1 is RAM - write the address into In1, write the number you want to store into In2 and press Write.

2 is ADD - write the first digit into In1, write the second digit into In2

3 is Subtract - write the first digit into In1, write the second digit into In2

4 is Counter - Inputs unavailable

5 is AND Gate - write the first digit into In1, write the second digit into In2

6 is a Clock - Inputs unavailable

7 is Accessing the ROM - Inputs unavailable

8 is Binary to Decimal converter

9 is Random Number - Inputs unavailable

10 is Not Gate - write the converting digit into In1

11 is Shift Right* - write the converting digit into In1, write the shift number into In2

12 is Shift Left* - write the converting digit into In1, write the shift number into In2

13 is Multiply - write the first digit into In1, write the second digit into In2

14 is Divide - write the first digit into In1, write the second digit into In2**

HALT is to halt operation


*when using shift the first 3 digits of Out will be nonfunctional

**when using divide the first 4 digits away from the CPU are remainders and the last 4 digits closest to the CPU are quotients.

(There is also a Computer version that doesn't get updated much.)


project.name
1 Stars     55 Views

This is the CTH-10 CPU. This uses all binary to operate. First click on Power to start. Turn Op to 1 and double click the RAM. Then type in the Op code you want. Only put inputs and read outputs of the User Interface. Wait until the Red light turns Green then start. If you want to change operations, then turn Op to 1 and double click the RAM. Then type in the Op code you want. (If you use full screen, and it keeps on kicking you out when you type, click full screen and then look to the bottom right and press + or - and don't touch the full screen after that unless the RAM input kicks you out)

0 is No Operation - Inputs unavailable

1 is RAM - write the address into In1, write the number you want to store into In2 and press Write.

2 is ADD - write the first digit into In1, write the second digit into In2

3 is Subtract - write the first digit into In1, write the second digit into In2

4 is Counter - Inputs unavailable

5 is AND Gate - write the first digit into In1, write the second digit into In2

6 is a Clock - Inputs unavailable

7 is Accessing the ROM - Inputs unavailable

8 is Binary to Decimal converter

9 is Random Number - Inputs unavailable

10 is Not Gate - write the converting digit into In1

11 is Shift Right* - write the converting digit into In1, write the shift number into In2

12 is Shift Left* - write the converting digit into In1, write the shift number into In2

13 is Multiply - write the first digit into In1, write the second digit into In2

HALT is to halt operation


*when using shift the first 3 digits of Out will be nonfunctional


project.name
0 Stars     15 Views

Half Subtractor

Half Subtractor

project.name
0 Stars     14 Views

Full Subtractor

Full Subtractor

project.name
0 Stars     4 Views