Week 4
Counters and Shift Registers
COS10004 Computer Systems · Lecture 3: Counters and Shift Registers
Building a computer? Things we need:
memory within Fast memory (RAM) Persistent the CPU – program and data memory
= banks (Disks)
of flip- flops Instruction Pointer Central processing Motherboard (counter) unit (CPU) registers IP full adder + Screen shift ALU operations Keyboard
Input / Output accel
2 Channels cards Mouse
REGISTERS
Fast RAM (uses transistor states)
- Uses clocked flip-flops
- Inside the CPU chip
- Limited number of them (cause it's hardware)
- Let's build one...
D-TYPE FLIP-FLOP
- Set data to high – Q goes high on next clock pulse. Stays high.
- Set presets Q to high when pulled high
- Reset clears Q when pulled high
- In Logisim we can also leave PR' and CLR' disconnected.
D-FLIP-FLOPS AS A REGISTER OR LATCH
A register (many bits) or latch (usually one bit) can be made Input before the clock Information 1 0 1 1 up from a series of D-Flip-Flops latched driven by a common clock. now D D D D
The transfer from the D side to the Clock Q Q Q Q Q side for all D flip flops occurs 1 0 1 1 simultaneously as this clock Output after the clock changes. This arrangement is found in CPU registers http://www.electronics-tutorials.ws/sequential/seq_4.html
6 COS10004 Computer Systems 6
8 BIT REGISTER
little-endian
Little Endian
BIG ENDIAN AND LITTLE ENDIAN DATA FORMAT
- Technical definition for the order of bytes:
- Big Endian:
- The most signficant byte resides in the smallest memory address
- Little Endian:
- The least significant byte resides in the smallest memory address
BIT ENDIANNESS
- Bits generally don’t have an address, so definitions refer to the positional order of bits
- Big Endian:
- The most significant bit comes first
- Little Endian:
- The least significant bit comes first
- This matters for interpreting the value of a bit string (especially if bits are received as a serial stream!)
- Eg What is 1011 in decimal?
- 1110 (Big endian), or 1310 (Little endian) 9
8 BIT REGISTER
little-endian
Little Endian
Big Endian
SUMMARY
- D Flip Flops generally form the building blocks of registers
- Registers:
- Allow us to store bit strings that represent data
- Reside close to the CPU, allowing fast and easy access
- Bit Endianness determines how we interpret bit strings:
- Big Endian: most significant bit comes first
- Little Endian: least significant bit comes first
- Next Lecture: ripple counters with JK Flip Flops