ECE224 Notes
ECE224 Notes
Computer Technology
Hardware: mechanical or electronic components of a computer
Software: programs or other operating information used by a computer
Hardware/Software Co-design: task of simultaneously designing hardware and software
components in a combined system
Microprocessor: consists of only a CPU, no main memory or built-in support for I/O devices
o General-purpose CPU that can include multiple processor cores
o Delivers high performance
o Requires (off-chip) I/O devices to implement a complete computer
Microcontroller: a complete, single-chip computer that consists of a CPU, memory, and some
I/O devices
o Specialized CPU to control a mechanical or electronical system
o Built-in memory storage
o Small and cost-efficient
o Specialized, built-in interface support for devices (e.g. parallel, analog, serial)
o Designed to meet needs of wide range of applications
System-on-a-Chip (SoC): a user-designed, fully functional system implemented on a single chip;
may contain CPU, memory, I/O devices, and other digital logic
o Typically contains:
Similar functionality to a microprocessor or microcontroller, implemented as
either hardware or software
Communication ports
Volatile storage (e.g. RAM)
Non-volatile storage (e.g. ROM)
Other components such as timers, parallel interfaces, analog to digital
converters, etc.
Programmable Logic Device (PLD): a digital logic chip that permits configuring and
interconnecting internal logic blocks to form a custom digital circuit; can be rewired using
primitive building blocks to implement custom circuits
o Primitive building blocks: flip-flops, multiplexers, LUTs, adders, multipliers, and RAM
blocks
o Examples: SRAM, EEPROM, NOR Flash
o PLDs can be one-time programmable vs. reconfigurable, as well as contain in-system
programmability vs. external programming hardware
System-on-a-Programmable-Chip (SoPC): a SoC that is implemented using a PLD
o Advantages over SoCs:
Flexible
Upgradable
o Disadvantages over SoCs:
Can be slower
More expensive in large quantities
Synchronization Mechanisms
Blind cycle: software waits for an amount of time, then acts on data regardless whether or not
the device is ready
Occasional polling: device status is checked at convenience of the designer
Periodic polling: device is checked after a set amount of time, repeating until device is done –
generally uses a timer interrupt
Tight polling loop (busy waiting): software continuously checks I/O status until device is ready
Interrupt handling: devices generates hardware interrupts to request service
Blind cycle, occasional polling, and periodic polling are CPU-oriented – device waits for CPU to
initiate synchronization
Tight polling and interrupt handling are device-oriented – devices demands service, reducing
device latency
Interrupt Synchronization
1. Device requests interrupt to CPU
2. CPU completes execution of current instruction
3. CPU suspends execution of main program
4. Interrupts may be disabled
5. Internal registers saved to stack
6. Device may be acknowledged
7. ISR is selected
8. ISR is executed
9. Registers are restored
10. Interrupts are enabled (if disabled)
11. CPU resumes execution of main program
Each request is associated with an interrupt vector, which has a fixed priority
ISR at vector address is executed
Device Drivers
Device drivers: software included with a particular device
Includes:
o Data structures
Variables to access device interface registers
Variables to track state of device
Data buffers
o Initialization functions
Device initialization
Synchronization initialization
Driver variables initialization
o I/O functions
o ISRs
Section IV: Synchronization, Data Generation, and Data
Transfer
Generally, during interface communication, the two sides of the interface (producer and
consumer) likely have different views of time and perform independent tasks except when
communicating with each other
Producer: hardware/software component that’s responsible for producing data and/or events
Consumer: hardware/software component that’s responsible for consuming data and/or events
Data: state information transferred from producer to consumer
Event: control information transferred from producer to consumer to indicate the occurrence of
an activity
Producer/Consumer Communication
Event only: event occurs and the occurrence is transferred from producer to consumer
Event and data: an event occurs, so the event and some associated data is transferred to
consumer
Data only: a data value is produced but the consumer isn’t notified of the data; consumer can
read data at any time
Synchronization Hierarchy
Synchronization is considered at several levels:
1. Data generation: how is data creation controlled, started/stopped?
2. Data notification/Initiation of transfer: once producer has data, how does it notify the
consumer? Does the consumer request the data?
3. Data transfer: once producer has data and consumer is ready, how does
synchronization of data transfer handled?
Synchronization: interaction required to make two entities with different views of time interact
o Active synchronization: one of the entities is able to force a change in the operational
characteristics of the other
o Passive synchronization: one of the entities signals a request for service; the other is
not required to respond
Synchronization needs
o Relationship between/amongst entities (how many, master/slave vs. equal entities)
o Level of required service
Active, demand-oriented: event must be serviced
Passive, request-oriented: event may be serviced
Data Generation
Creation of data can be initiated by both the producer and consumer, but requires action by the
producer
Spontaneous sources: data is produced by the device, independent of the actions of the
consumer accepting it
Consumer sensitive sources: data is produced by the device, only after data is consumed by the
consumer (consumer acknowledges consumption)
Consumer responsive sources: data is produced by the device, only after requested by the
consumer
Notification/Initiation of Transfer
Consumer initiated scenarios: consumer requests data, data becomes/is ready, request is
completed
o Passive synchronization example: polling for a key press, and once it’s pressed, data is
consumed
o Active synchronization example: interrupt from printer to indicate that it’s ready for the
next item
Producer initiated scenarios: data is available, data is accepted by consumer, transfer is
completed
o Passive synchronization example: polling for printer to be ready for the next character,
and once it is ready, data transfer occurs
o Active synchronization example: keyboard sends interrupt to indicate it has the next
character for consumption
Data Transfer
Data transfer: exchange of information between two entities that may have different view of
time
Data transfer considerations:
o Data persistence: how long the data is valid for transferring between entities
o Time synchronization/clocking: how signals representing any data are enabled to make
a transfer happen
o Control signal: how control information is exchanged between communicating entities
Persistent data: information remains valid until consumer indicates that it has consumed it
o Requires feedback path
Transient data: information is made available to consumer, and only valid for a period of time
o Synchronized buses
Global initialization: set processor and I/O interface parameters once for overall system
operation
o Initializing vectored interrupt tables, specifying port directions, etc.
Transfer initialization: set processor and I/O interface parameters once per transfer to facilitate
a specific transfer
o Setting memory location to provide data for transfer, setting the block and track number
of disk transfer, etc.
Data transfer: synchronization before and after data transfer
Impact of Notification/Initiation
Assume data source is consumer sensitive, and that each block contains one data unit
Since ttransfer producer < ttransfer consumer, ttransfer (total transfer time) = ttransfer consumer
Transfer is consumer-initiated since ttransfer consumer starts before and ends after ttransfer producer
Block Read Transfers
Assume data source is consumer sensitive, and that each block contains two data units
t wait =
{ t sync −poll
t sync−inter +t interdata
(differs for polling and interrupts)
I/O devices can also be connected to a separate I/O bus that isn’t connected to memory
Memory
Memory connects to CPU through 1+ buses
Instructions and data are both stored in memory
o They can only be distinguished by context
Stored memory values are accessed using their memory addresses
Read Only Memory (ROM): contains sequences of instructions necessary to put processor in
start-up state, which can be the final state or a starting point to boot into a more functional OS
Random Access Memory (RAM): used to store values and programs that may change
There isn’t distinction between ROM and RAM addresses
Control Signals
Many operations are triggered by 1+ control signals
Control signals can be active high or active low triggered
o Active high: indicates certain condition when set to 1
o Active low: indicates certain condition when set to 0
Control signals can be rising or falling edge triggered
o Rising edge: changes from low to high voltage
o Falling edge: changes from high to low voltage
Clock Signals
Special signal that synchronizes 2+ devices
They are (rising or falling) edge-triggered
They are periodic, with a fixed duty cycle (ratio of high to low time)
System clock signals are typically periodic with duty cycles of ~50%
o Input signals are sampled at predictable times with respect to the system clock
o Output signals change at predictable times with respect to the system clock
Some clock signals aren’t periodic, like register clock signals, where active edges only occur
when needed to trigger an event
Multiphase clock signals have been proposed to increase synchronization opportunities
Truth table:
i o
0 0
1 1
Logic must be implemented to prevent active connections to both the power supply voltage and
ground at the same time
o Permanent: use passive pull-up or pull-down resistor to limit current flow in all possible
paths
o Temporary: disable device by turning off all its transistor-controlled connections to the
power source and ground
Open-Collector Output Driver
Truth table:
i o
0 0
1 Z
Truth table:
i e o
0 0 Z
1 0 Z
0 1 0
1 1 1
Device Selection
If a bus line has more than one possible driver, it must select devices to drive the bus
Explicit selection
o Selects unique device based on available bus signals
Address values
Arbitration signal
Timing signal
Event signal
o Used for general purpose buses
Implicit selection
o Resolves bus conflicts in predictable manner, using wired logic
Wired AND logic = 1 if all drivers output a 1
Wired OR logic = 1 if any driver outputs a 1
o Used for special applications (e.g. IRQ lines)
Address Decoding
Centralized vs. decentralized
o Centralized: system has centralized address and timing decoder to enable devices
o Decentralized: system embeds all address and timing decode logic into circuitry
Address aliasing
o Aliasing: portion of address bus signals can be ignored by the system
o No aliasing: all address bus signals are considered by the system
Bus Timing Example – Write Operation
Time A: CPU (bus master) puts address, data, and write signal onto the appropriate bus signals
Time B: Memory (bus slave) assumes valid bus signals
Time C: Memory (bus slave) stores data in appropriate register or memory location
Metastability
Metastability: when setup times or hold times are violated, because data changes during setup
or hold time
o Can never be completely eliminated from a computer system, since external inputs are
unpredictable
o Synchronization chains can reduce probability of metastable signals
o Write operation:
tSkew – Skew time: maximum difference in propagation times of signals that ideally occur
simultaneously
tM1/tM2 – Margin time: extra time reserved by designer to allow for unexpected variables in
performance, ensuring reliable operation
Skew
Sources of skew:
o Minor differences in propagation delays due to wire length
o Differences in logic gate delays
o Differences in rise and fall times due to capacitive effects
Master Edge
o CPU puts address on bus: tPA + tSkew
o tM1 until slave edge
Slave Edge
o Device is selected and retrieves data: tSelect + tAccess
o Device puts data on bus: tPD + tSkew
o tM2 until master edge
Master Edge
o tSetup before master edge
o tHold after master edge
Synchronous Bus Write – Timing Diagram
Master Edge
o CPU puts address and data on bus: tP (for both address and data to be valid) + tSkew
o tM1 until slave edge
Slave Edge
o Device is selected and stores data: tSelect + tStore
o tM2 until master edge
Master Edge
o tSetup before master edge
o tHold after master edge
Normal clock:
Register clock:
o Inverted so that data is clocked on rising edge
Functions:
o Synchronizes device with system
o Alters signal levels
o Encodes data
o Buffers data
Parallel interfaces help convert processing domain (operating in GHz–MHz) to device domain
(operating in Hz) – large time discrepancy
Driver Alternatives
Enable:
Clock 1:
Clock 2:
Explicit Bidirectional
Implicit Bidirectional
Explicit Direction Control using Passive Pull-up
Implicit Direction Control (Pseudo Bidirectional)
Data Characteristics
When two systems communicate, need to consider:
o Signal translation
o Synchronization
Data can be:
o Persistent: remains valid until consumer explicitly accepts data
o Transient: data will vanish if not read at the appropriate time
Data source may either inform or not inform receiver that data is present
Receiver may or may not request for new data when it is ready
Control Signalling
Two techniques to pass control information between two systems:
o In-band: some or all control information is passed the same way that data is transferred
o Out-of-band: control signalling is done with techniques that cannot be confused with
data, e.g. signals at frequency where data isn’t found, values that data will never be,
extra signal lines, etc.
Signalling of data changes:
o In-band: value of data line differing from previous value indicates that data has
changed; special value can be inserted in between consecutive values to indicate change
o Out-of-band: use an extra signal line to indicate that new data is available
Persistence of Data
Persistent data can be accepted at convenience of receiver; after data is received, source is
informed that data is no longer needed
Transient data must be accepted within a source-specified time limit after it signals its
availability; this can be done with a latch at the receiver
o What happens if consumption is too slow?
Error
Only keep first read value (discard new value)
Remember the new value
Error detection (ED): add sufficient redundant information at the data source so that at the data
destination, we can determine if the data has changed from the original
Error correction (EC): add sufficient redundant information at the data source to make it
possible to recover the original information
Error rate: the rate/probability of errors on a channel; e.g. 10-6 = one bit per million is an error
o Errors may or may not be correlated, meaning error in one bit increases likelihood of
error in next bit
number of non−data bits
Overhead:
total number of bits transferred
Parity
Most common first level of defense to detect single bit errors (C = 1)
Add 1 bit per B bits, so that B+1 bits always have:
o Even parity: even number of bits set to 1
o Odd parity: odd number of bits set to 1
Error is detected if data doesn’t have correct parity
Distance: minimum number of bits that must change to go from one code word to another code
word
o For parity bits, minimum distance between valid code words is 2
o To detect single bit errors, minimum distance of 2 is required
Example: Consider a 3-bit data word + 1 parity bit (bbbc); assume even parity
Hamming Code
Introduction
Consider 4 data bits ( B = 4)
Three overlapping sets (P, Q, R) are needed to construct the code word
o Each set uses 1 check bit – 3 check bits for 4 data bits
o Each set has initial even parity (combination of data and check bits results in even
number of 1’s)
After transmission, each set has either even or odd parity
o 23 – 1 code words indicate a single bit error condition
o 1 code word indicates no error (P, Q, R all have even parity)
Syndrome
Syndrome: XORs received check bits (CRec) and calculated check bits (CCalc) to determine the
location of a single bit error in a received code word
o If S = 0 (all bits are 0), no error
o If S only has one 1, error occurred in check bit
o If S has more than one 1, error occurred in data bit
C 1=D0 D 2 D3 D5 D6
C 2=D1 D2 D3 D 7
C 3=D4 D5 D6 D7
CTransmitted: 100
C 0=D0 D1 D3 =0 11=0
C 1=D0 D 2 D3=01 1=0
C 2=D1 D2 D3=1 11=1
DRec: 1010
CCalc: 010
C 0=D0 D1 D3 =0 11=0
C 1=D0 D 2 D3=0 01=1
C 2=D1 D2 D3=1 0 1=0
Classes of Synchronization
Bit synchronization: how long each bit is, and where it starts/stops
o Bit rate synchronization: time that elapses between start of one bit and start of another
o Phase synchronization: given a bit rate, how the midpoint or start of each bit is found –
found by determining phase relationship between local clock and transmitter clock
Byte synchronization: where bytes start/stop
Block synchronization: where blocks start/stop
Bit Synchronization
Given an input signal with no other information, number of bits and their values are unknown
Given an input signal and a clock signal, the clock provides way to get bit rate synchronization
Assume data line is sampled on every edge of the clock period
o Number of bits: 8
o Value: depends on phase synchronization – which edge of the clock is sampled
(rising/falling)
Byte Synchronization
Given an input signal and a clock signal, the clock provides a way to get bit timing, but we do not
know where a byte starts
Need additional byte timing clock to reliably get byte info
Again, assume data line is sampled on every edge of the clock period
o Still do not know what the bytes represent
Bit rate: number of bits that can be transferred per second over a channel
Baud rate: maximum number of symbols that can be transferred per second over a channel
o Example:
Shift registers (SR) convert between serial and parallel data streams
Transmitting data:
o Data is loaded into XMIT (Data Out) register in parallel from system bus
o When SRout is empty and XMIT has data, data from XMIT is transferred to SRout in
parallel
o Data is shifted out serially by the Tx (transmit) clock connected to SRout
Asynchronous (separate clocks): Tx clock generated by local oscillator
Synchronous (common clock): Tx clock received from data destination or
another external source
Receiving Data
Receiving data:
o Data is shifted into SRin serially by the Rx (receiver) clock
Asynchronous (separate clocks): Rx clock generated by local oscillator
Synchronous (common clock): Rx clock generated by data source or another
external source
o When SRin is full, data is transferred to RCV (Data In) register in parallel
o Data is transferred from RCV to system bus in parallel
Processor Side
Reality Checks/Issues
Time
o How does receiver recognize bits/bytes/blocks?
o Given a clock, how do you send/receive data?
o How do you get the clock?
o Synchronous vs. asynchronous:
Asynchronous: Rx and Tx share the same clock
Synchronous: Rx and Tx have different clocks that may have same or slightly
different frequencies
Errors
o Corrupted data due to channel noise
o Erroneous data caused by timing problems (e.g. slow readings, clock differences)
Clocks/Time
Transmit and Receive clocks don’t have to be the same rate, but they usually are
Clock is considered external to the serial interface
In some cases, a local oscillator is used for the Transmit clock, and may also be used for the
Receive clock
Depending on the chosen edge and Receive clock rate, different data is received:
Time and Data at the Transmit and Receive Registers
Transmit and Receive both consist of two registers, an additional shift register (SR)
It takes bit time to transmit between SR and TX/RCV registers, and byte time to transmit
between CPU and TX/RCV registers
o Receive: processor may not pick up the data fast enough – overrun
o Transmit: processor may not respond fast enough for serial data stream to be
uninterrupted
Communication Protocols
Two systems that want to exchange information need to agree on:
o Timing
o Control
o Format
o Data representation
o Electrical signalling (voltages, currents, connector pins, etc.)
Communication Protocol: set of rules for making connections and transferring information
o Communication protocols are generally developed in the following sequence:
1. A company or organization defines the specifications for use with their products
2. A national-level organization sanctions (approves) the standard
3. International Standards Organization (ISO) may sanction an international
standard
4. International Telegraph Union – Telecommunication (ITU-T) standardization
sector sanctions it
Asynchronous Protocols
Transmit and Receive sides are connected to separate local oscillators
Assume both sides agree on a data rate (baud rate)
Phase of Transmit clock is communicated to the Receiver
Clock Errors
If clock rate drift causes sample point to change by more than 0.5 bits in 10 bits (8 data bits +
start/stop bits), sampled data will be incorrect
o Clock too slow: missed bits
o Clock too fast: double sampled bits
Thus, for 10-bit frames, frequencies of transmit and receive clocks can’t differ by more than 5%
Clock Shift
∆T= | 1
−
1
f Rx f Tx |
f Rx and f Tx are the actual clock rates of the transmit and receive clocks
If B is the total number of bits to be transmitted (including start/stop bits), then if
1 1
B× ∆ T > × , then at the end of B bits the shift will be larger than 0.5 bits
2 f Tx
o The larger B is, the smaller ∆ T has to be
Overhead
number of non−data bits
Overhead ¿
number of total bits
Per byte of data:
o Worst-case – more overhead, but know if data is correct:
7 data bits
1 start bit
2 stop bits
1 parity bit
4
¿ =36 %
11
o Best-case – less overhead, but don’t know if data is correct:
8 data bits (no parity bit)
1 start bit
1 stop bit
2
¿ =20 %
10
Errors
Framing error: incorrect frame detected due to incorrect stop bit
Overrun error: data is overrun by data following it, due to serial data arrives too fast for
Receiver to process, or Transmitter sends data too fast for the serial channel to transfer
o Receive overrun error: at Receiver, incoming data has overwritten data in SR¿
o Transmit overrun error: CPU or device writes to transmit buffer before its current data
has been transmitted
Parity error: parity of received data and value of parity bit do not match
Start bit error: when the line is sampled 0.5 bit times after the (falling) edge of the start bit, the
value is not 0 – false start bit detected or there is an error in the assumed bit rate
o DELETE (0x7F): even parity is more prone to error, because a start bit followed by all 1’s
looks like a correct even-parity character
o ~ (0x7E): odd parity is more prone to error than even parity, but there is no ideal parity
If distances are too large, then clock may not arrive at the input of each device at the correct
time
o Moving data from device 2 to 1: need to shift CLK x 8
o Moving data from device 2 to 3: need to shift CLK x 16
Block Oriented Synchronous Port Structure
Receive clock is extracted from the data; data line edges are used to adjust the frequency and
phase of the local oscillator
Since there are no start/stop bits, Sync Detect is required for synchronization, to determine
where bytes start
Since higher speeds are possible, FIFO queues may be required
BISYNC Protocol: modify sequence of characters (using hardware or software) to provide block
synchronization
o Byte synchronization used to derive block synchronization
HDLC Protocol: modify sequence of bits to maintain synchronization
o Bit synchronization used to derive block synchronization
BISYNC Protocol
Based on special ASCII characters:
o SYNC (Synchronize) – 0x16 (0001 0110)
o SOH (Start of Header)
o STX (Start of Text)
o ETX (End of Text)
o ETB (End of Transmission Block)
o DLE (Data Link Escape)
A long string of SYNC characters can be used to establish correct synchronization during
initialization; they are ignored
Header: can contain source/destination addresses or a sequence number
Data: data being transferred (excluding STX and ETX characters)
Special characters: all special characters are sent with a DLE, which indicates that the next
character should be interpreted as a special character
o E.g. to send ETX in data, send DLE | ETX
o E.g. to send DLE in data, send DLE | DLE
When the source buffer empties, SYNCs are inserted by the source and ignored by the
destination
BISYNC frame:
HDLC Frame:
1. Flag: 8 bits
2. Address: 8 bits
3. Control: 8 bits
4. Data: >= 0 bits
5. Checksum: 16 bits
6. Flag: 8 bits
Information Frames
Unnumbered Frames
Device 1 sends data frames and Device 2 acknowledges received data frames
o D x, y : Data frame y from device x
o A x , y : Acknowledgement of data frame y from device x
o E: Erroneous frame
o D: Discarded frame
At most n−1 outstanding data frames from Device 1 at a time
When an erroneous frame is detected, all subsequent frames are discarded until timeout
Then, erroneous frame is re-transmitted
Sequence Numbers – Unidirectional Transmission with NACKs
Device 1 sends data frames and Device 2 acknowledges received data frames
o D x, y : Data frame y from device x
o A x , y : Acknowledgement of data frame y from device x
o N x , y : Negative Acknowledgement of data frame y from device x
o E: Erroneous frame
o D: Discarded frame
At most n−1 outstanding data frames from Device 1 at a time
When an erroneous frame is detected, a NACK is sent so that the frames can be retransmitted
starting with the erroneous frame
All frames are discarded until erroneous frame is re-received
General goal was to create a standard for cables in the PC market, with:
o Cheap connectivity
o Ease-of-use
o Expandable ports
Specific goals:
o Common connector
o Automatic device detection and configuration upon plug-in
o Support for new and legacy devices
o Higher performance
o Low-power
o Direct power distribution for low-power devices
USB Packets
USB PID: there are 16 PID values, each of which are 4 bits followed by the same 4 bits
complemented
o E.g. Start of Frame (0101) -> 0xA5
USB SOF Token Packet: frame used to provide some synchronization and facilitate data transfer
– generally sent once per millisecond to indicate start of new cycle
USB IN Token Packet: used for Interrupt, Bulk, Control, and Isosynchronous transfers, provides
device address and I/O register endpoint to provide data for during the transfer
USB OUT Token Packet: same as IN packet except communication is in opposite direction
USB SETUP Token Packet: used to set up a remote device of hub
USB ACK Packet: error free receipt of data packet
USB NACK Packet: inability to accept or return data, or no new data available
USB STALL Packet: error that can’t be recovered by itself; target is unable to complete transfer,
so software intervention is required
V out =A V ¿
ol
Non-Ideal Op-Amps
Finite gain
V out is bounded by V S and V S −¿¿
V out =A V ¿
ol
Op-amp with resistor feedback such that increase in input voltage decrease in output voltage
V out =−A V V −¿¿ or V −¿=−V
ol
out
¿
AV ol
V out −R f
If AV → ∞ then the closed-loop gain =
ol
V¿ R¿
−R f
V out = V¿
R¿
Current Summer/Inverting Adder/Weighted Summer
Vi
The current in the i th branch is I i=
Ri
V out Vi
If = =−∑ I i=−∑ by KCL
Rf Ri
Vi
V out =I f R f =−Rf ∑
Ri
−R f
o If all Ri=R (same value), then V out =
R
∑Vi
Basic Non-Inverting Amplifier
Op-amp with resistor feedback element such that increase in input voltage increase in output
voltage
V out R f + R¿
=
V¿ R¿
Non-Inverting (Unity Gain) Buffer
Output voltage/current x is proportional to V Ref (analog reference voltage) and n -bit binary
input B to map to analog
o x=k × V Ref × B , where k is a proportionality constant
Binary Weighted Resistor Ladder
Max −V Ref
n
2 −1
V out = n ( 2 −1 )=−V Ref
n
n
=FSAR
2 2
n
2 −1
FSAR −V Ref
1 LSB= n 2
n
2 −1 ¿ n
2 −1
−V Ref
¿ n
2
This is the amount of analog voltage change per change in LSB
Resistor Values
Arbitrary example:
For very large n (number of bits), very large resistors are needed and a very large resistor range
is needed – hard to fabricate
Largest current 100mA is too large for most op-amps to supply, while smallest current 4uA is
akin to the noise level of most op=amps
This configuration is impractical and expensive for large n
R-2R Ladders
Characteristics
Easy to fabricate two resistors of a fixed ratio
Consider an n -bit DAC:
−V Ref n−1
V out =
2 n ∑ 2i Bi
i =0
Full scale output (every B = 1):
n
Max 2 −1
V =−V Ref
out n
2
1
Thus, if |k|< n , then | out| | Ref| and so the largest possible output value is
V <V
2
n
Max 2 −1
V out =−V Ref n
2
Multiplying DACs (M-DACs)
A DAC that is configured such that the analog input voltage signal (V Ref ) is a time-varying signal
Output analog voltage:
V out =k × B ×V ¿
o V ¿ is a varying input – attaching an analog signal to V ¿ would allow you to control the
gain with the digital signal B
Settling time – often expressed as the amount of time it takes for a certain percentage of the
final output to be reached
1
o Should be ± LSB to accurately read output
2
Manufacturers will often leave amplifier off the DAC and only provide a current source, making
the DAC faster and cheaper
Glitch impulse: when digital values change from one to another, the analog output may not
change directly from one value to the other
o Glitch impulse area is the region of error caused by internal switches not changing at the
same rate – e.g. in the example above, if the switch for b3 changes slower than switches
for b0, b1, and b2
Analog-to-Digital Converters
If the digital value is 010, then the applied analog voltage was between 1.5–2.5 LSBs
Two basic operations:
o Quantization: reduce range of analog values to discrete digital values
o Coding: assign binary code to each discrete range
ADC Unbiased vs. Biased Error
For biased errors, transition point gets moved over to each volt (instead of between volts)
If digital value of 010 is read, then applied analog voltage is between 2–3 LSBs
Example
Analog input voltage 0.6V is converted by ADC to digital value 101, since it is between 0.571V –
0.714V
Biased high: digital value 101 is interpreted as 0.714V, i.e. all values in range 0.571V – 0.714V
are interpreted as 0.714V
// increment digital value while it is lower than the analog value and
the
// max value hasn’t been reached
while (S == 0 && DV < pow(2, n) – 1) {
DV += 1;
}
Conversion time becomes fixed for a given resolution, instead of being dependent on the analog input
voltage
Example
Analog input voltage = 0.6V
o First clock cycle: X =2, SAR = 100 ( DV 2=1); comparator outputs 0, so leave DV 2=1
o Second clock cycle: X =1, SAR = 110 ( DV 1=1); comparator outputs 1, so set DV 1=0
o Third clock cycle: X =0, SAR = 101 ( DV 0=1); comparator outputs 1, so set DV 0=0
3 clock periods to convert 0.6V to 100
Biased low: digital value 100 interpreted as 0.571V, i.e. all values in range 0.571V – 0.714V are
interpreted as 0.571V
DV = 0;
1 1
E.g. XYZ = 100 means that V Analog is between V and V Ref , so DV = 01
4 Ref 2
1 3
E.g. XYZ = 110 means that V Analog is between V Ref and V Ref , so DV = 10
2 4
ⅆv
I =C and I ¿=I f so:
ⅆt
V¿ ⅆ V out
=−C
R ⅆt
Integrating both sides:
T
∫ −1
RC
V ¿ ⅆt =V out ( T )−V out ( t 0 )
t0
Then, at time T :
V¿
V out ( T )=V out ( t 0 )− (T −t 0 )
RC
T
Switch is kept closed until start of conversion, so V out ( 0 ) =0 and V out ( T )= V
RC Ref
At the start of conversion, switch is opened and counter is reset
V Ref
o V out ramps up with a slope of
RC
When the threshold is reached (at time T ), the counter stops
o V out (T )≈ V Analog
DV
o T= , where DV is the binary value of the counter and f is the clock frequency
f
Thus:
T V Ref DV
V Analog ≈ V Ref ≈
RC RC f
V Analog RCf
DV ≈
V Ref
o This shows that DV is dependent on R , C , f , and V Ref
The frequency of a periodic signal can impact the required sampling rate
o Nyquist Sampling Rate: if a time-varying signal contains components of significant
amplitude only below f Hz , then a sampling frequency ¿ 2 f Hz will suffice to
reconstruct the frequency without generating lower frequency aliasing signals
i.e. a signal with frequency f requires a sampling frequency of at least 2 f to
reconstruct the signal
o
ΔV
|
Δt Max
=2 π f Max V ρeak
0.6 mV
f Max = ≈ 2 Hz very constraining for a 100kHz converter
(10 μs)(2 π)(5 V )
Sample-and-Hold Overview
ADCs require a stable input voltage during conversions, i.e. the voltage remains within ¼ LSB
A sample-and-hold circuit is used to ideally hold the input voltage constant during the
conversion
Buffer 1 isolates the analog circuit from C when Q is on
Buffer 2 isolates the converter from C
Sample period: When Q is on, V c tracks V ¿
Hold period: When Q is off, V c retains the most recent V ¿, which means that V out retains the
most recent V ¿ value and it can be used as the ADC input voltage
Some ADCs include sample-and-hold circuits
During sampling
o Errors in input buffer
Offset
Non-linearity
Non-unity gain
o Settling time: time to attain a good estimate of the final value, given a full-scale step at
the input, to within a specified error – i.e. time to couple the voltage across the
capacitor through the two buffers, to the ADC input
During sample-to-hold transition
o Sample and Hold Aperture Time: time required for Q to turn off, once the hold signal is
asserted
o Sample and Hold Aperture Uncertainty (Jitter): the time between the command to turn
Q off and when Q actually turns off
Caused by variables in: the delay to turn off, sample/hold transition, or
temperature
If sampling a signal at regular intervals, cannot miss a sample by the time
required for the signal to change by more than a fraction of the LSB value
o Example: if you need to sample a 10kHz signal using the 10µs ADC mentioned above,
how much sample and hold aperture uncertainty can be tolerated?
1 1 10 V
LSB= ≈ 0.6 mV
4 4 212−1
ΔV
|
Δt Max
=2 π f Max V ρeak
0.6 mV
T aperture uncertainty= ≈2 ns
2 π (10 kHz)(5 V )
During hold
o Droop: a drop in the signal out of the sample and hold circuit
Caused by C discharging due to:
Input bias currents in output buffer
Leakage through the switch
Leakage across C
o Hold settling time (t hs): time for signal to stabilize after hold begins
o Feed through: leakage forward through the switch
During hold-to-sample transition
o Acquisition time (t acq): time required before capacitor voltage is within a specified
percentage of the final value
o At times, input and stored values may appear to be close, but there may still be
transients when sample starts due to stray capacitance still present in the circuit
In this case, hold time is decoupled from the next cycle, because it occurs before the clock edge
where data is read
Synchronous Write (Single Clock)
Synchronous Write (Two Clocks)
Synchronous buses must run at the speed of the slowest interfacing device
Asynchronous buses allow bus speed to vary according to a wide variety of device speeds
o Clock line is replaced with Master and Slave lines
Fully Interlocked Asynchronous Read Transfer
Optimistic slave: once the address is decoded, save the data in a temporary register until it can
be written to the correct location
Conservative slave: wait until the data is written to the correct location before informing the
master
Assume that t Delay can be set to any fixed value that is higher than the device time
Synchronous vs. Fully- and Partially-Interlocked Asynchronous
Split Cycle
In all previous strategies, the bus is occupied by the master until the transfer is completed
What if there is a very slow device on the bus, but several possible bus masters
Split cycle protocol:
o Writes are one quick transfer – could use a temporary register to hold data at the slave,
if necessary
o Reads two write cycles
1. Master sends address and Read signal to slave
2. Master releases bus
3. Slave requests access to the bus and writes the request result back to master
Can be implemented using synchronous, asynchronous, or semi-synchronous buses
o Most useful when combined with synchronous buses, to make use of extra clock cycles
Case A – Idle: local device interface i isn’t requesting service, no lower-priority devices are
requesting service
o All inputs ( R¿ , G¿ , Reques t i) and outputs ( Rout , Gout ,Gran t i) are 0
Case B – Local Only: only local device interface i requests service
Case C – Lower-Priority Only: only one or more lower-priority device interfaces request service
o Higher-priority devices pass along the signal
Case D: one or more lower-priority device interfaces request service while the local device
interface i is using the bus
o Case D1: forward grant immediately
Gran t i :1→ 0 and G out :0 →1
o Case D2: re-arbitration cycle
Gran t i :1→ 0 and Rout :1 →0 (regardless of value of R¿)
DA waits for G ¿ :0 → 1 before re-asserting Rout :0 → 1
Case E: local device interface i requests service after a lower-priority device has requested
service
o Case E1: If G ¿ :0 → 1 hasn’t occurred yet, grant bus to local device
o Case E2: If G ¿ :0 → 1 already, pass grant along to lower-priority device
Reques t 1 occurred before BusGrant 0, so local device (Device 1) gets bus as if it was the first to
request
Case E1A: Propagate Grant
Reques t 1 occurred after BusGrant 0, so remote device (Device 2) gets bus first
a: system is idle
b: local request ( Request ) only (no remote requests ( R¿ )
c: remote requests only (no pending local request)
d: system is awaiting a G ¿ signal; remains in this state until G ¿ is received
e: G ¿ received, bus granted to local device; if there is an R¿, move to state i
f: G ¿ received, bus granted to remote device; if Request is activated during this state, move to
state j
g: two pending requests; local request wins when grant is detected
h: arbiter waits for Request to fall after Rout has been de-asserted – transition state
i: local device is bus master while remote request ( R¿) arrives
j: remote device is bus master while local request ( Request ) arrives
When a device interface wants to use the bus, its DA pulls BusRequest low to request service
A DA may take control of the bus when it sees a rising edge on BusGrant i−1, the bus is not busy
( BusBusy=1), and it has a local request ( Reques t i=1)
When it gets the bus, the local device pulls BusBusy low to indicate that it is in use
3-Wire Daisy-Chain Arbitration
Priority uncertainty: consider the situation where the bus is idle and there are > 2 requests
t uncertainty=( n−i ) × t DA for 2-wire, 3-wire, and 4-wire arbitration systems
o If device i requests the bus more than t uncertainty before device n receives the bus and
i<n, it will be serviced first
o If device I requests the bus after t uncertainty has passed, device n will get the bus even
though device i has higher priority
Bus Busy – Delay
Consider a bus request by the nth device in the daisy chain
Assume the bus is currently being used by the c th device, where c greater than or less than n
Assume the bus is busy, so the delay is only related to the time to determine the next user
What is the delay between the completion of one user and the start of the next (assuming the
request is already present when the current DA finishes)?
Delay if the bus is busy:
o 3-wire: delay to de-assert BusBusy (t BL), delay through CA, delay through n DAs, delay
to assert BusBusy (including Grant ) (t BL) t arbitration busy =2 t BL + nt DA +t CA
o 4-wire: if there is enough time to arbitrate the new request before the previous user has
finished using the bus, then the delay is just to assert BusBusy (including Grant )
t arbitrationbusy=t BL
Assume:
o Device is unidirectional and only provides data
o Data is applied and clocked in by external device
o When data is clocked, the flip-flop is set to 1, which can be read by the bus master by
querying the status register
o When data is read, status register is cleared
Example: transfer of 256 bytes
for (int i = 255; i <= 0; i--) {
while (Status_Register & 0x80 != 0x80);
value[i] = Data_Register;
}
Assembly:
o Number of useless memory/bus cycles is 2+n(6 x+7) , where n is the number of bytes
to transfer and x is the number of cycles needed for synchronization
Even for fastest devices with x=1, waste 13 bus cycles
Transfer Mode
Cycle Stealing: only transfer 1 byte per bus mastership
o May require an excessive number of bus requests/grants
Transparent: if CPU tells the DMA controller the cycles when it doesn’t need the bus, DMA can
only use the bus during those cycles
Burst: multiple transfers are permitted per bus mastership; allows the transfer of up to an entire
block per bus mastership
o Eliminates some latency due to bus request/grant cycles, but CPU can be blocked from
using the bus as long as the I/O devices needs to transfer data
Trade-offs:
o During a burst, the CPU can’t access anything on the bus
o Thus, the length of a burst is usually constrained by:
Amount of data available to be transferred
Number of cycles that the CPU is willing to give up the bus
Number of wasted memory/bus cycles decreases to 12+6 x ; if DMAC completes first, x=1
Complete DMA Cycle
Initialization
Global initialization – once
o CPU configures global aspects of DMAC
o CPU configures unchanging aspects of device
o CPU configures unchanging aspects of DMAC interrupts, if applicable
CPU does normal operations
Block initialization – once per block
o May be necessary to set up device or device interface every block
o CPU writes control values to DMAC (MAR, BCR, interrupt enable/disable, etc.)
CPU does normal operations until DMAC takes control
Data Transfer
Data transfer – once per transfer
o Device data is ready
o Device interfaces requests transfer from DMAC
o DMAC requests for and gets control of the bus through arbitration
o DMAC does a read (memory data gets written to interface) or write (interface’s data
gets written to memory) operation
o DMAC increments/decrements MAR and decrements BCR (loop if burst mode)
o DMAC releases bus
Block synchronization – once per block
o DMAC tests if the BCR = 0; if so, set the status bit or trigger an interrupt (if interrupts
enabled)
Cycle Stealing – Ladder Diagram
DMAC Architecture Considerations
1. Device request service from interface, which request service from DMAC
2. DMAC requests and claims bus
3. DMAC asserts memory address and control signals for desired memory operation
4. DMAC issues Acknowledge signal to the interface to indicate that it should take the appropriate
action
5. Interface releases request and DMAC completes transaction (including removing Acknowledge
signal)
Implicit Addresses vs. Dual Addresses
o Options:
2 physical buses – two sets of address, control, and data lines
1 physical bus and 1 mode bit (virtual memory bus) – two modes, one
optimized for memory transfers and the other optimized for I/O transfers
I/O Performance
Performance Comparison
Assume 3-wire arbitration, where arbitration is comparable (faster) than a memory cycle (i.e.
1 bac = 1 bc)
Perspective is everything:
o Device sees tight polling as the best option because it provides fastest response time
o Processor may see best performance with interrupts, since processor performs fewer
instructions when interrupts are used, so it has more time to complete other tasks
o Overall cost/complexity may be better with polling, since it is less complex and so may
cost less
Device perspective:
o Latency – delay between data being available and data being read (by DMAC or CPU)
o Transfer rate – how quickly data is transferred out of buffer
o Effective transfer rate – highest sustained rate of transfer
CPU perspective:
o How much processing and bus time is needed for the transfer?
o Device latency – delay between making request and first data being available
o Transfer rate – delay between subsequent transfers
o Effective transfer rate – highest sustained rate of transfer