Κυριακή, 22 Δεκεμβρίου 2013

Half Adders, Full Adders, Ripple Carry Adders (WIKI BOOKS)


Half Adder

Consider adding two binary numbers together:
Binary Addition.svg
We see that the bit in the "two's" column is generated when the addition carried over. A half-adder is a circuit which adds two bits together and outputs the sum of those two bits. The half-adder has two outputs: sum and carry. Sum represents the remainder of the integer division A+B/2, while carry is the result. This can be expressed as follows:
  • \mbox{S} = A \oplus B
  • \mbox{C} = AB\,
Half Adder.svg

A B A+B
S C
0 0 0 0 0
0 1 1 1 0
1 0 1 1 0
1 1 2 0 1

Full Adder

Half-adders have a major limitation in that they cannot accept a carry bit from a previous stage, meaning that they cannot be chained together to add multi-bit numbers. However, the two output bits of a half-adder can also represent the result A+B=3 as sum and carry both being high.
As such, the full-adder can accept three bits as an input. Commonly, one bit is referred to as the carry-in bit. Full adders can be cascaded to produce adders of any number of bits by daisy-chaining the carry of one output to the input of the next.
Full Adder.svg

A B Cin A+B+Cin
S Cout
0 0 0 0 0 0
0 0 1 1 1 0
0 1 0 1 1 0
0 1 1 2 0 1
1 0 0 1 1 0
1 0 1 2 0 1
1 1 0 2 0 1
1 1 1 3 1 1
The full-adder is usually shown as a single unit. The sum output is usually on the bottom on the block, and the carry-out output is on the left, so the devices can be chained together, most significant bit leftmost:
Full Adder Block.svg

Ripple-Carry Adder

A ripple carry adder is simple several full adders connected in a series so that the carry must propagate through every full adder before the addition is complete. Ripple carry adders require the least amount of hardware of all adders, but they are the slowest.
The following diagram shows a four-bit adder, which adds the numbers A[3:0] and B[3:0], as well as a carry input, together to produce S[3:0] and the carry output.
4-Bit Ripple Adder.svg

Propagation Delay in Full Adders

Full-Adder Propagation Delay.svg
Real logic gates do not react instantaneously to the inputs, and therefore digital circuits have a maximum speed. Usually, the delay through a digital circuit is measured in gate-delays, as this allows the delay of a design to be calculated for different devices. AND and OR gates have a nominal delay of 1 gate-delay, and XOR gates have a delay of 2, because they are really made up of a combination of ANDs and ORs.
A full adder block has the following worst case propagation delays:
  • From Ai or Bi to Ci+1: 4 gate-delays (XOR → AND → OR)
  • From Ai or Bi to Si: 4 gate-delays (XOR → XOR)
  • From Ci to Ci+1: 2 gate-delays (AND → OR)
  • From Ci to Si: 2 gate-delays (XOR)
Because the carry-out of one stage is the next's input, the worst case propagation delay is then:
  • 4 gate-delays from generating the first carry signal (A0/B0C1).
  • 2 gate-delays per intermediate stage (CiCi+1).
  • 2 gate-delays at the last stage to produce both the sum and carry-out outputs (Cn-1Cn and Sn-1).
So for an n-bit adder, we have a total propagation delay, tp of:
t_{p} = 4+2(n-2)+2 = 2n+2
This is linear in n, and for a 32-bit number, would take 65 cycles to complete the calculation. This is rather slow, and restricts the word length in our device somewhat. We would like to find ways to speed it up.

Carry-Lookahead Adder

A fast method of adding numbers is called carry-lookahead. This method doesn't require the carry signal to propagate stage by stage, causing a bottleneck. Instead it uses additional logic to expedite the propagation and generation of carry information, allowing fast addition at the expense of more hardware requirements.
In a ripple adder, each stage compares the carry-in signal, Ci, with the inputs Ai and Bi and generates a carry-out signal Ci+1 accordingly. In a carry-lookahed adder, we define two new function.
The generate function, Gi, indicates whether that stage causes a carry-out signal Ci to be generated if no carry-in signal exists. This occurs if both the addends contain a 1 in that bit:
G_i = A_i \cdot B_i\,
The propagate function, Pi, indicates whether a carry-in to the stage is passed to the carry-out for the stage. This occurs if either the addends have a 1 in that bit:
P_i = A_i + B_i\,
Note that both these values can be calculated from the inputs in a constant time of a single gate delay. Now, the carry-out from a stage occurs if that stage generates a carry (Gi = 1) or there is a carry-in and the stage propagates the carry (Pi·Ci = 1):
C_{i+1} = A_iB_i + A_i C_i + B_i C_i\,
C_{i+1} = A_iB_i + (A_i + B_i)C_i\,
C_{i+1} = G_i + P_i C_i\,
The table below summaries this:
Ai Bi Ci
Gi Pi Ci+1
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 0 1 0
0 1 1 0 1 1
1 0 0 0 1 0
1 0 1 0 1 1
1 1 0 1 1 1
1 1 1 1 1 1
We can extend the expression for the carry-out by substituting the expression for the carry-out of the previous stage:
c_{i+1} = G_i + P_i c_i\,
c_{i+1} = G_i + P_i \left(  G_{i-1} + P_{i-1} c_{i-1} \right) \,
c_{i+1} = G_i + P_iG_{i-1} + P_i P_{i-1} \left(  G_{i-2} + P_{i-2} c_{i-2} \right) \,
c_{i+1} = \quad \vdots
c_{i+1} = G_i + P_iG_{i-1} + P_i P_{i-1} G_{i-2} + P_i P_{i-1} P_{i-2} G_{i-3} + \ldots + P_i P_{i-1}
 \cdots P_1 P_0 c_0\,
Note that this does not require the carry-out signals from the previous stages, so we don't have to wait for changes to ripple through the circuit. In fact, a given stage's carry signal can be computed once the propagate and generate signals are ready with only two more gate delays (one AND and one OR). Thus the carry-out for a given stage can be calculated in constant time, and therefore so can the sum.
Operation Required Data Gate Delays
Produce stage generate and propagate signals Addends (a and b) 1
Produce stage carry-out signals, C1 to Cn P and G signals, and C0 2
Produce sum result, S Carry signals and addends 3
Total 6
The S, P, and G signals are all generated by a circuit called a "partial full adder" (PFA), which is similar to a full adder.
Partial Full-Adder.svg
For a slightly smaller circuit, the propagate signal can be taken as the output of the first XOR gate instead of using a dedicated OR gate, because if both A and B are asserted, the generate signal will force a carry. However, this simplifiaction means that the propagate signal will take two gate delays to produce, rather than just one.
A carry lookahead adder then contains n PFAs and the logic to produce carries from the stage propagate and generate signals:
4-Bit CLA Adder.svg
Two numbers can therefore be added in constant time, O(1), of just 6 gate delays, regardless of the length, n of the numbers. However, this requires AND and OR gates with up to n inputs. If logic gates are available with a limited number of inputs, trees will need to be constructed to compute these, and the overall computation time is logarithmic, O(ln(n)), which is still much better than the linear time for ripple adders.

Cascading Carry-Lookahead Adders

A basic carry-lookahead adder is very fast but has the disadvantage that it takes a very large amount of logic hardware to implement. In fact, the amount of hardware needed is approximately quadratic with n, and begins to get very complicated for n greater than 4.
Due to this, most CLAs are constructed out of "blocks" comprising 4-bit CLAs, which are in turn cascaded to produce a larger CLA.

Carry-Save Adder

This section of the Digital Circuits wikibook is a stub. You can help by expanding this section. If you add something, list yourself as a Contributor.

A carry-save adder is a kind of adder with low propagation delay (critical path), but instead of adding two input numbers to a single sum output, it adds three input numbers to an output pair of numbers. When its two outputs are then summed by a traditional carry-lookahead or ripple-carry adder, we get the sum of all three inputs.
When adding three or more numbers together, a sequence of carry-save adders terminated by a single carry-lookahead adder provides much better propagation delays than a sequence of carry-lookahead adders. In particular, the propagation delay of a carry-save adder is not affected by the width of the vectors being added.
Carry-save adders are really completely parallel arrays of full adder circuits, with the each bit of the three input vectors loaded into each full adder's A, B, and Cin inputs. Each full adder's output S is connected to the corresponding output bit of one output, and its output Cout is connected to the next higher output bit of the second output; the lowest bit of the second output is fed directly from the carry-save's Cin input.
Read more...

Σάββατο, 12 Οκτωβρίου 2013

ΑΠΛΟΠΟΙΗΣΗΜΕ ΠΙΝΑΚΕΣ KARNAUGH

Read more...

Λογικη Σχεδιαση/Karnaugh

Karnaugh Map Explorer 2.0
Two Variables Three Variables Four Variables Allow Don't Cares

Click on the buttons in the Truth Table or in the Karnaugh Map to change the value. Mouse over minterm components of the function F to see a representation of the minterm in the Karnaugh Map.
1.html Read more...

Κυριακή, 6 Οκτωβρίου 2013

Linux Terminal Command Reference

 Linux Terminal Command Reference





System Info

date – Show the current date and time
cal – Show this month's calendar
uptime – Show current uptime
w – Display who is online
whoami – Who you are logged in as
finger user – Display information about user
uname -a – Show kernel information
cat /proc/cpuinfo – CPU information
cat /proc/meminfo – Memory information
df – Show disk usage
du – Show directory space usage
free – Show memory and swap usage

Keyboard Shortcuts

Enter – Run the command
Up Arrow – Show the previous command
Ctrl + R – Allows you to type a part of the command you're looking for and finds it
Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background
Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L – Clear the screen
command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
!! – Repeats the last command
command  !$ – Repeats the last argument of the previous command
Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command
Ctrl + A – Return to the start of the command you're typing
Ctrl + E – Go to the end of the command you're typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
Ctrl + W – Delete the word / argument left of the cursor in the current line
Ctrl + D – Log out of current session, similar to exit

Learn the Commands

apropos subject – List manual pages for subject
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf  – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes
whereis app – Show possible locations of app
which app – Show which app will be run by default; it shows the full path

Searching

grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name ”*filename*” – Starting with the root directory, look for the file containing the string filename
locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file  called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind

File Permissions

chmod octal file – Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 – read (r), 2 – write (w), 1 – execute (x)
Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world
For more options, see man chmod.

File Commands

ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files
cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory
rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)
cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn't exist
cp file /home/dirname – Copy the file called filename to the /home/dirname directory
mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2
ln -s file link – Create symbolic link link to file
touch file – Create or update file
cat > file – Places standard input into file
cat file – Display the file called file
more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines

Compression

tar cf file.tar files – Create a tar named file.tar containing files
tar xf file.tar – Extract the files from file.tar
tar czf file.tar.gz files – Create a tar with Gzip compression
tar xzf file.tar.gz – Extract a tar using Gzip
tar cjf file.tar.bz2 – Create a tar with Bzip2 compression
tar xjf file.tar.bz2 – Extract a tar using Bzip2
gzip file – Compresses file and renames it to file.gz
gzip -d file.gz – Decompresses file.gz back to file

Printing

/etc/rc.d/init.d/lpd start – Start the print daemon
/etc/rc.d/init.d/lpd stop – Stop the print daemon
/etc/rc.d/init.d/lpd status – Display status of the print daemon
lpq – Display jobs in print queue
lprm – Remove jobs from queue
lpr – Print a file
lpc – Printer control tool
man subject | lpr – Print the manual page called subject as plain text
man -t subject | lpr – Print the manual page called subject as Postscript output
printtool – Start X printer setup interface

Network

ifconfig – List IP addresses for all devices on the local machine
ping host – Ping host and output results
whois domain – Get whois information for domain
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
wget file – Download file
wget -c file – Continue a stopped download

SSH

ssh user@host – Connect to host as user
ssh -p port user@host – Connect to host on port port as user
ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login

User Administration

adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user

Process Management

ps – Display your currently active processes
top – Display all running processes
kill pid – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground

Installation from source

./configure
make
make install
dpkg -i pkg.deb – install a DEB package (Debian / Ubuntu / Linux Mint)
rpm -Uvh pkg.rpm – install a RPM package (Red Hat / Fedora)

Stopping & Starting

shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system
Read more...

Κυριακή, 26 Μαΐου 2013

PC BUSTERS ARDUINO WEB CONTROL OUTPUT

processing code

#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

int LEDpin = 4;
String readString = String(30);
String state = String(3);

void setup()
{
  Serial.begin(9600);
  while (!Serial);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  //Sets the LEDpin as an output
  pinMode(LEDpin,OUTPUT);

  digitalWrite(LEDpin,LOW);
  state = "OFF";
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply

        if (readString.length() < 30) {
          readString.concat(c);
        }

        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          int LED = readString.indexOf("LED=");


          if (readString.substring(LED,LED+6) == "LED=ON") {
            digitalWrite(LEDpin,HIGH);
            delay(1000);
            digitalWrite(LEDpin,LOW);
            delay(100);
            digitalWrite(LEDpin,HIGH);
            state = "ON";
          }
          else if (readString.substring(LED,LED+7) == "LED=OFF") {
            digitalWrite(LEDpin,LOW);
            state = "OFF";
          } 
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.print("<b>LED CONTROL</b>");
          client.print("<br><br>");
          client.print("<br><br>");
          client.print("LED is ");
          client.print(state);
          client.print("<br><br>");
          client.print(bitRead(PORTD,4));//Reads bit 4 of register PORTD which contains the current state (high/low) of pin 4
          client.print("<br><br>");
          if (bitRead(PORTD,4)==1){
            client.print(" Pin 4 is High as fuck");
            client.print("<br><br>");
            Serial.println(state);
          }
          else
          {
            client.print("Pin 4 is DOWN");
            client.print("<br><br>");
            Serial.println(state);
          }

          if (state == "ON") {
            client.print("<body style=background-color:green>");
            client.println("<form method=get name=LED><input type=submit name=LED value=OFF>  <b>LED ON</b><form>");
            //client.println("<a href="./?LED=F">Turn Off<a>");
          }
          else {
            client.print("<body style=background-color:red>");
            client.println("<form method=get name=LED><input type=submit name=LED value=ON> <b>LED OFF</b><form>");
            //client.println("<a href="./?LED=ON">Turn On<a>");
          }
          client.print("<br><br>");
          client.print("<br><br>");
          client.print("<b>PC BUSTERS</b>   Web Control Led Project 2013");
          break;
        }

        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    readString = "";
    // close the connection:
    client.stop();
  }
}
Read more...

Τετάρτη, 20 Φεβρουαρίου 2013

ΣΕΛΙΔΕΣ ΜΑΘΗΜΑΤΙΚΩΝ ΟΡΙΑ ΣΥΝΑΡΤΗΣΕΩΝ

ΜΑΘΗΜΑΤΙΚΑ ΚΑΤΕΥΘΥΝΣΗΣ  ΜΑΘΗΜΑΤΙΚΑ ΓΕΝ. ΠΑΙΔΕΙΑΣ  
ΜΙΓΑΔΙΚΟΙ
---
ΣΥΝΑΡΤΗΣΕΙΣ
---
ΟΡΙΑ
---
ΣΥΝΕΧΕΙΑ
    6. Ασκήσεις επανάληψης - όρια, συνέχεια
---
ΠΑΡΑΓΩΓΟΙ-ΜΕΡΟΣ 1ο
---
ΠΑΡΑΓΩΓΟΙ-ΜΕΡΟΣ 2ο
    2. Ασκήσεις στο θεώρημα Rolle
    3. Θεώρημα μέσης τιμής
    4. Ασκήσεις στο θεώρημα μέσης τιμής
    5. Σταθερές συναρτήσεις
    6. Ασκήσεις στις σταθερές συναρτήσεις
    7. Μονοτονία
    8. Ασκήσεις μονοτονίας
    9. Ακρότατα-θεώρημα Fermat
  10. Ασκήσεις στο θ.Fermat
  11. Ασκήσεις στα ακρότατα
  12. Κυρτότητα-Σημεία καμπής
  13. Ασκήσεις στην κυρτότητα-Σ. καμπής
  14. Ασύμπτωτες-Κανόνας του De l' Hospital
  15. Ασκήσεις στις ασύμπτωτες-De l' Hospital
  16. Μελέτη συνάρτησης
  17. Ερωτήσεις-Παράγωγοι 2ο μέρος
  18. Ασκήσεις επανάληψης στις παραγώγους
  19. Θέματα πανελληνίων έως και παράγωγοι
---
ΟΛΟΚΛΗΡΩΜΑΤΑ
Στην εξεταστέα ύλη του σχ. έτους 11-12 οι ενότητες 
1, 2, 3, 4  αντικαθίστανται με τις ενότητες  1α, 1β
  12. Ερωτήσεις - Ολοκληρώματα
  13. Επαναληπτικές ασκήσεις-ολοκληρώματα
---
ΓΕΝΙΚΑ ΘΕΜΑΤΑ
ΣΥΝΑΡΤΗΣΕΙΣ-ΟΡΙΟ-ΣΥΝΕΧΕΙΑ
    1. Συναρτήσεις
---
ΠΑΡΑΓΩΓΟΣ
---
ΣΤΑΤΙΣΤΙΚΗ
---
ΠΙΘΑΝΟΤΗΤΕΣ
---
ΓΕΝΙΚΑ ΘΕΜΑΤΑ
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---


Read more...