Escolar Documentos
Profissional Documentos
Cultura Documentos
::
::
) Page -1-
Table of Contents
1. INTRODUCTION...................................................................................................................................................2
2. SYSTEM CIRCUITS.............................................................................................................................................3
2.1 Processors........................................................................................................................................................3
2.1.1 Market........................................................................................................................................................4
2.1.2 Instruction Set Architecture (ISA)......................................................................................................5
2.1.3 Micro-Architecture (uArch)...................................................................................................................6
A. Control Unit (CU).....................................................................................................................................6
B. Algorithmic Logic Unit (ALU)................................................................................................................6
C. Interrupt Requests (IRQ).......................................................................................................................6
D. Bit-Numbering (Endianness)...............................................................................................................7
E. Timing..........................................................................................................................................................7
2.2 Memory..............................................................................................................................................................7
2.2.1 Market........................................................................................................................................................7
2.2.2 Hierarchy...................................................................................................................................................7
A. Processor Registers...............................................................................................................................8
B. Cache..........................................................................................................................................................8
C. Main Memory............................................................................................................................................9
D. Secondary Memory................................................................................................................................9
2.2.3 Management............................................................................................................................................9
A. Memory Management Unit (MMU)....................................................................................................9
B. Memory Controller (MEMC) ............................................................................................................10
2.3 Peripheral Buses..........................................................................................................................................10
2.3.1 Overview.................................................................................................................................................11
2.3.2 I2C............................................................................................................................................................11
2.3.3 Industry Standard Architecture (ISA).............................................................................................12
2.3.4 General Purpose I/O (GPIO)............................................................................................................12
2.3.5 Serial Peripheral Interface (SPI).....................................................................................................12
2.3.6 Joint Test Action Group (JTAG).......................................................................................................12
2.3.7 Peripheral Component Interconnect (PCI / PCIe).....................................................................12
2.3.8 Serial Communication Interfaces (SCI / RS-XXX).....................................................................12
2.3.9 Serializer/Deserializer (SERDES)..................................................................................................13
2.3.10 Universal Async Receiver/Transmitter (UART)........................................................................13
2.3.11 Universal Serial Bus (USB)............................................................................................................14
A. Abstraction Layers................................................................................................................................14
B. Functional Layer....................................................................................................................................14
C. Logical Layer..........................................................................................................................................15
D. Physical Layer.......................................................................................................................................16
2.3.12 VGA Interface Spec..........................................................................................................................18
3. CIRCUIT THEORY.............................................................................................................................................18
3.1 Analog..............................................................................................................................................................18
3.1.1 Analysis...................................................................................................................................................18
3.1.2 Transistors..............................................................................................................................................19
A. CE Amp (DC Analysis)........................................................................................................................20
B. Dual Stage NPN PNP Amplifier (AC Analysis).............................................................................20
3.1.3 Inductors/Coils......................................................................................................................................23
A. Series RL AC Circuits - Low Pass Filtering..................................................................................23
3.2 Digital...............................................................................................................................................................23
3.2.1 Sequential Logic (RTL)......................................................................................................................24
A.1 Synchronous (In-Sync).............................................................................................................24
A.2 Asynchronous (Transparent)..................................................................................................24
A.3 Implementation............................................................................................................................24
A.3.1 Finite State Machine (FSM)...............................................................................................24
A.3.2 Pipe-Lining...............................................................................................................................24
3.2.2 Combinational Logic...........................................................................................................................24
A. Algorithmic Circuits..............................................................................................................................25
B. Arithmetic Circuits.................................................................................................................................25
B.1 Negative numbers (0x7F).........................................................................................................25
B.2 Adder..............................................................................................................................................25
B.3 Boolean Algebra..........................................................................................................................25
3.2.3 Logic Gates............................................................................................................................................26
3.2.4 Discrete Logic.......................................................................................................................................26
A. 7400-Series ICs.....................................................................................................................................26
3.3 Mixed-Signal ( Analog & Digital )............................................................................................................27
4. CIRCUIT DESIGN STEPS...............................................................................................................................27
4.1 Planning..........................................................................................................................................................28
4.1.1 System Buses.......................................................................................................................................28
A. Reference................................................................................................................................................96
7.3.4 Linux.........................................................................................................................................................96
A. Overview..................................................................................................................................................96
B. Code..........................................................................................................................................................96
7.4 Assembly Language (ASM)......................................................................................................................97
7.5 C & C++..........................................................................................................................................................98
7.5.1 Compilers (GCC/MSVC)....................................................................................................................99
7.5.2 C++...........................................................................................................................................................99
A. Header File...........................................................................................................................................100
A.1 #Pre-processor directives......................................................................................................100
A.2 #Include/Using..........................................................................................................................100
A.3 Namespace/Class/Struct/Union..........................................................................................100
B. Source File............................................................................................................................................101
B.1 Details..........................................................................................................................................102
C. Qt.............................................................................................................................................................103
D. Makefile.................................................................................................................................................103
7.6 Java...............................................................................................................................................................104
7.7 C#...................................................................................................................................................................105
7.8 VB6 & VBA..................................................................................................................................................105
7.8.1 VB(6&A) Learned Items...............................................................................................................105
8. INDUSTRIAL CONTROL SYSTEMS (ICS)..............................................................................................108
8.1 Allen-Bradley PLC.....................................................................................................................................108
8.2 Siemens........................................................................................................................................................109
8.3 Omron...........................................................................................................................................................109
8.4 Ladder-Logic on PLC...............................................................................................................................109
8.5 Human Machine Interface (HMI)..........................................................................................................110
8.6 Instrumentation..........................................................................................................................................110
9. NETWORKING..................................................................................................................................................111
9.1 IT Distributed Management (DMTF)....................................................................................................111
9.2 Cellular Networking...................................................................................................................................112
9.3 Area Networking (LAN/WAN)................................................................................................................113
9.3.1 OSI Protocol Model...........................................................................................................................115
A. Application Layer-7 (HTTP/POP3)...............................................................................................116
B. Presentation (Layer-6)......................................................................................................................117
C. Session (Layer-5)...............................................................................................................................117
D. Transport Layer-4 (TCP/UDP Data Segment)......................................................................117
E. Network Layer-3 (IP Packet Data).............................................................................................118
E.1 Internet Protocol (IP)...............................................................................................................118
E.2 Subnet..........................................................................................................................................119
F. Data-Link Layer-2 (MAC Frame Data)......................................................................................119
G. Physical Layer-1 (PHY Bit Data)...............................................................................................121
G.1 WAN Physical Layer...............................................................................................................121
9.4 Reference / Tools.......................................................................................................................................122
9.5 Cisco Systems............................................................................................................................................122
10. RESOURCES..................................................................................................................................................122
10.1 Engineering Models...............................................................................................................................123
10.2 Market Segments....................................................................................................................................123
10.2.1 Market-Specific Standards...........................................................................................................124
10.2.2 General Purpose Standards........................................................................................................125
10.3 Embedded System IDE.........................................................................................................................125
10.4 Symbols.....................................................................................................................................................126
10.4.1 Timing Diagrams.............................................................................................................................126
10.4.2 Schematic Symbols........................................................................................................................126
1. INTRODUCTION
Electronics Engineering Newbie-2-Novice Outline (N2NO) provides a quick outline of subjects related to the electronics engineering field. Topics will be touched upon briefly in a bullet
type format. Finer details will be left up to the reader to investigate at-will using supplied web-links.
Top-Level Terms
Architecture
Circuit
System
Component
Interface
Protocol
Bus
- Model
- Electrical Network
- Integrated Whole
- Part or Element
- Interacting Boundary
- Interface Standards
- Collective
= Relative term; A smaller, self-contained part of a larger entity. (e.g. The parts of an integrated whole)
= The shared boundary across which two separate components exchange information.
= Predefined standard of rules & regulations that determines how an interface exchanges information.
= Term that entails all related connections, software and protocols used to interface components.
2. SYSTEM CIRCUITS
Categories
Computer System
Embedded System
Consumer Electronics
- Software Operated
- Firmware Operated
- Circuit Operation
= Preforms a variety of functions by means of loading a list of execution instructions (ie: Software)
= Dedicated function by means of fixed-in-hardware list of execution instructions (ie: Firmware)
= Electronic equipment for everyday use that may or may not contain a Computer or Embedded System.
Implementation Hardware
SOC
SOPC
PCA
+ System On a Chip
+ System On a Programmable Chip
+ Printed Circuit Assembly
System Components
Processor
Memory
Peripheral Buses
System Buses
- Obeys Instructions
- Stores Instructions / Data
- Processor IO
- Internal Processor IO
= Named circuits that processes instructions as defined by a processor's Instruction Set Architecture (ISA)
= Electrical signal storage typically used to store the list of instructions and other data
= Communication (ie: Input/Output(IO)) bus between processor and an Internal/External devices
= Embedded Systems can use standard interconnect fabric between internal components
System Software
Implementation Categories
Software
= Dynamic execution instructions typically for computer systems.
Firmware
= (ie: Embedded Software); Static Instructions that are an essential part to hardware control.
Purpose Categories
System Software
Application Software
= Software or Firmware designed to Isolate Application Software from hardware control by providing a standard platform.
= Software or Firmware designed for the system user; Including the programming languages used to create system software.
--[ References ]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Covers many details of low/high level programming and Processor architectures http://en.wikipedia.org/wiki/Computer
Details including ASIC and FPGA solutions
http://en.wikipedia.org/wiki/Embedded_system
(Example of an Embedded System / Microcontroller ) Automotive Engine Controller http://en.wikipedia.org/wiki/Electronic_control_unit
2.1 Processors
Processor tasks
1. Drive Address Bus
2. Activate Enable
3. Fetch Data from Data Bus
4. Control Unit - receives instructions from RAM
5. Interrupt Handling (IRQ)
Implementation Groups
Microprocessor
Microcontroller
HPS
SPS
- Discrete component
- Hardware control purpose
+ Hard-Core Processor System
+ Soft-Core Processor System
Architectures
Von Neumann
Harvard
= (ie: Princeton) Any control circuit that can store, load and execute instructions dynamically from memory using a single pathway
= A Von Neumann with two physically separate storage and pathways; one for data and one for instructions
+ Micro-Architecture
= The processors hardware (ie: circuit design) that implements the tasks of the ISA
2.1.1 Market
Purpose Groups
CPU
MCU
DSP
GPU
= CPU can infer box, board or processor chip that performs different tasks under software control.
= Processor + Memory + IO Control integrated on one chip
= Optimized for digital signal processing generally from an analog source
= Optimized for displaying image and frame buffers
Common Processors
AMD
ARM
- Acorn Computers Ltd
= A fab-less design company that sells power optimized processor designs
Broadcom
Intel
RISC based ARM (by ARM Holding Co), AVR (by Atmel Technologies), PowerPC, SPARC/LEON, MIPS, Nios
Development Tools
Bochs
QEMU
Galileo
Shark Cove
http://en.wikipedia.org/wiki/Bochs
http://en.wikipedia.org/wiki/QEMU
http://www.intel.com/content/www/us/en/do-it-yourself/galileo-maker-quark-board.html
http://www.sharkscove.org/
= Application-Specific purpose; simple slave processors (e.g. TV receiver board, GPU, etc...)
= Repeatedly preforms same computations on a stream of data (e.g. Digital Signal Processors - DSP's)
= Combination of Controller/Data-path typically implemented on FPGA(s) and/or PLD(s) (e.g. MPEG Decoder)
= Some processor's ISA can run Java byte-code via hardware (e.g. aJile's aj-80, aj-100)
( 2.1.2 SYSTEM CIRCUITS :: Processors :: Instruction Set Architecture (ISA) ) Page -5 Operand
- Data
Containing Circuits
Address Generation Unit
Branch Prediction Unit
Sequencer
Instruction Queue
Stop standard execution to execute event-based (ie: OnEvent) functions (e.g. hardware issues, resets)
D. Bit-Numbering (Endianness)
8-bits = 1-byte
Word = 16-bits (2-bytes) (0xFFFF)
Double Word = 32 bits (4-bytes) (0xFFFF_FFFF)
Endianness is also called byte-ordering
Endianness = Is a BYTE(8-bits) level order (2-digit HEX Swap)
Little-endian
= Least significant byte is at byte(0) in Left Right.
Big-endian
= Most significant byte is at byte(0) in Left Right.
Bit-Significance
LSB
+ Least significant bit
MSB + Most significant bit
Timing
Time handling makes sure logic-element-1 has evaluated before its output is fed into logic-element-2
Register = Is a Flip-Flop circuit that holds it's output state (has memory).
2.2 Memory
Market
Hierarchy
2.2.1 Market
Volatile Memory (ie: non-permanent)
DRAM + Dynamic random-access memory
= Capacitor Storage
SDRAM
+ Synchronous Dynamic RAM = Requires a refresh clock and synchronous clock (storage cells are made of capacitors)
RDRAM
+ Rambus DRAM
DDR-SDRAM
+ Double Data Rate SDRAM
FPM-DRAM
+ First Page Mode DRAM
EDO-DRAM
+ Extended Data Out DRAM
VRAM
+ Video RAM
SGRAM
+ Synchronous Graphics RAM
PSRAM
+ Pseudostatic RAM
SRAM
2.2.2 Hierarchy
Memory Hierarchy
Processor Registers
Cache
Main Memory
Secondary Memory
= (ie: Register File) Is the fastest closest memory to store operands that are being frequently used
Internal
Instruction
MBR
+ Memory Buffer Register
MDR
+ Memory Data Register
MAR
+ Memory Address Register
Memory Data (
Accumulator
- (ie: Summation) Stores numeric values Floating Point
Load-Store Model (RAM -> Register)
In-line barrel shift-er
MMIO + Memory Mapped Input Output
Cache
Cache Hit
Cache Miss
Cache Schemes
Direct Mapped = Data in cache is located by its associated block address in memory (ie: Tagged)
Set Associative = Cache is divided into sets where multiple blocks can be placed; Blocks are located according to an index field that maps into a set
Full Associative = Blocks are placed anywhere in cache and must be located by searching the entire cache memory each time
Transfers from main-memory using one-word or multi-word blocks; Blocks contain the data and main memory location (ie: Tags)
Cache Levels
L0 Micro-operations cache
L1 Separate Instruction/Data Cache
L2 Shared Instruction/Data Cache
L3 Shared Cache; 6MiB; 100 GB/s
L4 Shared Cache; 128Mib; 40GB/s
D. Secondary Memory
Memory Hardware
Hard Disk Drive
Tape Backup
Flash Memory
2.2.3 Management
Memory Management Groups
Hardware Memory Management
- Typically resides in the Processor IC but can reside as a separate IC.
OS Memory Management
Windows
= Virtual Memory Scheme
Linux
Application Memory Management
Memory Architecture
Linear
Segmented
Base Address::Offset
Addressing Architecture
Load-Store
Register-Memory
Memory Addressing
= A Processors ISA defines how the processor sees the data (ie: Operand) storage and addressing modes
Logical
Virtual
= Memory Addresses are Virtual. Addressing to physical memory is handled by look-up tables in the memory manager.
Physical
= Actual (Row,Col) addressing; no encoding/decoding of addresses
Memory Map (MM)
= Processor/Software treats memory as one large one-dimensional array
Direct Mapping
= TAG / CACHE / OFFSET
Associative Cache
=
--[ References ]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Subject 6.3.3 (pg) System Software :: Operating Systems (OS) :: Windows :: Memory Management
http://en.wikipedia.org/wiki/Category:Memory_management
https://www.kernel.org/doc/gorman/pdf/understand.pdf
MSDN Virtual Address Space Explained
https://msdn.microsoft.com/en-us/library/windows/hardware/hh439648%28v=vs.85%29.aspx
A. Memory Management Unit (MMU)
Cache memory can be behind an MMU or skip the MMU
Memory Scheme
segmentation
paging
both
= Schemes in translating addresses (Determined by the OS Software MMUs and OS manage virtual memory)
= Dividing logical memory into large variable-size sections
= Dividing logical memory into smaller fixed-sized units
Features
DMA
MM
TLB
Bus Arbitration
Exceptions
Security
Shared
Page Fault
= Off-chip memory can be accessed directly by slave processors w/o going through the main processor
= Translates logical addressing into physical addressing
= Cache memory allocated for mapping logical addresses into physical addresses
Note:: Some chips don't have Memory-Mapped I/O (have instruction 'OUT' and 'IN') this route is mostly historical. (x86 has it?)
= Data is transferred at both the rising and falling edges of a master clock
= Logic signals 1 and 0 are transferred using a difference between 2-line voltages
http://en.wikipedia.org/wiki/International_Organization_for_Standardization
Technical Management Board members is responsible for over 250 technical Committees.)
Is a Technical Committee of ISO. ( http://www.iec.ch/ )
Global standards for the microelectronics industry http://www.jedec.org/
http://www.aecouncil.com/
e) The organization's headquarters were in Arlington, Virginia. The EIA divided its activities into the following sectors:
ECA
Electronic Components, Assemblies, Equipment & Supplies Association
JEDEC
JEDEC Solid State Technology Association, former Joint Electron Devices Engineering Councils
GEIA
(now part of TechAmerica), Government Electronics and Information Technology Association
TIA
Telecommunications Industry Association
CEA
Consumer Electronics Association
e) USB
- Ethernet Interface
h) Fieldbus
CAN-Bus
LIN-Bus
PROFIBUS
i) Timers
PLL
Capture/Compare
Time Processing Units
2.3.1 Overview
Serial Interfaces
Terms
SCC
SMC
FIFO
Bandwidth
Capabilities
Simplex
Half Duplex
Full Duplex
Synchronization
Synchronous
Asynchronous
2.3.2 I2C
Signals
START = SDA line transitions from HIGH->LOW while SCLK is HIGH
STOP = SDA line transitions from LOW->HIGH while SCLK is HIGH
Rules
SDA must never change while SCLK is HIGH (Unless marking a Condition change)
8-bits is always transfered at once (followed by 9th bit a read-back ACKnowledge)
1st 8-bits are the SHIP Address or CHIP ID address which is actually 7-bit with 8th bit indicating Read/Write
SDA/SCL in an idle state are required to be pulled high to VDD_IO level. This can be done with either 1K pull-up resistors on the probe-card or using the tester to hold the levels
high.
CHIP_ID |
11-1111-1111-22222
0123-4567-|-8901-2345-6789-01234
-------------------------------------|CHIPID|
|-16BIT REG ADDR -|
1st - 0010-0000-L-0000-0000-0000-0000
2nd - 0010-0001-L-VVVV-VVVV-VVVV-VVVV
|
| ^ACK
|
^Read=1,Write=0
^t_i2c_st
I2C CLK can run at typically 100KHz (standard) or 400KHz (high-speed)
Synchronous Transmission
( 2.3.5 SYSTEM CIRCUITS :: Peripheral Buses :: Serial Peripheral Interface (SPI) ) Page -11-
A Pair of functional blocks that convert between serial & parallel in both directions
Parallel In Serial Out
Serial In Parallel Out
( 2.3.11 SYSTEM CIRCUITS :: Peripheral Buses :: Universal Serial Bus (USB) ) Page -12-
Speed (Name)
Host Controller
_ 2.0 High-Speed(480Mbit/s)
A. Abstraction Layers
Functional Layer (Software)
View-point that abstracts (removes) logical & physical layer details
= USB Driver
= Host Controller Driver
= USB Device initialization
= Addressable buffer ( holder for to/fro host data )
B. Functional Layer
Communication duties
Host controls all communications
System SW maintains ownership of the Default Control Pipe (ie: Endpoint(0))
Client SW requests data transfer via I/O Request Packets (IRP) to a pipe.
IRP details are part of the hosts operating system (OS)
Enumeration Process (ie: Device Initialization / Introduction)
1. USB device is connected to a host and drives (D+) or (D-) high
2. Host sends device a Reset (ie: D+/D- held low for 3-ticks 'SE0')
3. Host requests USB device descriptors using the Default Control Pipe (ie: Device(00h)::Endpoint(0h))
4. Device Responds with it's descriptor information.
5. Host assigns the device a 7-bit address
6. Host uses the newly assigned device address to request device descriptors a 2 nd time. (ie: Device(#)::Endpoint(0h))
7. Device Responds with it's descriptor information.
8. Host locates the device drivers by reading (.INF) file for driver location and loading driver (.SYS)
9. Host selects the appropriate configuration for the device and device is set to a 'configured' state.
Device Descriptors
Device Descriptor ( Only 1 per device )
Offset
0
1
2
4
5
6
7
8
10
12
14
Field
bLength
bDescriptorType
bcdUSB
bDeviceClass
bDeviceSubClass
bDeviceProtocol
bMaxPacketSize
idVendor
idProduct
bcdDevice
iManufacturer
Bytes
1
1
2
1
1
1
1
2
2
2
1
Value
Number
Constant
BCD
Class
SubClass
Protocol
Number
ID
ID
BCD
Index
Description
Size of the Descriptor in Bytes (18 bytes)
Device Descriptor (0x01)
USB Specification Number which device complies too.
Class Code (Assigned by USB Org)
If equal to Zero, each interface specifies its own class code
If equal to 0xFF, the class code is vendor specified.
Otherwise field is valid Class Code.
Subclass Code (Assigned by USB Org)
Protocol Code (Assigned by USB Org)
Maximum Packet Size for Zero Endpoint. Valid Sizes are 8, 16, 32, 64
Vendor ID (Assigned by USB Org)
Product ID (Assigned by Manufacturer)
Device Release Number
Index of Manufacturer String Descriptor
( 2.3.11 SYSTEM CIRCUITS :: Peripheral Buses :: Universal Serial Bus (USB) ) Page -1315
16
17
iProduct
iSerialNumber
bNumConfigurations
1
1
1
Index
Index
Integer
Configuration Descriptor (Only one active at a time user / driver selects the configuration typically there is only one)
Offset
0
1
2
4
5
6
7
Field
bLength
bDescriptorType
wTotalLength
bNumInterfaces
bConfigurationValue
iConfiguration
bmAttributes
bMaxPower
Bytes
1
1
2
1
1
1
1
Value
Number
Constant
Number
Number
Number
Index
Bitmap
mA
Description
Size of Descriptor in Bytes
Configuration Descriptor (0x02)
Total length in bytes of data returned
Number of Interfaces
Value to use as an argument to select this configuration
Index of String Descriptor describing this configuration
D7 Reserved, set to 1. (USB 1.0 Bus Powered)
D6 Self Powered
D5 Remote Wakeup
D4..0 Reserved, set to 0.
Maximum Power Consumption in 2mA units
Interface Descriptors (Function Interfaces Multiples allowed in a Compound/Composite devices (e.g. fax, scan, print))
Each Interface can have alternate settings (ie: Various switchable blocks of endpoint settings)
Offset
0
1
2
3
4
5
6
7
8
Field
bLength
bDescriptorType
bInterfaceNumber
bAlternateSetting
bNumEndpoints
bInterfaceClass
bInterfaceSubClass
bInterfaceProtocol
iInterface
Bytes
1
1
1
1
1
1
1
1
1
Value
Number
Constant
Number
Number
Number
Class
SubClass
Protocol
Index
Field
bLength
bDescriptorType
bEndpointAddress
Bytes
1
1
1
Value
Number
Constant
Endpoint
Description
Size of Descriptor in Bytes (9 Bytes)
Interface Descriptor (0x04)
Number of Interface
Value used to select alternative setting
Number of Endpoints used for this interface
Class Code (Assigned by USB Org)
Subclass Code (Assigned by USB Org)
Protocol Code (Assigned by USB Org)
Index of String Descriptor Describing this interface
Endpoint Descriptors
Offset
0
1
2
bmAttributes
Bitmap
4
6
wMaxPacketSize
bInterval
2
1
Number
Number
Description
Size of Descriptor in Bytes (7 bytes)
Endpoint Descriptor (0x05)
Endpoint Address
Bits 0..3b Endpoint Number.
Bits 4..6b Reserved. Set to Zero
Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints)
Bits 0..1 Transfer Type
00 = Control
01 = Isochronous
10 = Bulk
11 = Interrupt
Bits 2..7 are reserved. If Isochronous endpoint,
Bits 3..2 = Synchronisation Type (Iso Mode)
00 = No Synchonisation
01 = Asynchronous
10 = Adaptive
11 = Synchronous
Bits 5..4 = Usage Type (Iso Mode)
00 = Data Endpoint
01 = Feedback Endpoint
10 = Explicit Feedback Data Endpoint
11 = Reserved
Maximum Packet Size this endpoint is capable of sending or receiving
Interval for polling endpoint data transfers. Value in frame counts. Ignored for Bulk & Control Endpoints.
Isochronous must equal 1 and field may range from 1 to 255 for interrupt endpoints.
( 2.3.11 SYSTEM CIRCUITS :: Peripheral Buses :: Universal Serial Bus (USB) ) Page -14 Pipes
= Representation of data movement between host software (via Memory Buffers) and endpoints on devices
Transfer-Type
Pipe Mode
Description
Transaction Packets
Control
Message
Control Pipe
Bulk
Stream
Data Pipe
Interrupt
Stream
Data Pipe
Isochronous
Stream
Data Pipe
Pre-negotiated bandwidth (streaming real time transfers) guaranteed data rate (audio / video)
D. Physical Layer
1. Device Introduction ( ie: Device is plugged physically into a USB port )
a) SE0 State - Single-Ended '0' = Both data-lines are at GND indicating a reset-device or no-device connected state.
b) J-State
- Idle State
= Device pulls a data line high (D+(full speed) /D- (low-speed)) over-ridding the hosts SE0 initial state and setting / defining the J-State.
c) K-State
- Opposite J-State = The differential data-lines pair implement NRZI line coding data representation.
d) NRZI line coding = Non Return to Zero Inverted
'0' = D+/D- compliment (ie: Inverse) previous voltage levels (ie: J K or K J)
'1' = No-change on D+/D- through a data cycle.
e) Reset / Data Polling
USB 2.0
= Host controller polls the bus for traffic (throughput is the slower one of either host / device )
USB Reset
= A Prolonged (10 to 20 mS) of the SE0-State
Low-Speed USB = Requires a Keep-Alive signal (An EOP) every 1 ms to keep device from entering suspended mode.
2. Packet Communications
(8)bit bytes least significant bit (NOTE: not byte) first (LSb)
a) Sync = Initiates communication and synchronizes / defines the data cycle speed (ie: Clock) All packets begin with a 'Sync'
Host drives 'Sync' signals on the data lines that determines the data cycle speed and signals the start of a packet communication.
USB Low/Full Speed Length: 1-byte (ie: 8-bits)
USB High-Speed Length:
4-bytes (ie: 32-bits)
Contains:
'0000_0001' (ie: KJKJKJKK states) same KJ repeat for 32-bit ending with a double KK which signals ( end-of-sync start-of-PID)
b) PID = Packet ID The Packet Type being communicated (e.g. Token, Data, Handshake, Special)
Length:
1-byte (ie: 8-bits)
Contains: [ 4-bit PID Value | 4-bit Inverted PID Value ]
Type
Reserved
Token
Special
Handshake
PID value
Transmitted byte
(msb(lsb-first)
first)
Name
Description
0000
0000 1111
1000
0001 1110
SPLIT
High-bandwidth (USB 2.0) split transaction. Sends data at high-bandwidth to a high-bandwidth HUB where it
will be transferred to a full/low bandwidth to slower devices.
0100
0010 1101
PING
Check if endpoint can accept data (USB 2.0) after getting a 'NYET'
PRE
Low-Speed packet preamble for HUB (USB 2.0 devices ignore this packet)
ERR
Split transaction error from a HUB (USB 2.0 devices ignore this packet)
1100
0011 1100
0010
0100 1011
ACK
1010
0101 1010
NAK
0110
0110 1001
NYET
Data not ready yet; Device isn't ready to receive another packet yet (USB 2.0 ONLY)
1110
0111 1000
STALL
( 2.3.11 SYSTEM CIRCUITS :: Peripheral Buses :: Universal Serial Bus (USB) ) Page -15-
0001
1000 0111
OUT
1001
1001 0110
IN
0101
1010 0101
SOF
1101
1011 0100
SETUP
Token
|4-bit ENDP #
to host
STALL)
a Host-ACK.
|5-bit CRC
|EOP ]
Data Transfers includes: [IN/OUT/SETUP Token] [Data Packet] [ACK Handshake Packet]
Payload Size Limits: HS 1024-bytes, FS 64-bytes, LS 8-bytes ( 2-packet type provides 1-bit seq number req by Stop-and-Wait ARQ.)
Data
0011
1100 0011
DATA0
1011
1101 0010
DATA1
0111
1110 0001
DATA2
1111
1111 0000
MDATA
3. CIRCUIT THEORY
Circuit Purpose Groups
Processors
Digital Logic
Frequency
Period = 1 / Frequency
Frequency = 1 / Period
= 0.500
1/3 = 0.333
Per (<>1)
mS = Hz
(=1)
kHz(k)
uS = kHz
nS = MHz
Mega(M)
Giga(G)
3.1 Analog
1. Power / Ohms Law
a) Power(Watts) = Current(I-Amps) * Voltage(V-Volts)
b) Ohms Law:
.
/\
Picturing the diagram; Cover the Letter for the item you want to find. (V=Volts, I=Amps, R=Ohms)
.
/V\
Find V (cover V whats left?) V = I * R
.
/-----\
Find I (cover I whats left?) I = V / R
.
/I |R\
R=V/I
.
^^^^^^^
Power = V * I; So we can replace any item in the power equation for derived equations
.
Ex. Power = (I*R) * I = I^2 * R
2. OpAmp
3. Transformer
3.1.1 Analysis
http://coen.boisestate.edu/bobhay/ece210/
Chapter 1 Current, Voltage, and Resistance
Charge Quantity of electricity
1 C (Coulomb) = 6.24 x 1018 electrons
Current [I or i] rate of charge flow
Charge to Current equation
I[A] = dq/dt [coulombs/second]
Current to Charge equation
Q[C] = I[A] dt + q(0)[C]
Q(0) is charge at t=0
Voltage The energy(work) required to move electricity
V = dw/dq = (w)energy[Joules]/(q)charge[Coulombs]
Power rate of energy absorption/expension
P[W] = VI = dw/dq * dq/dt ->then = dw/dt (Watts)
Or w[J] = p dt + w(0)[J]
1 Joule = 1Watt/Sec
1 KJ = 1 KW/s
1 KWH = 3600KJ
Prefix
yotta
zetta
exa
peta
tera
giga
mega
kilo
hecto
deca
Symbol
Y
Z
E
P
T
G
M
k
h
da
deci
centi
milli
micro
nano
pico
femto
atto
zepto
yocto
d
c
m
n
p
f
a
z
y
10n
1024
1021
1018
1015
1012
109
106
103
102
101
100
101
102
103
106
109
1012
1015
1018
1021
1024
Nodal analysis
Current out of node (+)
Node V far side V
Thevinens
Rth = Voc/Isc
3.1.2 Transistors
a) NMOS
b) PMOS
Circuit Analysis
Fist step is to find the DC voltage Ratings.
From here we can find Ve because of the 0.7V drop from base to emitter of the NPN Transistor
Now we can find the current through the emitter by ohms law on the emitter resitor
Because of a very small base current we can assume that the collector current through Q1 is approximately the same as the emitter current in Q1, therefore we
can find the voltage drop across the collector resistor by using ohms law.
Then we can find the collector voltage on Q1 by subtracting Vr9 from Vcc
Then we can find voltage from collector to emitter by subtraction.
(For normal operation should be Vcc)
We then do the same process for the second part of the dual stage amplifier to get:
Before
We
we can apply gain we must find the actual input AC voltage though at the base. Notice:
can draw the Thevenins equivalent circuit as shown to the left. By this we mean that the source AC goes
through R5 but is also dropped to ground through R1||R3||Zin (Zin of the base of Q1). The total Zin was found
previously to be 403 Ohms. Therefore, the actual input AC is equal to the value in the center of two series
resistors, the first being R2 and the seconds is the resistance from the base to ground of the transistor.
So the
actual AC input voltage is:
(The actual input AC voltage)
With this input voltage we can then find the approximate output voltage by Total Gain:
Different Approach
A different approach to analyzing the above circuit would to find amplifier stage gains without including the load. For example, instead of including Zin of the
next stage, find gain without a load at the output of each amplifier stage. Then one could Thevenize the circuit into three different circuits as shown below:
In the first schematic, we show how we came up with input voltage of 889uV as shown above. The unloaded voltage gain of the first amplifier will be found by:
Then 889uV x 9.59 = 8.53mV
The unloaded gain of the second stage is done exactly the same way. Gain=32 unloaded
After solving the second schematic we find the input voltage into the load with a gain of 32 is 126.4mV.. Finally the output must be divided by the collector
resistor ground and the Load resistance to ground giving us a final Vout of 63.2mV which is approximately the same answer as doing things the other way.
3.1.3 Inductors/Coils
A. Series RL AC Circuits - Low Pass Filtering
Frequency Cutoff
(Frequency cut off is when Inductive Reactance (XL) equals Resistance)
(Rearranged equation from above when Xl=6.28LF)
(This is a slow curved process, cutoff is just a standard)
Cutoff with Inductive reactance passes low frequencies and filters high frequencies.
As shown by the oscilloscope, current leads the voltage or voltage lags the current.
Inductive Reactance
(Where L=Inductor (Henrys) and F=Frequency (Hertz))
(Inductive Reactance always 90degrees)
Inductive Impedance
On the HP48G+ enter polar mode by right shift (MTH), then enter polar numbers in (xx) with<
This can also be found by graphing or Trigonometry as shown below:
As shown by the graph, for solving Z one can use the hypotenuse equation:
Hypotenuse equation
4.
5. Diode
6. Capacitor
7. Inductor (ie: coil)
8. Resistor
3.2 Digital
Combinational Logic Circuits
Sequential Logic
Synchronous Sequential
Asynchronous Sequential
A. Algorithmic Circuits
Algorithmic
Sub-Level Blocks / Sub-Circuits For Logic / Math / Memory
Functionality defined by operation (No hardware implementation details), ALU, RAM, CU
Algorithm level;
much like c-code with if, case, loop statements
Example; 'Z=X+Y' for 32-bit adder
B. Arithmetic Circuits
Arithmetic Circuits (for numeric functions) are Combinational Circuits
Number representation (Encoders/Decoders)
B.2 Adder
Math Circuits ( Subtraction is done by changing negative number to 2s Compliment and then adding )
Half-Adder(HA) - 2-binary bit (b1, b2) addition circuit with 'carry' and 'sum' bits.
Full-Adder(FA) - 2-binary bit (b1, b2) addition circuit with a 'carry-in' bit for extra bit addition (Created from 2 Half-Adder circuits and an OR
gate).
Ripple Carry Adder (RCA)
http://en.wikipedia.org/wiki/Adder_%28electronics%29
B.3 Boolean Algebra
Mathematics sector used to represent Logical-Circuits and reduce them to simplest terms.
1. Gate Representation (In precedence order of operations)
a) ' (!~) - NOT - L(x,y) = x' + y';
NOT(X) OR NOT(Y) also line above; cant make on PC
b) * (^) - AND - L(x,y) = xy;
X AND Y; Intersection of X & Y "product"
c) + (v) - OR - L(x,y) = x + y;
X OR Y;
Union of X & Y
"sum"
2. Axioms
a)
b)
c)
d)
e)
3.
AND
0*0=0
1*1=1
0*1=1*0=0
If x=0 {x'=1}
Theorems
a)
AND
b)
x*0=0
c)
x*1=x
d)
xx=x
e)
x!x=0
f)
!!x=x
OR
1+1=1
0+0=0
1+0=0+1=1
If x=1 {x'=0}
OR
x+1=1
x+0=x
x+x=x
x+x'=1
4. Principle of Duality - An equations dual is obtained by replacing all + with * and 0s with 1s or visa versa. (as shown above)
a) If x,y,z are variables in B(equation) then the following properties hold true.
b)
AND
OR
c)
x*y = y*x
x+y=y+x
// Commutative
// Huntington's Basic Postulate
d)
x*(y*z)=(x*y)*z
x+(y+z)=(x+y)+z
// Associative
e)
f)
g)
h)
i)
j)
x*(y+z)=x*y+x*z
x+y*z=(x+y)*(x+z)
// Distributive
// Huntington's Basic Postulate
x+x*y=x
x*(x+y)=x
// Absorption
xy + xy! = x
(x+y)(x+y!)=x
// Combining
!(xy)=!x+!y
!(x+Y)=!x!y
// DeMorgan's theorem
x+!xy=x+y
x(!x+y)=xy
xy+yz+!xz=xy+!xz
(x+y)(y+z)(!x+z)=(x+y)(!x+z)// Consensus
All other theorems and properties can be derived from the 'Huntingtons Basic Postulates'
These are fundamental concepts of the Synthesis process in CAD::EDA design tools
k) Venn diagram - A pictorial representation in which "sets" are represented by circles or other shapes.
3.2.3 Gates/Flip-Flops(FF)
Logic Gates
switch
= standard / common switch-circuit designs created specifically for handling basic digital logic.
= transistors used for digital purposes
Only on=1 / off=0 states are relevant
Buffers
Separate Drive from Pin
Tri-State (ie: Transmission Gate) buffers allow pins to be either output-driven or 'Z' dis-connected; thus tri-state 1,0,Z
Short-Circuit Prevention when two device outputs share a common wire (One drives while the other in 'Z' high impedance / disconnected )
Register = Collection of Asynchronous Flip-Flops (ie: Latch)
16-bit register ~ 16 latches
Flip-Flops(FF)
Flip-Flop
D
= Common logic-gate circuit design that can retain logic levels through time (e.g. memory)
Q = Output
Description
D=Q
&
SR
Set / Reset
JK
J=Set,
K=Reset
~&
Latch
D=Q
Logic Gates
Logic Gates
NOT
AND
OR
NAND
NOR
XOR
XNOR
Inverse
All-Input-AND
All-Input-OR
NOT AND
NOT OR
Exclusive OR
Exlusive NOT OR
Verilog
~
&
|
~&
~|
^
~^
Input Output
1 0 / 0 1
1,1,1(all) 1 ELSE 0
0,0,0(all) 0 ELSE 1
NOT(AND)
NOT(OR)
0,1,0(1-1) 1 ELSE 0
NOT(XOR)
Propagation delay (ie: Gate Delay) = The time it takes for a digital logic gate to register a result
7400 IC Gates typically have a gate delay of around 10 2 nanoseconds; thus can only operate at 100 500MHz frequency correctly
Inside modern CPU's with speeds of up to 3.5GHz requires gates that respond with a delay of around 280pS (picoseconds)
3.2.4 Market
A. 7400-Series ICs
Labeling Notations
'L' = TTL (74LS00)
'H' = CMOS (74HC00)
Notes
7400-Series buffers are about the only 7400 chips still in use today (74244);
7400-Series SSI-Small Scale Integration technology to make the ICs.
162244 (SOIC-Package, much smaller & more devices)
http://en.wikipedia.org/wiki/7400_series
= Converts an Analog Input to a Digital Number (ie: Voltage level Digital Number )
= Converts a Digital Number to an Analog Output (ie: Digital Number Voltage Level )
Entry Categories
Behavioral
- How the circuit behaves (e.g. What a house does)
Structural
- How the circuit is connected (e.g. House blue-prints)
Entry Abstraction Layers ( Most abstract to least abstract )
Architectural
- Design in terms of functional blocks (IP-Cores)
Algorithmic
- Design in terms of math function (behavioral)
Register Transfer Level (RTL)
- Design in terms of logic and storage devices
Gate level
- Design in terms of logic comparison gate components
Switch level
- Design in terms of transistor switches or discrete devices
4.1 Planning
Purpose/Goal
Specifications
Block Diagram
I/O Interfaces
Interconnects
Feasibility
IP-Cores typically have Interconnection Standards (ie: System Buses) that need to be considered.
List of places to get IP-Cores
http://www.opencores.org/
http://www.geocities.com/SiliconValley/Pines/6639/ip/memory_cores.html
- Free Memory Cores
http://www.estec.esa.nl/wsmwww/erc32/ - An ERC32 (radiation-tolerant SPARC V7) processor developed for space applications.
http://www.cmosexod.com/freeip.htm
- 12bit DSP core / peripherals, 8bit CISC processor, frequency counter, SDRAM Controller
http://young-engineering.com/intellectual_property.html
http://www.freerangefactory.org/cores/
Companies that sell IP-Cores
http://www.smart-dv.com/
http://www.wipro.com/
http://www.hcl.com/
Variations / Extensions
Actel HDL (AHDL)
Altera HDL (AHDL)
SystemC
Verilog-A
BlueSpec Verilog
= Is a C++ library (TLM - Transaction Level Modeling) much higher-level than RTL
= Analog design extension for Verilog
= Atom System Verilog (Guarded atomic actions); Is a Verilog Simulation extension package.
Historical
ABEL
From 1981
PALASM PAL HDL from 1980s
see http://en.wikipedia.org/wiki/Advanced_Boolean_Expression_Language
see http://en.wikipedia.org/wiki/PALASM
Behavioral Code = Verb Emphasis ( Sequential / Procedural ); describes IO responses; what it does or how it behaves.
Algorithm level code
Register Transfer level(RTL) code
Structural Code
= Noun Emphasis (Concurrent); Tying together gate/transistor level components (verbal wiring w/o storage)
HDL code that is used only for simulation and verification purposes
HDL Terms
Sub-Circuits are sometimes called macro-functions, mega-functions or IP-Cores
Technology Dependent Macro-function
= circuit design for a specific type of chip
Technology Independent Macro-function
= circuit design that can be implemented in any type of chip.
LPM + Library of Parameterized Modules = Circuit Library that is technology independent. 'lpm_add_sub'
Coding Practices ( Typically Job specific no real standard )
Use
For
Postfix
For
addr Address
_n
Active Low
clk
Clock
_r
Register
rst
Reset
_#r
Pipeline #
Use For
Internal signal
read-write
--[ References ]---------------------------------------------------------------------------------------------------------------------------------------------------HDL examples including I/O Hardware Interfaces and descriptions http://www.fpga4fun.com/
HDL Coding Styles
http://www.maia-eda.net/index.php?option=com_content&task=view&id=121&Itemid=258
VHDL Primer
http://www.seas.upenn.edu/~ese171/vhdl/vhdl_primer.html#_Toc526061348
MIT-Press Circuit Design with VHDL
http://profs.basu.ac.ir/abdoli/upload_file/722.file_ref.1121.1422.pdf
Online HDL Simulator
http://www.edaplayground.com
4.3.1 Verilog
See Also
http://www.doe.carleton.ca/~jknight/97.478/97.478_02F/PetervrlQ.pdf
A. Module
// Module = A named sub-circuit with an external interface
module learnbasic(input wire
ClkIn,
RstIn,
ReqIn,
// Port = External connection. (type
input [7:0] AddTo7,
HalfIn,
ShifLft,
//
- 'input' (type wire only)
inout [7:0] DataLine, Trans1,
Trans2,
//
- 'inout' (type wire only)
output wire
ClkLight, RstLight, ReqLight,
//
- 'output' (any net type)
output reg
BcdOut1, BcdOut2, BcdOut3, OddIn7,
output [7:0] Sum7,
HalfOut, Shift,
output [15:0] HWord1,
HWord2,
HWord3,
output [31:0] Word1,
Word2,
Word3); // [msb:lsb] bundle/bus
B. Parameter
parameter WIDTH = 5;
// assign/drive net-connectors only once ELSE U-get "Error 10028 Can't resolve multiple constant drivers for net "?"."
C. Connectors
line
//--Internal connectors--//
wire [7:0]Sum,DivOut = 0;
wand [7:0]Active;
wor a;
tri b;
////
// // // // -
supply0 Gnd;
supply1 Vcc;
reg [7:0]OperReg = 0;
wire Enable,EnableN;
//
//
//
//
D. Bit-Literals
//--[ Drive-Line
assign
Word2 =
assign
Word3 =
reg [7:0]Div2 =
reg [7:0]Seven =
assign
W8C
=
]--//
123;
32'd123;
8'b0000_0010;
8'h7;
8'o377;
E. Logic Gates
//--[ Logic Gates ]--//
not(Active[0],RstIn);
buf U1(DataLine,A8);
assign EnableN = ~Enable;
assign Enable = ClkIn & RstIn;
notif0(Trans1,DataIn1,EnableN);
bufif1(Trans2,DataIn2,Enable);
//// Primitives
+--------------------------------------------------------------// Gate-Syntax
| not(o,i)
= '~'
notif(o,i)
notif0()
notif1()
// Named 'U1'
| buf(o,i)
bufif(o,i,e)
bufif0()
bufif1()
// BitWise-Syntax
| and(o,i..) = '&'
or() = '|'
xor() = '^'
//
| nand(o,i..) = '~&'
nor() = '~|'
xnor() = '~^'
// Not-gate with a Tri-state output and an active-low('if0') enable.
// Buffer with a Tri-state output and an active-high('if1') enable.
F. Algorithmic
//--[ Algorithmic ]--//
assign
Sum7
= AddTo7 + Seven;
assign
HalfOut = HalfIn / Div2;
assign
Shift
= HalfOut << 1;
assign
HWord1 = {1'b0,Sum7[6:0],Shift};
assign
Word1
= {2{HWord1}};
Sum7 <= Sum7 << 1;
H. Compiler Directives
'timescale 1 ns/ 1 ps
'define name code;
'include filename.v;
I. Behavioral (Always@)
// BEHAVIORAL - Sequential/Procedural logic (RTL-Modelling) ( Cannot assign net-connectors; only registers and variables )
always @(posedge ClkIn) begin
reg m; // local
I.1 If Else
BcdOut1 = (RstIn == 1) ? 0: 1;
// '?:' IF...THEN
if(ClkIn == 1 && RstIn != 1) BcdOut2 = 1;
// '=='
EQUALS
Not Equal
else if (RstIn == !ReqIn || ClkIn == 0) BcdOut3 = 1; // '!'
NOT
'||'
OR
I.2 Case
if(ClkIn == 1) begin
case(AddTo7)
8'b0 : OddIn7 <=
8'b1 : OddIn7 <=
8'd3 : OddIn7 <=
default : OddIn7
endcase
end
1;
1;
1;
<= 0;
// casex() to allow 'X', casez() to allow 'Z' and wild-card '?' but not 'X'
// '<=' is for Synchronous logic where RHS is evaluated but only assigned on next trigger.
end
// SIMULATION - Testbench
initial begin
// Executed once at very beginning of simulation
end
J. Task
task DoSomething;
$display("Hi");
endtask
time z;
//{SO}
//{SO}
//{SO}
//{SO}
//{SO}
initial
wait(%condition)
#5 a = 20
c = #5 a;
fork...join
endmodule
module SubCircuit#(parameter PassedParam = 5)(input one, output two);
assign two = ~one;
endmodule
:
:
:
:
dmux_in
dmux_sel
dmux_out
: IN
: IN
: OUT
STD_LOGIC
:= '0';
STD_LOGIC
:= '0';
STD_LOGIC_VECTOR ( 1 DOWNTO 0) := "00"; -- Initial Value on both wires is '0'
add_in1
add_in2
add_sum
add_carry
:
:
:
:
clk_in
clk_out
: IN
STD_LOGIC
: BUFFER STD_LOGIC
SegDisplay
END EntityName;
IN
IN
IN
OUT
IN
IN
OUT
OUT
: OUT
STD_LOGIC
STD_LOGIC
STD_LOGIC
STD_LOGIC
:=Initial Value
:= '0';
:= '0'; -- SR Latch debounce requires double-throw switches (on/off)
:= '0'; -- Buffers allow output to be wired to other internal circuits
:= '0'; -- Inverted 'debounce_out'
:=
:=
:=
:=
'0';
'0';
'0';
'0';
:= '0';
:= '0';
-- 7 Segment Display
C. ARCHITECTURE (Declarations)
SIGNAL / CONSTANTS / TYPE / SUBTYPE definition area local to the Architecture
FUNCTION / PROCEDURE / COMPONENT declarations are generally declared here.
--====================================================================================================================
ARCHITECTURE ArchitectureName OF EntityName IS
--====================================================================================================================
--[ Inter-Architecture ]----------------------------------------------------------------------SIGNAL ABitIs1
: BIT;
SIGNAL Bit1
: BIT;
-- BIT is a basic data type
SIGNAL Bit2
: BIT;
SIGNAL Bits
: BIT_VECTOR(1 DOWNTO 0);
SIGNAL Bits_n
: BIT_VECTOR(1 DOWNTO 0);
SIGNAL Bits_0
: BIT_VECTOR(3 DOWNTO 0);
SIGNAL Bits_1
: BIT_VECTOR(3 DOWNTO 0);
SIGNAL add_sum_full
SIGNAL debounce_tmp
: STD_LOGIC_VECTOR (ADD_BITS DOWNTO 0); -- +1 bit for full add sum of other 2.
: STD_LOGIC;
SIGNAL StateClk
: STD_LOGIC;
SUBTYPE TwoBits
: STD_LOGIC_VECTOR(1 DOWNTO 0);
TYPE States IS ( Display1, Display2, Display3, Display4 );
TYPE SegMem IS ARRAY ( 1 TO 4 ) OF STD_LOGIC_VECTOR(6 DOWNTO 0);
CONSTANT SegROM
: SegMem := (x"F",
x"FF",
x"FF",
x"A");
-----
-----
index(1);
index(2);
index(3);
index(4);
Bits
Bits
Bits
Bits
on
on
on
on
7
7
7
7
Segment
Segment
Segment
Segment
display
display
display
display
to
to
to
to
show
show
show
show
a
a
a
a
'1'
'2'
'3'
'4'
C.1 COMPONENT
--[ Declare ]---( Re-Use )------------------------------------------------------------------------COMPONENT mitDFF
GENERIC( RisingEdge
: BOOLEAN
:= TRUE );
PORT(
d: IN STD_LOGIC;
clk: IN STD_LOGIC;
rst: IN STD_LOGIC;
q: OUT STD_LOGIC);
END COMPONENT;
C.2 CONFIGURATION
When VHDL comes across a COMPONENT declaration how does it know the COMPONENT class is associated to the ENTITY? Answer: They both have
the same name.
Actually every COMPONENT declaration has a configuration and the configuration that says use the same-named ENTITY is the VHDL default
configuration.
The CONFIGURATION block allows the designer to specifically assign a COMPONENT Instance to an associated ENTITY.
-- Select a given architecture for your component instance
CONFIGURATION AnyConfigName OF
--(The Entity ----> Architecture ----> Instance
: OfComponent) will point to (Library.Entity(Architecture))
MyEntity IS FOR MyArchitecture FOR MyInstance : OfComponentName USE ENTITY LibraryName.EntityName(ArchitectureName);
end for; end for;
END CONFIGURATION;
Typically the CONFIGURATION block will be in a Tree structure which will allow multiple assignments to parent level FOR
-- Why are two 'for' statements are nested? All 'for Instance'(s) under the main 'for Architecture'
acrchitecture' designated.
CONFIGURATION ForMyEntity OF MyEntity IS
FOR MyArchitecture
FOR MyFirstInstance
: OfComponentName use entity work.ComponentOne(Synchronous_Arch); END
FOR MySecondInstance : OfComponentName use entity work.ComponentOne(Asynchronous_Arch); END
FOR OTHERS
: OfComponentName use entity work.ComponentOne(MixedSignal_Arch); END
END FOR;
END CONFIGURATION;
FOR;
FOR;
FOR;
CONFIGURATION blocks are typically defined at the end of the VHDL code which uses the COMPONENT definition.
<=
<=
<=
<=
'1';
( 0 => NOT Bit1, 1 => NOT Bit2 );
(
Bit1,
Bit2 );
( OTHERS => '0' );
-----
'<=' assign;
'=>' Named connection;
Positional connection;
'OTHERS' keyword;
'ABitIs1' = '1'
connect Bits_n(0) to 'NOT Bit1' etc...
connect Bits(0) to 'Bit1' etc...
connect all other un-assigned bits to '0'
<= debounce_off
<= debounce_on
<=
NAND
NAND
NOT
debounce_out;
debounce_tmp;
debounce_out;
D.3 GENERATE
--[ GENERATE (Structural) ]--------------------------------------------------------------------G1: FOR i IN Bits_1'RANGE GENERATE
Bits_1(i) <= '1';
END GENERATE;
D.4 WHEN...ELSE
--[ WHEN...ELSE (Structural) ]-----------------------------------------------------------------dmux_out <= '0' & dmux_in
dmux_in & '0'
"ZZ"
"--";
D.5 WITH...SELECT
--[ WITH...SELECT (Structural) ]----------------------------------------------------------------WITH (mux_sel) SELECT
mux_out <=
mux_in1
mux_in2
UNAFFECTED
WHEN '0',
WHEN '1',
WHEN OTHERS;
E.2 IF...THEN
IF <condition> THEN <assign>; ELSIF <condition> THEN <assign>; ELSE <assign>; END IF;
--vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
PROCESS(rising_edge(clk_in))
VARIABLE clkcnt : INTEGER := 0;
BEGIN SYNCHRONOUS
--[ IF...THEN (Sequential) ]------------IF clkcnt = CLK_DIV THEN
clkcnt := 0;
-- Reset 'clkcnt'
clk_out <= NOT clk_out;
-- Toggle 'clk_out'
ELSIF clkcnt < 0 THEN
clkcnt := 0;
ELSE
clkcnt := clkcnt + 1;
END IF;
END PROCESS;
E.3 WAIT
WAIT Command is typically used only for Testbench Code; See Simulation
WAIT FOR <signal condition>;
WAIT ON <signals>;
WAIT UNTIL <time>;
E.4 CASE...WHEN
--[ CASE...WHEN (Sequential) ]------------CASE State IS
WHEN Display1 =>
StateAsInt := 1;
NextState := Display2;
WHEN Display2 =>
StateAsInt := 2;
NextState := Display3;
WHEN Display3 =>
StateAsInt := 3;
NextState := Display4;
WHEN OTHERS =>
NextState := Display1;
StateAsInt := 4;
END CASE;
E.5 FOR...LOOP
--[ FOR...LOOP (Sequential) ]--------------FOR i IN SegROM'LOW TO SegROM'HIGH
LOOP
IF ( i = StateAsInt ) THEN
-- Find the 'SegROM(index)' for the State.
SegDisplay <= SegROM(i); -- Drive the 'SegROM(i)' to the display to show the 'State' number.
EXIT;
-- Break out-of-loop
ELSE
NEXT;
-- Example of continuing loop w/o finish.
END IF;
END LOOP;
E.6 WHILE...LOOP
--vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
PROCESS
-- No sensitivity list when using 'WAIT'
VARIABLE State
: States
:= Display1; -- Data Type 'States' is User-Defined.
VARIABLE NextState
: States
:= Display1;
VARIABLE StateAsInt
: INTEGER
:= 0;
BEGIN -- SYNCHRONOUS
WAIT ON StateClk;
-- 'WAIT ON' is same as 'PROCESS (StateClk)' must be first line after BEGIN
--[ CASE...WHEN (Sequential) ]------------CASE State IS
WHEN Display1 =>
StateAsInt := 1;
NextState := Display2;
WHEN Display2 =>
StateAsInt := 2;
NextState := Display3;
WHEN Display3 =>
StateAsInt := 3;
NextState := Display4;
WHEN OTHERS =>
NextState := Display1;
StateAsInt := 4;
END CASE;
--[ FOR...LOOP (Sequential) ]--------------FOR i IN SegROM'LOW TO SegROM'HIGH
LOOP
IF ( i = StateAsInt ) THEN
-- Find the 'SegROM(index)' for the State.
NEXT;
END IF;
END LOOP;
------
LOOP
END LOOP;
END PROCESS;
END ArchitectureName;
F. PACKAGE
-===============================================================================================================================================
====
-- PACKAGING
( Creating Custom Libraries )
-===============================================================================================================================================
====
--[ PACKAGE ]--- packages COMPONENTS, FUNCTIONS, and PROCEDURES into a "library"
-- Abstraction in a Package has a declaration (.header) and architecture (PACKAGE BODY).
-- (.header) can exist by itself when only TYPE/CONSTANTS are being declared.
PACKAGE BasicTraining IS
-- Define an ENTITY as a COMPONENT for Re-Use (Definition is a copy of the ENTITY w/o the ARCHITECTURE)
COMPONENT EntityName IS
GENERIC ( -- Constructor / Instance Arguments -ADD_BITS : INTEGER
:= 4;
-- Bit count for 'add'
CLK_DIV : INTEGER
:= 15);
-- Clock Divider by
PORT ( -- External Connectors --ID
: Mode
DataType
debounce_on
: IN
STD_LOGIC
debounce_off
: IN
STD_LOGIC
debounce_out
: BUFFER STD_LOGIC
debounce_out_n
: OUT
STD_LOGIC
mux_in1
mux_in2
mux_sel
mux_out
:
:
:
:
dmux_in
dmux_sel
dmux_out
: IN
: IN
: OUT
STD_LOGIC
:= '0';
STD_LOGIC
:= '0';
STD_LOGIC_VECTOR ( 1 DOWNTO 0) := "00"; -- Initial Value on both wires is '0'
add_in1
add_in2
add_sum
add_carry
:
:
:
:
clk_in
clk_out
: IN
STD_LOGIC
: BUFFER STD_LOGIC
SegDisplay
END COMPONENT;
IN
IN
IN
OUT
IN
IN
OUT
OUT
: OUT
STD_LOGIC
STD_LOGIC
STD_LOGIC
STD_LOGIC
:=Initial Value
:= '0';
:= '0'; -- SR Latch debounce requires double-throw switches (on/off)
:= '0'; -- Buffers allow output to be wired to other internal circuits
:= '0'; -- Inverted 'debounce_out'
:=
:=
:=
:=
'0';
'0';
'0';
'0';
:= '0';
:= '0';
-- 7 Segment Display
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
END FUNCTION DoSomething;
END PACKAGE BODY BasicTraining;
-- ASSERT("Hi");
END TestBench;
-- PROCESS cannot have sensitivity list when using WAIT; Not part of sensitivity list
-- WAIT must be first statement in a No %sensitivy_list PROCESSS; WAIT ON clk is same as PROCESS(clk);
-- (Simulation Only)
entity test_counter is
PORT ( count : BUFFER bit_vector(8 downto 1));
end;
architecture only of test_counter is
COMPONENT counter
PORT ( count : BUFFER bit_vector(8 downto 1);
clk
: IN bit;
reset : IN bit);
END COMPONENT ;
SIGNAL clk
: bit := '0';
SIGNAL reset : bit := '0';
begin
dut : counter
PORT MAP (
count => count,
clk => clk,
reset => reset );
clock : PROCESS
begin
wait for 10 ns; clk
end PROCESS clock;
stimulus : PROCESS
begin
wait for 5 ns; reset
wait for 4 ns; reset
wait;
end PROCESS stimulus;
<= '1';
<= '0';
end only;
B. ClockDiv Circuit
------------------------------------------------------------------------------------------------------------------------------------------------ ClockDiv Circuit Design
----------------------------------------------------------------------------------------------------------------------------------------------library ieee;
use ieee.std_logic_1164.all;
entity ClockDiv is
generic ( div: integer :=15 );
port ( clkin: in std_logic; clkout: out std_logic);
end ClockDiv;
architecture ClockDiv of ClockDiv is
begin
process(clkin)
variable output : std_logic;
variable clkcnt : integer := 0;
begin
if rising_edge(clkin) THEN
clkcnt := clkcnt + 1;
if clkcnt = div then
clkcnt := 0;
output := NOT output;
else
NULL;
end if;
else
NULL;
end if;
clkout <= output;
end process;
end ClockDiv;
C. Package Example
------------------------------------------------ work.AnEntity with multiple architectures
----------------------------------------------LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY AnEntity IS
GENERIC (PropTime : TIME := 5 ns);
PORT
(OutPin : OUT STD_LOGIC);
END AnEntity;
ARCHITECTURE FirstArch OF AnEntity IS BEGIN
OutPin <= '1' after PropTime;
END FirstArch;
ARCHITECTURE SecondArch OF AnEntity IS BEGIN
OutPin <= '0' after PropTime;
END SecondArch;
ARCHITECTURE AnyOthers OF AnEntity IS BEGIN
OutPin <= 'Z' after PropTime;
END AnyOthers;
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------------------------ MyEntity that will configure various
-- architectures of component 'AnEntity'.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
----------------------------------------------ENTITY MyEntity IS
GENERIC
(EntityArg : TIME := 5 ns);
PORT
(PINS : OUT STD_LOGIC_VECTOR(2 DOWNTO 0) );
END MyEntity;
----------------------------------------------ARCHITECTURE MyEntity OF MyEntity IS
COMPONENT UseConfiguration IS
GENERIC (TimeNS : TIME);
PORT (Output : OUT STD_LOGIC);
END COMPONENT;
BEGIN
MyFirstInstance : UseConfiguration GENERIC MAP (10 ns) PORT MAP (PINS(0));
MySecondInstance : UseConfiguration GENERIC MAP (5 ns) PORT MAP (PINS(1));
SomeOtherInstance : UseConfiguration GENERIC MAP (1 ns) PORT MAP (PINS(2));
END MyEntity;
----------------------------------------------CONFIGURATION OfMyEntity OF MyEntity IS
FOR MyEntity
FOR MyFirstInstance
: UseConfiguration use entity work.AnEntity(FirstArch)
-- Resolve pin mismatches between 'AnEntity' => 'UseConfiguration' COMPONENT
-- GENERIC MAP and PORT MAP are NOT-NEEDED if the Pin Names in COMPONENT declare
-- are the same as the 'AnEntity' ENTITY.
GENERIC MAP (PropTime => TimeNS) PORT MAP (OutPin => Output); END FOR;
FOR MySecondInstance : UseConfiguration use entity work.AnEntity(SecondArch)
GENERIC MAP (PropTime => TimeNS) PORT MAP (OutPin => Output); END FOR;
FOR OTHERS
: UseConfiguration use entity work.AnEntity(AnyOthers)
GENERIC MAP (PropTime => TimeNS) PORT MAP (OutPin => Output); END FOR;
END FOR;
END CONFIGURATION;
----------------------------------------------LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY TestBench IS END TestBench;
ARCHITECTURE TestBench OF TestBench IS
SIGNAL CheckPins : STD_LOGIC_VECTOR(2 DOWNTO 0);
COMPONENT MyEntity IS
GENERIC
(EntityArg : TIME := 5 ns);
PORT
(PINS : OUT STD_LOGIC_VECTOR(2 DOWNTO 0) );
END COMPONENT;
BEGIN
U1 : MyEntity PORT MAP (PINS => CheckPins);
END TestBench;
D. Common Errors
VHDL Common Error Messages and Fixes
Signal does not hold value after clock edge - Only one item can be defined either at rising edge or falling edge but not both.
Multiply driven
- Same as above
clock not locally stable
- clk'EVENT cannot determine if rising/falling edge; no clk='1'
ignored unnecessary pin clk
- means PROCESS(clk) is ignored because 'clk' wasn't used in the code
4.5 Verification
Terms / Acronyms
PVT
+ Process, Voltage and Temperature Analysis
= How operation varies with varying PVT conditions.
MTBF
+ Mean Time Before Failures
=How long before design failures appear (Higher is better)
IBIS
+ Input Output Buffer Information Specifications
VCD
+ Value Change Dump (Waveform standard)
= A VCD viewer plots a wave form based on VCD-Values.
PLI
+ Programming Language Interface
= Invoking C functions from Verilog (ie: System Call)
HVL
+ Hardware Verification Langauge
= Language specifically designed for HDL verification / testbench
PSL
+ Property Specification Language
= http://www.eda.org/vfv/docs/PSL-v1.1.pdf
VIP
+ Verification IP
URM
+ Universal Reuse Methodology
= https://verificationacademy.com/topics/verification-methodolgy
UVM
+ Universal Verification Methodology
= SystemVerilog Validation - http://www.accellera.org/community/uvm/
OVM
+ Open Verification Methodology
= Documented methodology with a building block library for verification
No Timing considerations
Includes Timing Analysis (Requires Post-Synthesis NetList)
Maia Simulation
Wiki List of HDL Simulators
http://www.maia-eda.net/index.php?option=com_content&task=view&id=13&Itemid=47
http://en.wikipedia.org/wiki/List_of_HDL_simulators
Simulation Implementation
Forced Input
WaveForm
TestBench
Test Vectors
SPICE Simulation = Simulation Program with Integrated Circuit Emphasis ( SPICE Simulation often uses Schematic Entry to simulate circuit designs. )
Common SPICE Applications
NI MultiSim by National Instruments
(Previously ElectronicWorkbench)
Altium CircuitMaker
LTSpice is for transistor level model-ling.
Matlab
Details of SPICE
Synopsis owns HSPICE
Cadence owns PSPICE OrCad contains PSPICE simulation.
ADICE Analog Devices
LTSPICE Linear Technology
--[ References ]---------------------------------------------------------------------------------------------------------------------------------------------------Contains full details about categories, scale integration, fabricating & packaging, and families http://en.wikipedia.org/wiki/Integrated_circuit
ASIC is used to describe custom Integrated Circuits (IC) http://en.wikipedia.org/wiki/Application-specific_integrated_circuit
A PCB with attached components is called a PCA
http://en.wikipedia.org/wiki/Printed_circuit_board
Categories
MSI
LSI
VLSI
+ Medium-scale Integration
+ Large-scale Integration
+ Very Large-scale Integration
Manufacturing Steps
Circuit Design
Data-Base Release (DBR)
Wafer Fabrication
Wafer Sort
Dice/Wire-Bond
Packaging
= Circuit is designed on computers using EDA software which typically stores circuit designs in a database
= Design is released (ie: committed) for IC/ASIC manufacturing
= Circuit design is implemented on a silicon wafers at the FAB using photo-lithography technology.
= Automatic Test Equipment (ATE) tests each Integrated Circuit(IC) on the wafer using wafer probe
= Wafers are cut (ie: Diced), put on a substrate where nodes are wire-bonded for external pins
= Substrates are then put into plastic Chip-Packages
- Blank silicon plate on which many Integrated Circuit (IC) chips are created
2. Fabrication
a) Photo-Masks are used to implant/etch/grow the N and P semiconductor regions into the Silicon Wafer
b) DIE
= One IC (ie: Chip) on a wafer
c) LOT
= Case of 25-Wafers for transport
d) Wafer Traveler
e) Process Integration (PI)
= A list of process-steps at the fabrication facility (ie: FAB) required to create the circuitry of the design
= Handles the fab processing of wafers ( ie: Traveler Steps )
- http://www.digilentinc.com/index.cfm
Xilinx
Xilinx sells Dev-Boards directly
Popular provider (AVNET)
XTEX FPGA Boards
Mojo (Open-Hardware)
Papilio (Open-Hardware)
@ http://www.altera.com/products/devkits/kit-dev_platforms.jsp
@ http://www.terasic.com.tw/en/
@ http://www.xilinx.com/products/boards-and-kits/
@ http://www.avnet.com/en-us/Pages/default.aspx
@ http://www.ztex.de/
@ http://embeddedmicro.com/
@ http://papilio.cc/
Altera Architecture
FPGA
LAB
LE
LUT
Xilinx Architecture
FPGA
CLB
Slice
LC
LUT
// Register packing - refers to the use of the LUT and FF in a logic element(LE)
Programming a FPGA/PLD
IC-Programming-Unit
In-System-Programming (ISP)
Older PLD's with PROM, EPROM or Fuse-Memory required a physical tool to program the chip.
Circuit board has a JTAG header plug-in for programming chips within the circuit.
- Copper Traces/Routes are created on fiberglass boards typically using a photo-plotter and copper
2. Part Placement
a) Through-hole Technology (THT)
CNC Milling Machine
Wave Soldering machine
c) Pick N Place
automatic equipment
Tape Reel
3. PCA Testing
a) ICT
+ In-Circuit-Test = A test instrument with a bed of nails (ie: Connectors) for measure and test the PCA
b) Flying-Probe
= Flying-Probes can also be used for a cheaper and not as thorough In-Circuit-Test
4. Functional Testing
= Finally the circuit board is powered up under normal operating circumstances and tested for sale-quality functionality.
Overview
EDA Tools were originally created on Linux OS Shells.
TCL + Tool Command Language
= Linux scripting language used heavily in EDA tool integration
EDA Tools typically contain a slew of <command>.exe files inside the tools sub-directory
commands can be invoked entirely from the OS command line.
Graphical User Interfaces (GUI) s are usually just helper tools that auto-launch commands)
SDL + Specification and Description Language
EDA Vendors (Listed by assumed popularity)
Synopsis
Synplify
FPGA design solution by Synplicity (Acquired by Synopsis in 2008)
Mentor Graphics
Leonardo Spectrum
Precision RTL
ModelSim
Cadence
Virtuoso
Allegro SPB
Spectre
OrCad
Allegro Design Entry CIS
SimVision
= Schematic editor
http://www.cadence.com/products/rf/schematic_editor/pages/default.aspx
= Design Tool Suite
= Mixed signal (chip level) Simulation
= PCB design
- Free size limited download
http://www.orcad.com/
= Component Information System
also known as OrCAD Capture CIS
= Unified graphical debugging environment (Waveform simulation)
Xilinx (FPGA/CPLD)
Vivado
Altera (FPGA/CPLD)
Quartus-II
Qsys
= Previously SOPC-Builder
Commercial
Commercial
Commercial
Commercial
OpenSource
OpenSource
Quartus Folders
Error Message Details
= Menu Help Message List
<Install-Path>/quartus/common/help/webhelp/
Altera Device List
= Menu Help Devices and Adapters
<Install-Path>/quartus/common/help/webhelp/
EDA Interfaces (Other Tools)
= Menu Help EDA Interfaces
<Install-Path>/quartus/common/help/webhelp/
Getting Started Tutorial
= Menu Help Getting Started Tutorial
<Install-Path>/quartus/common/help/tutorial/qtutorial.htm
Altera supplied IP-Cores
= Menu Tools IP Catalog (MegaWizard)
<Install-Path>/ip/altera/<IP-Core>
Generate Tcl Project Script
= Menu Projects Generate Tcl file for project
** Add <Install-Path>/quartus/bin64 to Command Line PATH to use 'quartus_sh -qhelp'
Validation Tools
Auto device selected by Fitter
Device Migration
PowerPlay Power Analyzer
Simultaneous Switching Noise (SSN)
Design Assistant
= feature that will pick a suitable Altera FPGA upon design compilation.
= tools that allow designs to move between different FGPA IC-Chips
= Estimates power usage for the Circuit implemented on a PCB board.
= Analyzes / checks for noise /distortion voltage across I/O traces.
= Checks design for adherence to Altera guidelines (Can also use a lint tool for coding style checks)
Implementation
Component names
System is synthesized
- (ie: IP-Block Names) in Qsys are used by firmware to access the hardware
- [SOF] [FPGA] [HAL] [BSP](system.h) Applicaion(?.elf)
HAL
Altera SBT (The NiosII SBT (System Build Tools) Generates HAL Board Support Package (BSP))
SBT
+ System Build Tools = For Eclipse; Takes the sopcinfo file data and generates HAL -> Component Drivers
system.h
Defines symbols for referencing hardware in the system (BSP) part of the board support package
boot-loader (Intel HEX)
Initialization information for on-chip memories (initializes contents)
.a = Single user library project ( doesn't contain main() )
HAL + Hardware Abstraction Layer
newlib
Device drivers
Eclipse (C/C++) with the NiosII build chain
Compiles to ?.elf file
the executable for embedded processor
elf = Executable and Linking File
format is result of compiled C/C++ application
ELF
- Executable and Likable Format
= Binary File Format (Flexible file format for binary code)
SOPC-Peripherals
SysID to match firmware with processor core
Generating Systems with Qsys
Simulation
DMA direct memory access controller
DMA - Direct memory access "controller"; DMA is nothing more than a way to bypass the CPU to get to system memory and/or I/O.
http://www.ganssle.com/articles/adma.htm
Bus Request" (AKA "Hold" on Intel CPUs) is an input that, when asserted by some external device, causes the CPU to tri-state it's pins at the
completion of the next instruction.
Bus Grant" (AKA "Bus Acknowledge" or "Hold Acknowledge") signals that the processor is indeed tri-stated. This means any other device can put
addresses, data, and control signals on the bus. The idea is that a DMA controller can cause the CPU to yield control, at which point the
controller takes over the bus and initiates bus cycles. Obviously, the DMA controller must be pretty intelligent to properly handle the timing
and to drive external devices through the bus
What peripherals will Nios connect to (add/remove PIO, VGA, etc..)
5.1.3 IP-Cores
Mega-Functions
= Altera Quartus installs off-the-shelf configurable IP cores optimized for Altera devices (OpenCore Plus IP)
inst1 : altfp_mult
generic map (
pipeline => 11,
width_exp => 8,
width_man => 23,
exception_handling => "no")
port map (
dataa => wire_dataa,
datab => datab,
clock => clock,
result => result);
RTL simulation?
Simulating a Circuit
File > New > VWF; Edit > Insert > Node or Bus > Node Finder > List > Select and Add > OK > Drag area and click to apply levels
Click "Run a Functional Simulation Button"
Click "Run a Timing Simulation" (Full Compilation required)
= An FPGA design/plug-in that exports internal circuit logic for analysis and debug
= (ie: SOC); FPGA is much slower than HPS.
NI Labview - National Instruments Labview is a high-level system design tool that converts graphical block diagrams into digital hardware circuits
NetList - is a circuit connection text file (typically fed into a SPICE simulator to generate XY-plot analysis using Differential non-linear and
calculus/engineering equations.
IBIS + Input/Output Buffer Information Specification
= Hides SPICE model by assigning IO specifications of the device for board level simulation
**LEAVE OpenCore Plus Status Pop-Up box open else ELF will fail to download. (This message notifies that one of the IP-Cores used requires licensing for inproduction use)
B. Circuit-Level Tools
2. IP-Integrator (Previously ISE)
5.3 ModelSim
Features
Altera Quartus-II Installer includes ModelSim-Altera Starter edition
ModelSim has a Transcript command prompt which is actually a TCL shell prompt with necessary imports.
GUI providing tools to create and/or simulate design projects
Menu File New Project
Altera Quartus builds a ModelSim include file at C:\altera\13.0sp1\modelsim_ase\modelsim.ini
Includes Libraries such as: C:\altera\13.0sp1\modelsim_ase\altera\vhdl\altera_mf
Folder $MODELSIM_TECH = C:\altera\13.0sp1\modelsim_ase\win32aloem\
Paths
Program File
Working Directory
.\altera\
.\docs\
.\examples\
.\modelsim.ini
.\ieee\
.\win32aloem\
= C:\altera\13.0sp1\modelsim_ase\win32aloem\modelsim.exe
= C:\altera\13.0sp1\modelsim_ase
= Altera Mega-function simulation files.
= Documents and tutorial guides (as well as a Tcl help guide)
= ModelSim Help/Tutorial example files
= Text file that will include all the locations of Altera Mega-function simulation code
= simulation code for the 'IEEE' library
= The ModelSim Executable directory
File Associations
(.mpf)
ModelSim project file
= Text file containing all files and settings for a simulation project (App; ModelSim.exe)
(.wlf) Simulated Waveform
= Mentor graphics proprietary waveform (App; ModelSim.exe)
See Also
http://en.wikipedia.org/wiki/Waveform_viewer
Usage
Work Directory
- Choosing the directory that ModelSim will work out of
1) Menu File Change Directory
2) The Directory chosen will need a work sub-folder (ie: Library) and can only be properly created by using
ModelSim> vlib work
Right-Click in the Library browser and select 'new' 'library' 'a new library' and give the new sub-folder / library a name.
Compiling
- The Design Files (Verilog / VHDL) or Testbench files
ModelSim> vcom -reportprogress 300 -work work D:/Electronics/CAD/_Projects/MyDFF2/MyDFF2.vhd
Menu Compile Compile and choose File
Once Compiled the output files will be stored in the 'work' library / folder. (Files .dat, .dbs, .prw, .psm )
Simulate
- Load / launch the simulator
ModelSim> vsim -gui work.mydff2
Menu Simulate 'Start Simulation' and pick the Verilog / VHDL file to simulate
6. SYSTEM SOFTWARE
Common System Software
Bootloaders
BSP
OS
6.1 Bootloaders
Types
Bootstrap Loader
Boot Loader
Boot-loaders can jump to main() functions of C-Code for libraries that matches interface of routines and data structures
Chain-loading
= Process of LOADING multistage boot-loaders one after the other with increasing complexity and functionality
Bootstrap Loader
= Initial instructions that starts the loading of the boot-loaders; Execution begins at the 'reset vector' in ROM
BIOS
- Basic Input/Output System
= A boot-loader for basic I/O functionality (e.g. keyboard/mouse/display)
MBR
- Master Boot Record
= A boot-loader at the very beginning (boot sector) of a secondary memory device
2nd Stage Bootloaders
- Generic Bootloaders
= Further booting device drivers used to expand functionality of the system
Kernel
Common Bootloaders
BIOS
EFI
UEFI
GNU
GRUB
BOOTMGR
Syslinux
NTLDR
BootX
LILO
CFE
U-Boot
http://www.uefi.org/
+ Linux Loader
+ Common Firmware Environment
= An open source BIOS boot-loader
Notes
The reality is that hobbyist embedded programming doesn't allow time for implementing all the ISRs and the boot-loader code.
Many people use standard software frameworks available for specific processors.
EDA System Design Software typically contains applications that automatically create all the required boot-loaders and device drivers
Terms
HAL
BSP
ESD
SBT
EDS
HID
Memory Management
Kernel Mode
User Mode
= Controls Virtual Memory tables; dividing memory into two distinct access levels
= Full Access to all resources (ie: Supervisor Mode)
= Limited Access to resources (e.g. Applications cannot corrupt kernel-level code)
I/O Management
= Operates and Organizes Input/Output Devices (e.g. Drivers & File Systems)
Provides
IPC
+ Inter-process Communication
= Facilities/Mechanisms for component communications
HAL
+ Hardware Abstraction Layer
= Base hardware abstraction (e.g. Motherboard Isolation)
SCI
+ System Call Interface
= OS Subsystems provide a Hardware Software Isolation SCI
Windows API + Application Program Interface
= Microsoft Windows SCI
Kernel Architectures
Monolithic
Micro
Hybrid
= Entire OS works in Kernel Mode; Providing a high-level virtual interface over hardware.
= Only fundamental parts of the OS are working in Kernel Mode.
= OS Operation is divided between Kernel and User Mode.
6.3.1 Market
OS Types
Generic
RTOS
+ Real Time OS
= An OS for embedded systems typically with an Real-Time Clock (RTC)
RTOS for Altera NiosII Soft-Core processors
Micrium (MicroC/OS)
http://micrium.com/
http://en.wikipedia.org/wiki/MicroC/OS-II
VxWorks
Embedded Systems
Windows CE
Minix 3
OS Characteristics
Tasking (Single or Multi)
User ( Single or Multi )
Distributed
Templated
Embedded
Real-Time (RTOS)
Microsoft
DOSDOS - Disk Operating System
= OS Shell/Disk Operating System(DOS)
Windows Client Editions
Windows 7 Home Basic
Windows 7 Home Premium
Windows 7 Professional
Windows 7 Ultimate
Windows 7 Enterprise
Windows 7 Starter
Windows Server Editions
Windows Server 2008 R2 Foundation
Windows Server 2008 R2 Standard
= Hyper-V
Windows Server 2008 R2 Enterprise
= Hyper-V
Windows Server 2008 R2 Datacenter
= Hyper-V
Windows Web Server 2008 R2
Windows HPC Server 2008 R2
Windows Server 2008 R2 for Itanium-Based Systems
Invokes OS commands
Linux/Unix
BSD
OS-X
Google Chromium
RedHat
Suse
6.3.2 Windows
User-Mode Processes
User Applications
Fixed/Hardwired System Support
Service
Environment subsystems
Kernel-Mode Processes
Executive and Kernel
Device Drivers
HAL
Windowing and Graphics System
= Hardware (translates user I/O functions calls into specific hardware I/O requests)
= Layer of code that isolates the kernel & device drivers & executive from platform-specific hardware
= Implements Windows GUI functions (ie: Windows USER & GDI functions)
C:\Windows\System32\
Mode
Description
Hal.dll
Kernel
Ntoskrnl.exe
Kernel
Ntkrnlpa.exe
Kernel (32-bit)
System Support
Win32k.sys
Kernel
Windows Subsystem
Kernel32.dll
Kernel
Windows32 Subsystem
Advapi32.dll
Kernel
API Subsystem
User32.dll
Kernel
User Subsystem
Gdi32.dll
Kernel
Security
I/O
Networking
IPC
Functions
ALPC
NtQueryInformationProcess, NtCreatePagingFile Undocumented System Services (not part of ntdll.dll exports)
Supplies a general interface (Calls between user Kernel Mode for device drivers not associated with read/write)
WDK Kernel Functions
Hidden
WDK Undocumented Kernel Functions Starts with Inbv)
Iop = Internal I/O manager support functions
Mi = Internal memory management support functions
Ntdll
Ldr
- Image Loader
Csr
- Heap Manager / Windows subsystem process communications
Rtl
- General run-time library routines
DbgUi - User Mode debug functions
Etw - Event Tracing functions
APC - Asynchronous Procedure Call
= Dispatcher and exception dispatcher
CRT - C Run-Time routines
= Contains only a small sub-set of functions
Exports system services from the Executive (Ntoskrnl.exe)
Contains the 'Image Loader' for loading and communicating DLL files.
C. Environmental Subsystems
MS-Windows Subsystems
Windows Subsystem
POSIX
OS/2
SUA
- C:\Windows\System32\Win32k.sys
= Kernel-mode part of the Windows Subsystem
- Last shipped with Windows 2000
- Last shipped with Windows 2000
- Subsystem for Unix-based Applications = An Enhanced POSIX subsystem
Windows Subsystem
- Files; Kernel32.dll, Advapi32.dll, User32.dll and Gdi32.dll
= Windows API
SUA Subsystem
- Files; Psxdll.dll
= SUA API Functions
Allows running UNIX-based applications; Supported on Windows Server / Enterprise / Ultimate editions.
C.1 Windows API (SCI)
Categories
Base Services
Windows API Functions
- Documented (e.g. Create Process, CreateFile, GetMessage)
System Calls
- (ie: Native System Services) Undocumented, underlying user-mode callable (e.g. NtCreateUserProcess)
Routines
- (ie: Kernel Support Functions)
= Only callable from Kernel-mode (e.g. ExAllocatePoolWithTag for drivers)
Windows Services - User Level services like the Task Scheduler
DLL - Dynamic-link Libraries
=
Terminology
Fibers
User-Mode Scheduling (UMS)
Component Services
Details
SMSS
+ Session Manager Subsystem
= Launches Environmental Subsystems
Windows Registry @ HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
CSRSS
+ Client/Server Run-Time Subsystem
GDI
+ Graphics Device Interface
= Library for graphics output devices (ie: drawing)
USER32 [Window Manager] (Windows / Buttons) GDI Graphics device driver / Video miniport driver Hardware
= (ie: Kernel Space or System Space) Kernel Architecture of the OS determines software in the Kernel Space
= Kernel Architecture of the OS determines software in the User Space
= Each process is virtually allocated the full bit-length of bit-wise address spaces
= All processes share the same virtual address space
= 0x 0000 0000 0x 7FFF FFFF (32-bit / 8-digit HEX) Virtually allocates to only half the physical address space
= 0x 0800 0000 0x FFFF FFFF (32-bit / 8-digit HEX) Statically linked to half the physical address space
Support Mechanisms
SMP
ASMP
+ Symmetric MultiProcessing
+ Asymmetric MultiProcessing
MS-Windows Features
SMP Multiprocessor support
Multicore, Hyper-Threading, and NUMA Platform support
Windows Architecture knowledge for device drivers
spin locks
wait locks
Threads and Processes fully re-entrant, MP safe
B. Scheduling
Windows Implementations
Kernel Scheduler
Fibers
UMS
- User-mode Scheduling
Interface Categories
ABI
API
= Interface between program components at the machine code level (e.g. OS level)
= Interfaces between program components at the source code level
Ntdll.dll library
Technologies
Dynamic Linker
Dynamically Loaded Library
DLL- Dynamic Link Library
IPC - Inter-Process Communication
Component Re-Use
Late / Dynamic binding
Dynamic Linker
- Late Binding
= The part of an OS that loads and links shared libraries at run-time.
This is done by copying the library contents to RAM and filling jump tables and pointers
Late Linking
http://en.wikipedia.org/wiki/Late_binding
Dynamic Dispatch
Name Binding
http://en.wikipedia.org/wiki/Name_binding
Dynamic Loading
http://en.wikipedia.org/wiki/Dynamic_loading
3-mechanisms by which a program can use other software
dynamic loading
static linking
dynamic linking
Market
CORBA- Common Object Request Broker Architecture
ACE
- Adaptive Communication Environment
TAO
- The ACE ORB (Object Request Broker)
http://en.wikipedia.org/wiki/Adaptive_Communication_Environment
LPC
ALPC
RPC
http://en.wikipedia.org/wiki/Dynamic_loading
http://en.wikipedia.org/wiki/Static_library
http://en.wikipedia.org/wiki/Dynamic_linker
http://en.wikipedia.org/wiki/Dynamic_dispatch
http://en.wikipedia.org/wiki/Virtual_method_table
http://en.wikipedia.org/wiki/Comparison_of_application_virtualization_software
http://en.wikipedia.org/wiki/Foreign_function_interface
http://en.wikipedia.org/wiki/Language_binding
CBSE
- Component-Based Software Engineering
http://en.wikipedia.org/wiki/Component-based_software_engineering
CBD
- Component-Based Development
TI IPC Users Guide
http://processors.wiki.ti.com/index.php/IPC_Users_Guide/Use_Cases_for_IPC
Wiki IPC Categories http://en.wikipedia.org/wiki/Category:Inter-process_communication
Wiki Synchronization http://en.wikipedia.org/wiki/Synchronization_%28computer_science%29
OS MicroKernel http://en.wikipedia.org/wiki/Microkernel
Software Layers http://accu.org/index.php/journals/460
OS Technology
http://en.wikipedia.org/wiki/Category:Operating_system_technology
http://en.wikipedia.org/wiki/Loader_%28computing%29
B. Microsoft IPC (LPC/COM/IDL)
LPC
DDE
+ Dynamic Data Exchange
NetDDE
+ Windows for Workgroups DDE
COM
+ Component Object Model
COM
+ Common Object Model
DCOM
+ Distributed COM
MTS
+ Microsoft Transaction Server
COM+
OLE
+ Object Linking and Embedding
OLE Automation Active X
COM Type Libraries Are components that can describe themselves to the COM engine
Registry records a UID for each COM component known as HKEY_CLASSES_ROOT hive
Registry REVERSE look-up to UID is stored in HKEY_CLASSES_ROOT\CLSID sub-folder
Standardizes the instantiation (ie: Creation) process of COM objects by requiring the use of 'Class Factories'
Standard requires two items to exist
Type Library Contains
CLSID of a component
IID(s) of the interfaces the component implements
Descriptions of each of the methods of those interfaces.
Type Libraries are typically used by Rapid Application Development (RAD) environments such as Delphi, VB, VS to assist developers of client
applications.
RegFree COM
- Registration-Free COM
= A technology introduced with Windows-XP that allows COM compo
Allows COM components to store activation metadata and Class ID (CLSID) for the component w/o using the registry.
Metadata
- Instead, Metadata and CLSID(s) of the classes are implmented in the compontent and declared in an assmebly manifest
(described using XML), sotred either as a resource in the executable OR as a seperate file installed with the component. This allows multiple
versions of the same component to be installed in different directories; described by their own manifests as well as XCOPY deployment. This
technology has limited support for EXE and COM servers and cannot be used for system-wide components such as MDAC, MSXML, DirectX
or Internet Explorer.
Composed of
IDL
+ Interface definition language
= (Has Interfaces and Type Libraries) each having a GUID (Global Unique Identifier)
Enums and Data-Types can be defined in IDL
IID
- Interface ID(s) another common term for GUID(s)
LIBID(s)
- Type Library ID(s) a more specific term
CLSID
- Class ID(s)
COM Components contain:
Interface
= Does NOT carry any implementations of the methods (JUST method declarations)
Interface is the only way a client can access the services of the COM component
Two Types of Interfaces
Standard- Interfaces provided by the COM library. (e.g. Iunknown, Idispatch, IclassFactory, Iole, IdataObject, Istream, IStorage)
Custom
- Programmer interfaces
CoClass
- Component Class
= COM Class Definition (The 'class' identifier in IDL)
Types
In-Process
DLL Libraries that run in the same memory space as the client application using it. If DLL crashes App does too.
Out-Process
EXE Runs in separate memory space as the client App calling it. If EXE crashes App remains active and EXE is reloaded.
Remote
Just like any other component but runs from a seperate location via network; Implemented with DCOM (Distributed COM)
technology.
.NET has its own COM run-time tool known as WinRT
Windows Loader
#1 Application loads
#2 Windows searches for the manifest;
If preset, the loader adds information from it to the activation context
#3 When the COM class factory tries to instantiate a class
The activation context is first checked to see if an emplementation for the CLSID can
be found ONLY IF THE LOOKUP FAILS is the registry scanned.
Windows DNA
ActiveX
DHTML
COM
Component Object Model (COM) is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess
communication and dynamic object creation in a large range of programming languages. The term COM is often used in the Microsoft software development
industry as an umbrella term that encompasses the OLE, OLE Automation, ActiveX, COM+ and DCOM technologies.
Different component types are identified by class IDs (CLSIDs), which are Globally Unique Identifiers (GUIDs). Each COM component exposes its functionality
through one or more interfaces. The different interfaces supported by a component are distinguished from each other using interface IDs (IIDs), which are GUIDs
too.
COM interfaces have bindings in several languages, such as C, C++, Visual Basic, Delphi, and several of the scripting languages implemented on the Windows
platform. All access to components is done through the methods of the interfaces. This allows techniques such as inter-process, or even inter-computer
programming (the latter using the support of DCOM).
Interfaces
All COM components must (at the very least) implement the standard
IUnknown interface, and thus all COM interfaces are derived from IUnknown.
The IUnknown interface consists of three methods: AddRef() and Release() (which implement reference counting and control the lifetime of
interfaces) and QueryInterface(), which by specifying an IID allows a caller to retrieve references to the different interfaces the component
implements. The effect of QueryInterface() is similar to dynamic_cast<> in C++ or casts in Java and C#.
http://www.devarticles.com/c/a/COM/COM-101-A-Quick-Primer/1/#ZmD8mreIzVrKXBbA.99
Understanding Exported Code (DLLs, IDL, etc..) for VB6
http://whathesaid.ca/what-he-wrote/tame-visual-basic-with-idl/
Object
Recordset
Single
String
Variant
no parameters
Figure 2: Visual Basic data types and their corresponding data types in IDL
IDispatch*
_Recordset*
float
BSTR
VARIANT
void
Other than unsigned char (Byte), keep in mind that VB can only implement signed types. Parameters marked as [in] use the IDL representation as in
figure 1. These correspond to ByVal parameters in VB. Parameters marked as [in, out] add a single indirection operator (*). These correspond to VBs ByRef
parameters. For example:
HRESULT Method1(
// ByVal As Integer
[in] short intInParm,
// ByVal As Object
[in] IDispatch* objInParm,
// ByRef As Integer
[in, out] short* intInOutParm,
// ByRef As Object
[in, out] IDispatch** objInOutParm
);
Driver Types
Root
Software
Class
Function (FDO) = Primary bus/device driver that handles read/write/control (ie: Also called Mini-Port driver)
FDO
- Function Device Object = Parent device object
PDO
- Physical Device Object
= Child device object within a parent FDO
CDO
Filter (Filter DO) = Extension (ie: In-between driver) component for specialized protocols or bug-fixes
Upper-level filter driver
Processes IRP data before the Function Driver
Lower-level filter driver
Processes IRP data after the Function Driver
At start-up
The Windows kernel PnP-Manager requests that each parent driver enumerate all connected child nodes(PDO Child-list).
Each Child PDO then has at least 1-FDO or 1+ Filter DO
For Example: Every USB device is a PDO of the USB Host FDO But each USB device also has a local Function Driver (FDO)
OS Class Drivers
= OS's comes pre-packaged with general purpose standard device drivers for a particular class of devices
6.5 Unix/Linux
7. SOFTWARE DEVELOPMENT
User Applications
Windows 32-bit or 64-bit
Windows 3.1 (16-bit)
MS-DOS (16-bit)
POSIX 32-bit or 64-bit
Note: 16-bit applications can only run on 32-bit Windows
7.1 Overview
Programming
WAT
AOT
= Process of writing source code that is converted (ie: Compiled/Interpreted) to a target machine language (ie: Processor Instructions)
+ Way Ahead Of Time = The program is compiled to target processor machine code (ie: Compiler IS system processor specific)
+ Ahead Of Time
= A common alias to WAT
Initial Compilation
System Specific
JIT
Converts all source code to target Machine Language all at once during the compilation process
The compiler is system hardware/processor specific
+ Just-In-Time Compilation = AOT Compiler item is NOT system processor specific / The JIT Compiler/Interpreter IS processor specific
Source Code AOT Compiler Intermediate Language
Intermediate Language JIT Compiler Machine Language
Intermediate Language Interpreter Machine Language
Source Code is NOT system processor specific; The Interpreter Engine IS system processor specific
Converts source code to machine language on-the-fly line per line every-time the code is executed.
Machine-Level converter from one system platform (Itself) to a target system platform.
Language Terminology
Late-Binding
Scripting Language
JavaScript, Vb-script)
Program Paradigm
- Fundamental Style
(e.g. HTML,
- See http://en.wikipedia.org/wiki/Programming_paradigm
7.1.1 Compilers/Interpreters
Compiler Types
Assembler
Cross-compilers
= (ie: Assembly Language compiler) Converts assembly language to machine language; Typically both are processor specific
= Compilers located on a development PC but compiled for an embedded systems hardware platform
Compiling Tool-chain
Pre-processor
Compiler
Linker
Libraries
Executable
= Adjusts (ie: Adds, Deletes, Substitutes) source code fragments based on Pre-processor variables before compilation.
= Converts all source code Target language (ie: Machine Code or Byte Code) at one time.
Final file after linking the object file with system libraries file is ready to be transferred to the embedded systems memory
Event
Boolean
= Static Library
Linked during compilation and become part of the executable
= Dynamic Library Loaded only when program is running and library is called.
1. General Components
Data Storage - Noun
Variable
A named memory spot for holding data (Name Value)
Compound Contains both code and data (e.g. Objects)
Discrete
Only contains data
Static
All objects share one memory location (ie: variable)
Field
Alias for a public variable within a 'class' in OOP languages.
Property
Wrapper for a field in OOP languages.
Data Manipulation Verb ( Any data manipulation code generally takes on any of the below names technicality isn't maintained )
Function
= In Data Process Out Data
Method
= Alias for Function in OOP Languages.
Sub-routine = A function that does not directly return data
Function Types
Delegate
= Call Wrapper
Function that receives a pointer to some other function (e.g. DelagateCaller(InData, PtrToFunction))
2. Encapsulation = Data and function encapsulation within Classes and Structures ('struct')
class
= A defined and named block of code including variables(ie: Properties) and functions(ie: Methods)
Classes bind together functions and data
e.g. Class Circle { VARIABLES: 'radius', 'color', FUNCTIONS: getRadius(), getColor(), getArea() }
struct
= A class typically used for a data structure (User-defined Data Type (UDT)); where the variables within are public by default
e.g. struct milk { brand, amount, grade }
TYPE keyword is used instead of 'struct' in VB6, VHDL and various other languages
object
= An isolated copy of the class code that maintains it's own variable values (ie: Instance of a class)
C1 = A named copy of 'circle class' code thus 'C1' can have it's own radius and color settings.
C2 = A named copy of 'circle class' code thus 'C2' can have it's own radius and color settings.
C3 = A named copy of 'circle class' code thus 'C3' can have it's own radius and color settings.
NEW keyword typically instantiates the object from a class design
** Above isn't actually how classes/objects work; but it represents the effect **
** OOP languages use vtables behind the scenes to link-in the correct values for each object's variable values **
Ex. One can drive Object1 car without driving Object2 & Object3 cars even though they all derive from the same class (ie: design)
Class Types
Concrete Classes = Classes defined for object creation
Abstract Classes = Classes that never become objects but are strictly used for inheritance
C++ - Abstract classes contain at least one pure virtual function (to prevent objectifying it)
Example: Dog inherits Animal whereas just a plain 'Animal' object will never exist (Abstract is the common-ground of sub-classes)
Interface = A particular type of abstract class that contains ONLY empty PUBLIC members that must be implemented (ie: Over-ridden)
Interface abstract classes do not contain any information or functionality; just a public interface
C++ does not have a keyword 'interface'; Typically, a class with ONLY pure virtual(ie: =0) functions is considered an 'Interface'
Java does have keyword 'interface'; In Java, classes can inherit multiple interfaces but only one other class
Data Hiding
Public
Access allowed anywhere
Protected
Access allowed within the inheritance tree; keyword FRIEND is used in VB
Friend
In C++ a Friend Function can be defined as part of a class definition which allows that function access to private/protected class
variables.
Private
Access allowed within the class
3. Inheritance
= Method used to expand class functionality with finer details Models a hierarchical classification
e.g. food (base class) fruit (inherits 'food' class) apple (inherits 'fruit' class)
Classes that inherit a parent/base class are called derived classes
Other Terminology identifying inheritance
base derived class
parent child class
super sub class
Overloading = Same named functions with more than one implementation/functionality
Function Overloading = Two same-named functions with different arguments ( The caller argument count/type will determine which function
implementation is used)
Operator Overloading = Overloading operators like <,>,=,+, and etc.. (e.g. iostream overloads '<<' and '>>' operators for 'cin' and 'cout')
Overriding = One function implementation over-rides the previous version (Both having identical call names and arguments)
When an interface or abstract class is inherited and function bodies are defined in the derived class they actually override the empty body.
4. Polymorphism = Using the base class interface to access derived class objects
Using class inheritance a pointer to a derived class is compatible with a pointer to its base class
Polymorphism is the ability to access an object via it's base class inherited interface as its base class type
Base Class Animal; Func Walk
Derived class Dog
Derived class Cat
Animal DogPointer = &Dog
Animal CatPointer = &Cat
DogPointer->Walk()
We can call a base call using a pointer of base type even though Dog is of the derived dog class.
Runtime Library = Core functions and engine needed by a programming language compiler
Visual Basic Runtime = VBRUN60.DLL
Required for any compiled Visual Basic v6.0 compiled program to execute.
Microsoft .NET Framework [2003]
residing at the system software layer
.NET Programming Language = Is any language that meets the Microsoft Common Language Specification Standard (e.g. C#, J#, VB-2003+, JavaScript)
.NET Framework
Must be installed on the target processor system in order to execute a .NET application
Class Loader
Platform Extension Libraries
Garbage Collector (GC)
B. C++
Core language (variables, data types, literals)
C++ Standard Library (files, strings)'stdlib' Functions for manipulating files and strings
StdLib is != the STL library; but it is a common mistake to refer to the StdLib as STL; StdLib derived parts of the original STL library
Standard Template Library (STL) (std::)
methods for manipulating data structures (2.9+ may contain Boost libraries)
Boost
Typically considered the 'StdLib' sandbox; a library of pre-standard libraries
Cocoa (Mac)
GUI Designers (Cross-Platform User Interface Toolkits)
Linux (MinGW)
Qt(KDE default DUI engine) / GTK(GIMP engine) / wxWidgets (MFC copy-cat in Dev-C++) / SDL
Windows
Blend / MFC / CLR
Keywords
7.2 OS Shells
7.2.1 MS-DOS
A. >path
Display Environment PATH
Add to the Environment PATH
>PATH
>PATH=<NewPath>;%PATH%
C:
- Manages master processor integrated hardware/components (e.g. MMU Drivers, Floating Point Drivers)
- Manages board devices
(IDLE)
Communications
Application OS
OS Drivers
Drivers HAL
HAL Device
Communication Terms
IRP
WMI
DMA
IRQ
ISR
DPC
IRQL
- Interrupt ReQuest Level
= Interrupts contain priority levels DIRQL, DISPATCH, PASSIVE
DIRQL
- Most critical
= ISR(s) use interrupt spin lock (non-paged memory)
DISPATCH
- Highest software
= Spin lock process synchronization (non-paged memory)
PASSIVE - Application level
= Fast mutex / resource objects (built from dispatcher object-events)
Port-IO
= OS Initiated communication (MS-Windows uses 'IN' and 'OUT' Port access instead of Address Mapped I/O)
Debugging
Symbols
HLK
= Allows module debugging; Viewing the specific construct throwing an error on compiled code (PDB file)
+ Hardware Lab Kit
= Microsofts all-purpose device/driver tests for windows. (Device Driver Qualification)
[MS-DOS]
[Windows 3.x, 95, 98, Me drivers]
[Windows NT/XP/2000 till 2005]
Windows Vista, 7, 8 (2005+)
File Extensions
SYS
DLL
INF
WDF Terms
DDI- Device Driver Interface
SDV - Static Driver Verifier
PREfast
Checked Build OS
Free Build OS
WDF Versioning
Permanent Object
Transient Object
= Abstract OS-kernel supplied driver interfaces that drivers need to implement (ie: Driver Model)
= Debugging / Verifying tool packaged in the WDK
WdfChildList
WdfCollection
WdfDevice
WdfCommonBuffer
WdfDMAEnabler
WdfDMATransaction
DPC
Driver
WdfDPC
WdfDriver
File
Application ]
WdfFileObject
- File object for application and external driver access to the driver [ Device DMA Driver File
The native File Object represents a single, specific, open instance of a device (or a file on a device)
File object for application and external driver access to the driver [ Device DMA Driver File Application ]
Unique open instance of a WDF Device Object
Note that we are provided a WDF Device Object handle, which represents the WDF File Objects target device. We are also provided a WDF
Request Object handle, which is the WDF abstraction of the native I/O operation representing the creation of the File Object.
WDF Device Object handle, which represents the WDF File Objects target device
As an aside that we will revisit later, this WDF Request Object is unique in KMDF in that it is not queue presented, meaning that it has no parent
WDF Queue Object.
Register via FileObject for Create, Close, and Cleanup Callbacks of IRP(s)
General
I/O
Queue
Request (IRP)
Target
WdfObject
WdfQueue
WdfRequest
WdfIoTarget
Interrupt
Look-Aside List
Memory
Registry-Keys
WdfInterrupt
WdfLookAside
WdfMemory
WdfKey
Resources
List
Range-List
Requirements
String
WdfCmResList
WdfIoResList
WdfIoResReqList
WdfString
Synchronization
SpinLock
WaitLock
Timer
WdfSpinLock
WdfWaitLock
WdfTimer
USB
Device
Interface
Pipe
WMI
Work-Items
WdfUsbDevice
WdfUsbInterface
WdfUsbPipe
WdfWMIInstance
WdfWorkItem
Getting Started
All Drivers contain
(1) DriverEntry()
Gets called when driver gets loaded and creates the Top-Level (ie: Root) Driver Object
(1+)EvtDriverDeviceAdd() Gets called when device gets connected and creates Device Object(s) (1-FDO and 1+PDO for PnP Devices)
Creates Device Objects
Filter DO
= Filter Device Object
- Filters / Modifies IRP(s) for a device
FDO
= Functional Device Object
- Primary device driver for a PnP device tree
PDO
= Physical Device Object
- A Bus drivers child device enumerator for the PnP device tree
Control DO = Control Device Object
- Non-PnP device or control interface ( Operation independent of PnP Device stack
Queue )
Sets Device Attributes
Registers Required Callback Functions ( Not related to kernel-dispatcher events )
EvtDeviceEject
EvtIo*
Callback functions that handle specific types of IRP(s) from a particular IRP-Queue
PnP Manager Codes
IRP_MN_EJECT
Only drivers for physical devices with an eject require handling the request
/
***********************************************************************************************************************************************
*****
* Kernel Mode Device Driver based on:
*
Kernel Mode Driver Framework (KMDF) - A sub-division of the Windows Driver Foundation's (WDF) Windows Driver Kit (WDK) written in C
*
_In_ & _Out_ are Function parameter annotations; see http://msdn.microsoft.com/en-us/library/hh916382.aspx
*
*
DRIVER_OBJECT see http://msdn.microsoft.com/en-us/library/windows/hardware/ff544174%28v=vs.85%29.aspx
*
*
This version shows how to register for PNP and Power events, handle create & close file requests, handle WMI set and query events, fire WMI
*
notification events.
*
***********************************************************************************************************************************************
*****/
#include <ntddk.h>
// #include the Windows-NT Device Driver Kit (DDK)
#include <wdf.h>
// #include the Windows Driver Foundation (WDF) Framework
A. DriverEntry()
Driver Object Reference
Call-Back
@ http://msdn.microsoft.com/en-us/library/windows/hardware/dn265636%28v=vs.85%29.aspx
Methods
Structures/Enums
Initialization Functions
EvtDriverDeviceAdd
EvtDriverUnload
WdfDriverCreate
WdfDriverGetRegistryPath
WdfDriverIsVersionAvailable
WdfDriverMiniportUnload
WdfDriverOpenParametersRegistryKey
WDF_DRIVER_CONFIG
WDF_DRIVER_INIT_FLAGS
WDF_DRIVER_VERSION_AVAILABLE_PARAMS
WDF_DRIVER_CONFIG_INIT
WDF_DRIVER_VERSION_ABAILABLE_PARAMS_IN
/**********************************************************************************************************************
* DriverEntry()
*
IN:
DriverObject
*
IN:
RegistryPath
*
DESC:
*
- First routine called by the OS-PnP Manager when driver gets loaded.
*
- Creates the Driver Object and Registers 'EvtDriverDeviceAdd' and 'EvtDriverUnload' functions.
*
- Export standard set of entry points using the OS data-structure DRIVER_OBJECT
*
- OS looks at the data-structure of function pointers to call when a request is targeted to a device described by DEVICE_OBJECT
*
Function dispatch table = contains a function pointer for each major function code the OS system supports
*
28-functions can be supported but usually only 8 are: IRP_MJ_CREATE, CLOSE, READ, WRITE, PNP, POWER, DEVICE_CONTROL, and SYSTEM_CONTROL
*
by default all these functions point to a routine which indicates that major function is NOT supported.
* Parameters:
*
DriverObject = represents the instance of the function driver that is loaded
*
into memory. DriverEntry must initialize members of DriverObject before it
*
returns to the caller. DriverObject is allocated by the system before the
*
driver is loaded, and it is released by the system after the system unloads
*
the function driver from memory.
*
*
RegistryPath = represents the driver specific path in the Registry.
*
The function driver can use the path to store driver related data between
*
reboots. The path does not store hardware instance specific data.
* Duties:
*
1) Create
a PDDRIVER_OBJECT Instance by calling WdfDriverCreate()
*
2) Configure the DriverObject Instance using WDF_DRIVER_CONFIG_INIT(WDF_DRIVER_CONFIG)
/*********************************************************************************************************************/
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) {
NTSTATUS
WDF_DRIVER_CONFIG
status = STATUS_SUCCESS;
config;
B. EvtDeviceAdd()
Device Object Reference
@ http://msdn.microsoft.com/en-us/library/windows/hardware/dn265631%28v=vs.85%29.aspx
Device
Prefix
Call (Verb)
Item (Noun)
Structure
Create
WdfDevice
CreateDevice
Interface
Create Interface
WdfDevice
RetrieveDevice
InterfaceString
WdfDevice
SetDevice
InterfaceState
EvtDevice
Process
QueryInterfaceRequest
WdfDevice
Add
QueryInterface
WdfDevice
WDFDEVICE_INIT
Structure Initializer
WdfDevice
Device Initializer
Enables/Disables Interface
WDF_QUERY_INTERFACE_CONFIG
WDF_QUERY_INTERFACE_CONFIG_INIT
Interface{Der/R}eferenceNoOp
WdfDevice
WdfDevice
SetDevice
State
WdfDevice
Create
SymbolicLink
WdfDevice
WDF_DEVICE_STATE
MiniportCreate
WdfDevice
InitAssign
/RetrieveDevice
Name
WDFDEVICE_INIT
WdfDevice
InitAssign
SDDLString
WDFDEVICE_INIT
WdfDevice
Init
Free
WdfDevice
DeviceGet/InitSet/Set
Characteristics
WdfDevice
InitSetDevice
Class
WdfDevice
InitSetDevice
Type
WdfDevice
InitSet
Exclusive
WdfDevice
Assign
MofResourceName
WdfDevice
Set
Failed
WdfDevice
WdmGet
DeviceObject
WdfDevice
WdmGet
PhysicalDevice
Security Setting
De-allocate WDFDEVICE_INIT
WDF_DEVICE_FAILED_ACTION
WdfWdmDevice GetWdf
DeviceHandle
WdfDevice
OpenRegistryKey
/WdfFdoInit
WdfFdo
InitSet
DefaultChildListConfig
WdfFdo
InitSet
EventCallbacks
EvtDevice
Filter{Add/Remove}
ResourceRequirements
FDO
EvtDevice
RemoveAdded
Resources
FDO
WdfFdo
InitSet
Filter
WdfFdo
InitWdmGet
PhysicalDevice
WdfFdo
Add
StaticChild
WdfFdo
Get
DefaultChildList
WdfFdo
{Lock/Unlock}
StaticChildListForIteration
WdfFdo
QueryFor
Interface
WdfFdo
Retrieve
NextStaticChild
WdfPdo
Init
AddCompatibleID
WdfPdo
InitAdd
DeviceText
WdfPdo
InitAdd
HardwareID
WdfPdo
Init
Allocate
WdfPdo
InitAllow
ForwardingRequestToParent
WdfPdo
InitAssign
ContainerID
WdfPdo
InitAssign
DeviceID
WdfPdo
InitAssign
InstanceID
WdfPdo
InitAssign
RawDevice
WdfPdo
InitSet
DefaultLocale
WdfPdo
InitSet
EventCallbacks
EvtChildList
WDF_FDO_EVENT_CALLBACKS
WDF_FDO_EVENT_CALLBACKS_INIT
WDF_CHILD_LIST_CONFIG
WDF_PDO_EVENT_CALLBACKS
WDF_PDO_EVENT_CALLBACKS_INIT
CreateDevice
WdfChildList
Get
Device
WdfChildList
Retrieve
AddressDescription
WdfChildList
Retrieve
Pdo
EvtChildList
AddressDescription
Cleanup
EvtChildList
AddressDescription
Copy
EvtChildList
AddressDescription
Duplicate
EvtChildList
IdentificationDescription
Cleanup
EvtChildList
IdentificationDescription
Compare
EvtChildList
IdentificationDescription
Copy
EvtChildList
IdentificationDescription
Duplicate
WDF_CHILD_ADDRESS_DESCRIPTION_HEADER WDF_CHILD_ADDRESS_DESCRIPTION_HEADER_INI
T
EvtChildList
EvtChildList
WDF_CHILD_IDENTIFICATION_DESCRIPTION_
HEADER
DeviceReenumerated
EvtChildList
ScanForChildren
WdfChildList
AddOrUpdate/UpdateAll ChildDescriptionAsPresent
WdfChildList
Update
ChildDescriptionAsMissing
WdfChildList
{Begin/End}
Iteration
WdfChildList
{Begin/End}
Scan
WdfChildList
Create
WdfChildList
Request
ChildEject
WdfPdo
Add/Remove
EjectionRelationsPhysicalDevice
WdfPdo
Clear
EjectionRelationsDevices
WdfChildList
Retrieve
NextDevice
WdfChildList
Device Dependencies
PreFix
Call
Item
Structure
Structure Initializer
WdfDevice
Add/Remove
DependentUsageDeviceObject
Dependent driver
WdfDevice
Add/Remove
RemovalRelationsPhysicalDevice
Dependent driver/remove
WdfDevice
Clear
RemovalRelationsDevices
Remove all-drivers/dependence
WdfDevice
WdmGet
AttachedDevice
WdfPdo
Get
Parent
WdfPdo
MarkMissing
WdfPdo
Request
Eject
WdfPdo
Retrieve/Update
AddressDescription
WdfPdo
Retrieve
IdentificationDescription
File
PreFix
Call
Item
WdfDevice
InitSet
FileObjectConfig
WdfDevice
Get
FileObject
Evt
File
Cleanup
Structure
Structure Initializer
WDF_FILEOBJECT_CONFIG
WDF_FILEOBJECT_CONFIG_INIT
EvtDeviceFileCreate HANDLE
WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEAD
ER_INIT
Evt
File
Close
EvtDeviceFileCreate HANDLE
WdfDevice
Set
SpecialFileSupport
WDF_SPECIAL_FILE_TYPE
Call
Item
Structure
Structure Initializer
WdfDevice
InitSet
IoInCallerContextCallback
WdfDevice
InitSet
IoType
WdfDevice
/WdfFdoInit
AllocAndQueryProperty
WdfDevice
/WdfFdoInit
QueryProperty
WdfDevice
{Set/Get}
AlignmentRequirement
WdfDevice
Get
Driver
WdfDevice
Get
IoTarget
WdfDevice
Set
BusInformationForChildren
EvtDevice
Prepare
Hardware
EvtDevice
SelfManaged
IoCleanup
EvtDevice
SelfManaged
IoFlush
EvtDevice
SelfManaged
IoInit
EvtDevice
SelfManaged
IoRestart
EvtDevice
SelfManaged
IoSuspend
EvtDevice
UsageNotification
WDF_SPECIAL_FILE_TYPE
EvtDeviceWdm
IrpPreprocess
IRP Structure
EvtDeviceWdm
DispatchPreprocessedIrp
Evt
IoInCallerContext
DEVICE_OBJECT
Called when a new device is plugged-in
Registers the Functions that the Driver will Support
http://msdn.microsoft.com/en-us/library/windows/hardware/dn265631%28v=vs.85%29.aspx
Bus Driver
= KMDF drivers indicate a Bus Driver by calling PDO initialization methods before creating it s Device Object in EvtAddDevice().
Static Model
For PDO devices that are statically attached (ie: USB Host controller on the Motherboard)
Dynamic
For PDO devices that are hot-swappable (Plug n Play)
/**************************************************************************************************
* EvtDeviceAdd()
*
IN:
Driver
= Handle to a framework driver object created in DriverEntry
*
IN:
DeviceInit
= Pointer to a framework-allocated WDFDEVICE_INIT structure.
*
DESC:
Is called by the framework in response to AddDevice call from the PnP manager.
/*************************************************************************************************/
NTSTATUS MyEvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit) {
// Initialize settings structures
NTSTATUS
status = STATUS_SUCCESS;
WDF_PNPPOWER_EVENT_CALLBACKS
pnpPowerCallbacks;
WDF_OBJECT_ATTRIBUTES
fdoAttributes;
WDFDEVICE
device;
WDF_FILEOBJECT_CONFIG
fileConfig;
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings;
WDF_POWER_POLICY_EVENT_CALLBACKS
powerPolicyCallbacks;
WDF_IO_QUEUE_CONFIG
queueConfig;
//PFDO_DATA
fdoData;
WDFQUEUE
queue;
WDF_DEVICE_FAILED_ACTION
*one;
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE();
KdPrint(("EventDeviceAdd called\n"));
one = new WDF_DEVICE_FAILED_ACTION;
one->WdfDeviceFailedUndefined = 1;
one.WdfDeviceFailedAttemptRestart;
WdfDeviceSetFailed(&device, one);
WDF Framework handles PnP and Power Management via a State Machine (Applies to both KMDF and UMDF)
Driver can implement particular states callback functions that it needs to handle specifically while leaving others for the WDF default implementations
The WDF Default implementation can handle other parts of the framework so proper behavior occurs when a state transition occurs
Example: The I/O queue can stop dispatching requests when device is in a low-power state
PnP Operations
PreFix
Call
Item
Structure
Structure Initializer
WdfDevice
Set
PnpCapabilities
WDF_DEVICE_PNP_CAPABILITIES
WDF_DEVICE_PNP_CAPABILITIES_INIT
WdfDevice
InitSet
PnpPowerEventCallbacks
WDF_PNPPOWER_EVENT_CALLBACKS
WDF_PNPPOWER_EVENT_CALLBACKS_INIT
WdfDevice
GetDevice
PnpState
WDF_DEVICE_PNP_STATE
EvtDevice
PnpStateChange
WDF_DEVICE_PNP_NOTIFICATION_DATA
EvtDevice
ReleaseHardware
EvtDevice
SurpriseRemoval
EvtDevice
SelfManaged
IoCleanup
EvtDevice
SelfManaged
IoInit
WDF_DEVICE_PNP_CAPABILITIES_INIT
Power States
Sx = System Power States (Where 'x' is 0 to 5)
S0 = Working State
Dx= Device Power States (Where 'x' is 0 to 3) higher uses less power and longest wake-up latency
D0 = Working State
Power
PreFix
Call
Item
Structure
Structure Initializer
WdfDevice Set
PowerCapabilities
WDF_DEVICE_POWER_CAPABILITIES
WDF_DEVICE_POWER_CAPABILITIES_INIT
WdfDevice InitSet
PowerPolicyEventCallbacks
WDF_POWER_POLICY_EVENT_CALLBACKS
WDF_POWER_POLICY_EVENT_CALLBACKS_INIT
WdfDevice InitRegister
PowerPolicyStateChangeCallback
WdfDevice InitSet
PowerPolicyOwnership
EvtDevice
PowerPolicyStateChange
WdfDevice GetDevice
PowerPolicyState
WdfDevice GetDevice
PowerState
WDF_DEVICE_POWER_POLICY_NOTIFICATION_DATA
WDF_DEVICE_POWER_STATE (Returns)
WdfDevice InitRegister
PowerStateChangeCallback
EvtDevice
PowerStateChange
WdfDevice InitSet
PowerInrush
WdfDevice InitSetPower{Not}
Pageable
WdfDevice {Set/Get}Device
State
WdfDevice Get
SystemPowerAction
WdfDevice Assign
S0IdleSettings
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT
WdfDevice Assign
SxWakeSettings
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT
WdfDevice Indicate
WakeStatus
WDF_DEVICE_POWER_NOTIFICATION_DATA
Device requires inrush current @ start-up
Driver accepts pageable data during sleep or not
WDF_DEVICE_STATE (Returns)
WDF_DEVICE_STATE_INIT
Current system power action if any
WdfDevice {Stop/Resume}Idle
WdfDevice Set
StaticStopRemove
EvtDevice
{Arm/Disarm}
WakeFromS0
WDF_DEVICE_PNP_CAPABILITIES
WDF_DEVICE_PNP_CAPABILITIES_INIT
EvtDevice
{Arm/Disarm}
WakeFromSx
WDF_PNPPOWER_EVENT_CALLBACKS
WDF_PNPPOWER_EVENT_CALLBACKS_INIT
EvtDevice
Arm
WakeFromSxWithReason
EvtDevice
WakeFromS0Triggered
EvtDevice
WakeFromSxTriggered
EvtDevice
D0{Entry/Exit}
EvtDevice
D0Entry
PostInterruptsEnabled
WDF_POWER_DEVICE_STATE
EvtDevice
D0Exit
PreInterruptsDisabled
WDF_POWER_DEVICE_STATE
WdfDev
StateIsNP
WdfDev
StateNormalize
WakeAtBus
PDO
EvtDevice
Eject
PDO
EvtDevice
ResourceRequirementsQuery
EvtDevice
Disable/Enable
EvtDevice
EvtDevice
WDF_DEVICE_POWER_STATE
Is Non-Pageable
ResourcesQuery
Set
EvtDevice
Lock
ShutdownNotification
Wdf
ControlDeviceInit
Wdf
ControlDeviceInitSet ShutdownNotification
Wdf
Control
FinishInitializing
Po
Register/Unregisted
PowerSettingCallback
WDF_DEVICE_SHUTDOWN_FLAGS
Allocate
B.3
File / Context
B.4 Device
//-- [ Create Device ] --//
// DeviceInit is completely initialized so create the device and attach it to the lower stack
status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &device);
if (!NT_SUCCESS(status)) {
KdPrint( ("WdfDeviceCreate failed with Status code 0x%x\n", status));
return status;}
B.5 Interface
//-- [ Create Interface ] --//
// Tell the Framework that this device will need an interface so that applications can find our device and talk to it.
status = WdfDeviceCreateDeviceInterface(device, (LPGUID) &GUID_DEVINTERFACE_TOASTER, NULL);
if (!NT_SUCCESS (status)) {
KdPrint( ("WdfDeviceCreateDeviceInterface failed 0x%x\n", status));
return status;}
Communications
I/O Request Packet (IRP) = All windows I/O requests are carried by an IRP which is a kernel data structure.
Write IRP Packet
= Data to be written to the device
- WriteFile()
IRP
PreFix
WdfDevice
Call
Item
InitAssign WdmIrpPreprocessCallback
WdfRequest Allocate
Timer
WdfRequest Cancel
SentRequest
WdfRequest Change
Target
WdfRequest
Complete
WdfRequest
CompleteWithInformation
WdfRequest
CompleteWithPriorityBoost
WdfRequest
Create
WdfRequest
CreateFromIrp
WdfRequest Format
RequestUsingCurrentType
WdfRequest
ForwardToIoQueue
WdfRequest
ForwardToParentDeviceIoQueue
WdfRequest Get
CompletionParams
WdfRequest Get
FileObject
Get
Information
Get
IoQueue
Get
Parameters
Get
RequestorMode
Structure
Structure Initializer
IRP Major Code handler
Query
PreFix
Call
Structure
Structure Initializer
WdfDevice
InitSetRequestAttributes
WdfDevice
ConfigureRequestDispatching
WdfDevice
DeviceEnqueueRequest
WdfDevice
GetDefaultQueue
EvtDevice
QueryRemove
EvtDevice
QueryStop
EvtDevice
RelationsQuery
EvtIo
AllocateRequestResources
EvtIo
AllocateResourcesForReservedRequest
EvtIo
CanceledOnQueue
EvtIo
Default
EvtIo
DeviceControl
EvtIoWdm
IrpForForwardProgress
WDF_IO_FORWARD_PROGRESS_ACTION
WdfIoQueue
AssignForwardProgressPolicy
WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY
EvtIo
InternalDeviceControl
EvtIo
QueueState
WdfIoQueue
Start
EvtIo
Read
EvtIo
Resume
WdfIoQueue/EvtIo Stop
WdfIoQueue
StopSynchronously
EvtIo
Write
WdfIoQueue
Create
WdfIoQueue
Drain
WdfIoQueue
DrainSynchronously
WdfIoQueue
FindRequest
WdfIoQueue
GetDevice
WdfIoQueue
GetState
WdfIoQueue
Purge
WdfIoQueue
PurgeSynchronously
WdfIoQueue
ReadyNotify
WdfIoQueue
RetrieveFoundRequest
WdfIoQueue
RetrieveNextRequest
WdfIoQueue
RetrieveRequestByFileObject
WDF_IO_QUEUE_CONFIG
WDF_IO_QUEUE_CONFIG_INIT
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE
//--[ Finally register all our WMI datablocks with WMI subsystem. ]--//
status = ToasterWmiRegistration(device);
return status;
//--[
// Set the idle power policy to put the device to Dx if the device is not used
// for the specified IdleTimeout time. Since this is a virtual device we
// tell the framework that we cannot wake ourself if we sleep in S0. Only
// way the device can be brought to D0 is if the device recieves an I/O from
// the system.
//
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleCannotWakeFromS0);
idleSettings.IdleTimeout = 60000; // 60 secs idle timeout
status = WdfDeviceAssignS0IdleSettings(device, &idleSettings);
if (!NT_SUCCESS(status)) {
KdPrint( ("WdfDeviceAssignS0IdleSettings failed 0x%x\n", status));
return status;
}
//
// Set the wait-wake policy.
//
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings);
status = WdfDeviceAssignSxWakeSettings(device, &wakeSettings);
if (!NT_SUCCESS(status)) {
//
// We are probably enumerated on a bus that doesn't support Sx-wake.
// Let us not fail the device add just because we aren't able to support
// wait-wake. I will let the user of this sample decide how important it's
// to support wait-wake for their hardware and return appropriate status.
//
KdPrint( ("WdfDeviceAssignSxWakeSettings failed 0x%x\n", status));
status = STATUS_SUCCESS;
}
//
// Finally register all our WMI datablocks with WMI subsystem.
//
status = ToasterWmiRegistration(device);
//
//
//
//
//
//
//
Please note that if this event fails or eventually device gets removed
the framework will automatically take care of deregistering with
WMI, detaching and deleting the deviceobject and cleaning up other
resources. Framework does most of the resource cleanup during device
remove and driver unload.
return status;
}
C. Callback Functions
/************************************************************************************************************
* EventDevicePrepareHardware()
*
IN:
Device - Handle to a framework device object.
*
IN:
ResourcesRaw - Handle to a collection of framework resource objects.
*
This collection identifies the raw (bus-relative) hardware
*
resources that have been assigned to the device.
*
IN:
ResourcesTranslated - Handle to a collection of framework resource objects.
*
This collection identifies the translated (system-physical)
*
hardware resources that have been assigned to the device.
*
The resources appear from the CPU's point of view.
*
Use this list of resources to map I/O space and
*
device-accessible memory into virtual address space
*
DESC:
*
When PnP manager sends IRP_MN_START_DEVICE; EvtDevicePrepareHardware() can:
*
- map resources
*
- Get USB device descriptors, config, and select configs.
*
- Download firmware to the device if firmware is reatained during D0 -> D3 states else use EvtDeviceD0Entry
*************************************************************************************************************/
NTSTATUS EventDevicePrepareHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesRaw, WDFCMRESLIST ResourcesTranslated) {
//PFDO_DATA
fdoData;
NTSTATUS status = STATUS_SUCCESS;
ULONG i;
PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor;
//fdoData = ToasterFdoGetData(Device);
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(ResourcesRaw);
KdPrint(("EventDevicePrepareHardware called\n"));
PAGED_CODE();
// Get the number of items that are currently in the Resources collection
for (i=0; i < WdfCmResourceListGetCount(ResourcesTranslated); i++) {
// iterate thru as many times to get more information about the each items
descriptor = WdfCmResourceListGetDescriptor(ResourcesTranslated, i);
switch(descriptor->Type) {
case CmResourceTypePort:
KdPrint(("I/O Port: (%x) Length: (%d)\n",
descriptor->u.Port.Start.LowPart,
descriptor->u.Port.Length));
break;
case CmResourceTypeMemory:
KdPrint(("Memory: (%x) Length: (%d)\n",
descriptor->u.Memory.Start.LowPart,
descriptor->u.Memory.Length));
break;
case CmResourceTypeInterrupt:
KdPrint(("Interrupt level: 0x%0x, Vector: 0x%0x, Affinity: 0x%0Ix\n",
descriptor->u.Interrupt.Level,
descriptor->u.Interrupt.Vector,
descriptor->u.Interrupt.Affinity));
break;
default:
break;
}
}
// Fire device arrival event.
ToasterFireArrivalEvent(Device);
return status;
/************************************************************************************************************
* EventDeviceReleaseHardware()
*
IN:
Device - Handle to a framework device object.
*
IN:
ResourcesTranslated - Handle to a collection of framework resource objects.
*
This collection identifies the translated (system-physical)
*
hardware resources that have been assigned to the device.
*
The resources appear from the CPU's point of view.
*
Use this list of resources to map I/O space and
*
device-accessible memory into virtual address space
*
DESC:
*
EvtDeviceReleaseHardware is called by the framework whenever the PnP manager
*
is revoking ownership of our resources. This may be in response to either
*
IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. The callback is made before
*
passing down the IRP to the lower driver.
*
*
In this callback, do anything necessary to free those resources.
*************************************************************************************************************/
NTSTATUS EventDeviceReleaseHardware(IN WDFDEVICE Device, IN WDFCMRESLIST ResourcesTranslated) {
//PFDO_DATA
fdoData;
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(ResourcesTranslated);
KdPrint(("EventDeviceReleaseHardware called\n"));
PAGED_CODE();
//fdoData = ToasterFdoGetData(Device);
// Unmap any I/O ports, registers that you mapped in PrepareHardware.
// Disconnecting from the interrupt will be done automatically by the framework.
return STATUS_SUCCESS;
/************************************************************************************************************
* EventDeviceSelfManagedIoInit()
*
IN:
Device - Handle to a framework device object.
*
DESC:
*
EvtDeviceSelfManagedIoInit is called it once for each device,
*
after the framework has called the driver's EvtDeviceD0Entry
*
callback function for the first time. The framework does not
*
call the EvtDeviceSelfManagedIoInit callback function again for
*
that device, unless the device is removed and reconnected, or
*
the drivers are reloaded.
*
*
The EvtDeviceSelfManagedIoInit callback function must initialize
*
the self-managed I/O operations that the driver will handle
*
for the device.
*
*
This function is not marked pageable because this function is in the
*
device power up path. When a function is marked pagable and the code
*
section is paged out, it will generate a page fault which could impact
*
the fast resume behavior because the client driver will have to wait
*
until the system drivers can service this page fault.
*
*
In this callback, do anything necessary to free those resources.
*************************************************************************************************************/
NTSTATUS EventDeviceSelfManagedIoInit(IN WDFDEVICE Device) {
NTSTATUS
PFDO_DATA
status;
fdoData;
KdPrint(("EventDeviceSelfManagedIoInit called\n"));
fdoData = ToasterFdoGetData(Device);
// We will provide an example on how to get a bus-specific direct
// call interface from a bus driver.
status = WdfFdoQueryForInterface(Device,
&GUID_TOASTER_INTERFACE_STANDARD,
(PINTERFACE) &fdoData->BusInterface,
sizeof(TOASTER_INTERFACE_STANDARD),
1,
NULL);// InterfaceSpecific Data
if(NT_SUCCESS(status))
{
UCHAR powerlevel;
// Call the direct callback functions to get the property or
// configuration information of the device.
(*fdoData->BusInterface.GetCrispinessLevel)(fdoData->BusInterface.InterfaceHeader.Context,
&powerlevel);
(*fdoData->BusInterface.SetCrispinessLevel)(fdoData->BusInterface.InterfaceHeader.Context, 8);
(*fdoData->BusInterface.IsSafetyLockEnabled)(fdoData->BusInterface.InterfaceHeader.Context);
// Provider of this interface may have taken a reference on it.
// So we must release the interface as soon as we are done using it.
(*fdoData->BusInterface.InterfaceHeader.InterfaceDereference)
((PVOID)fdoData->BusInterface.InterfaceHeader.Context);
} else {
// In this sample, we don't want to fail start just because we weren't
// able to get the direct-call interface. If this driver is loaded on top
// of a bus other than toaster, ToasterGetStandardInterface will return
// an error.
status = STATUS_SUCCESS;
}
return status;
/************************************************************************************************************
* EventDeviceContextCleanup()
*
IN:
Device - Handle to a framework device object.
*
DESC:
EvtDeviceContextCleanup event callback must perform any operations that are
necessary before the specified device is removed. The framework calls
the driver's EvtDeviceContextCleanup callback when the device is deleted in response
to IRP_MN_REMOVE_DEVICE request.
In this callback, do anything necessary to free those resources.
*************************************************************************************************************/
VOID EventDeviceContextCleanup(IN WDFOBJECT Device) {
//PFDO_DATA
fdoData;
UNREFERENCED_PARAMETER(Device);
KdPrint( ("EventDeviceContextCleanup called\n"));
PAGED_CODE();
//fdoData = ToasterFdoGetData((WDFDEVICE)Device);
return;
/************************************************************************************************************
* EventDeviceFileCreate()
*
IN:
Device - Handle to a framework device object.
*
IN:
FileObject - Pointer to fileobject that represents the open handle.
*
IN:
CreateParams - Parameters for create
*
DESC:
The framework calls a driver's EvtDeviceFileCreate callback
when the framework receives an IRP_MJ_CREATE request.
The system sends this request when a user application opens the
device to perform an I/O operation, such as reading or writing to a device.
This callback is called in the context of the thread
that created the IRP_MJ_CREATE request.
In this callback, do anything necessary to free those resources.
*************************************************************************************************************/
VOID EventDeviceFileCreate (IN WDFDEVICE Device, IN WDFREQUEST Request, IN WDFFILEOBJECT FileObject) {
//PFDO_DATA
fdoData;
UNREFERENCED_PARAMETER(FileObject);
UNREFERENCED_PARAMETER(Device);
KdPrint( ("EventDeviceFileCreate %p\n", Device));
PAGED_CODE ();
// Get the device context given the device handle.
//fdoData = ToasterFdoGetData(Device);
WdfRequestComplete(Request, STATUS_SUCCESS);
return;
}
/************************************************************************************************************
* EventFileClose()
*
IN:
FileObject - Pointer to fileobject that represents the open handle.
*
DESC:
EvtFileClose is called when all the handles represented by the FileObject
is closed and all the references to FileObject is removed. This callback
may get called in an arbitrary thread context instead of the thread that
called CloseHandle. If you want to delete any per FileObject context that
must be done in the context of the user thread that made the Create call,
you should do that in the EvtDeviceCleanp callback.
In this callback, do anything necessary to free those resources.
*************************************************************************************************************/
VOID EventFileClose (IN WDFFILEOBJECT FileObject) {
//PFDO_DATA
fdoData;
UNREFERENCED_PARAMETER(FileObject);
PAGED_CODE ();
//fdoData = ToasterFdoGetData(WdfFileObjectGetDevice(FileObject));
KdPrint( ("EventFileClose\n"));
return;
/************************************************************************************************************
* EventIoRead()
*
IN:
Queue - Handle to the framework queue object that is associated with the I/O request.
*
IN:
Request - Handle to a framework request object.
*
IN:
Lenght - Length of the data buffer associated with the request.
The default property of the queue is to not dispatch
zero lenght read & write requests to the driver and
complete is with status success. So we will never get
a zero length request.
*
DESC:
Performs read to the toaster device. This event is called when the
framework receives IRP_MJ_READ requests.
*************************************************************************************************************/
VOID EventIoRead (WDFQUEUE Queue, WDFREQUEST Request, size_t Length) {
NTSTATUS
ULONG_PTR
WDFMEMORY
status;
bytesCopied =0;
memory;
UNREFERENCED_PARAMETER(Length);
UNREFERENCED_PARAMETER(Queue);
PAGED_CODE();
KdPrint(("EventIoRead: Request: 0x%p, Queue: 0x%p\n",
Request, Queue));
// Get the request memory and perform read operation here
status = WdfRequestRetrieveOutputMemory(Request, &memory);
if(NT_SUCCESS(status) ) {
// Copy data into the memory buffer using WdfMemoryCopyFromBuffer
}
WdfRequestCompleteWithInformation(Request, status, bytesCopied);
}
/************************************************************************************************************
* EventIoWrite()
*
Queue
- Handle to the framework queue object that is associated with the I/O request.
*
Request - Handle to a framework request object.
*
Lenght - Length of the data buffer associated with the request. (0-lenght buffers aren't passed)
*
The default property of the queue is to not dispatch
*
zero lenght read & write requests to the driver and
*
complete is with status success. So we will never get
*
a zero length request.
*
DESC: Performs write to the toaster device. This event is called when the framework receives IRP_MJ_WRITE requests.
*************************************************************************************************************/
VOID EventIoWrite (WDFQUEUE Queue, WDFREQUEST Request, size_t Length) {
NTSTATUS
status;
WDFMEMORY memory;
UNREFERENCED_PARAMETER(Queue);
KdPrint(("EventIoWrite. Request: 0x%p, Queue: 0x%p\n", Request, Queue));
PAGED_CODE();
// Get the request buffer and perform write operation here
status = WdfRequestRetrieveInputMemory(Request, &memory);
if(NT_SUCCESS(status) ) {
// 1) Use WdfMemoryCopyToBuffer to copy data from the request
// to driver buffer.
// 2) Or get the buffer pointer from the request by calling
// WdfRequestRetrieveInputBuffer to transfer data to the hw
// 3) Or you can get the buffer pointer from the memory handle
// by calling WdfMemoryGetBuffer to transfer data to the hw.
}
WdfRequestCompleteWithInformation(Request, status, Length);
}
/************************************************************************************************************
* EventIoDeviceControl()
*
Queue
- Handle to the framework queue object that is associated with the I/O request.
*
Request
- Handle to a framework request object.
*
OutputBufferLength
- length of the request's output buffer, if an output buffer is available.
*
InputBufferLength - length of the request's input buffer, if an input buffer is available.
*
IoControlCode
- the driver-defined or system-defined I/O control code (IOCTL) that is associated with the request.
*
DESC:
This event is called when the framework receives IRP_MJ_DEVICE_CONTROL requests from the system.
*************************************************************************************************************/
VOID EventIoDeviceControl(IN WDFQUEUE Queue,IN WDFREQUEST Request,IN size_t OutputBufferLength,
IN size_t InputBufferLength, IN ULONG IoControlCode) {
NTSTATUS
WDF_DEVICE_STATE
WDFDEVICE
status= STATUS_SUCCESS;
deviceState;
hDevice = WdfIoQueueGetDevice(Queue);
UNREFERENCED_PARAMETER(OutputBufferLength);
UNREFERENCED_PARAMETER(InputBufferLength);
KdPrint(("EventIoDeviceControl called\n"));
PAGED_CODE();
switch (IoControlCode) {
case IOCTL_TOASTER_DONT_DISPLAY_IN_UI_DEVICE:
// This is just an example on how to hide your device in the
// device manager. Please remove this code when you adapt
// this sample for your hardware.
WDF_DEVICE_STATE_INIT(&deviceState);
deviceState.DontDisplayInUI = WdfTrue;
WdfDeviceSetDeviceState(
hDevice,
&deviceState
);
break;
default:
status = STATUS_INVALID_DEVICE_REQUEST;
}
// Complete the Request.
WdfRequestCompleteWithInformation(Request, status, (ULONG_PTR) 0);
}
/
***********************************************************************************************************************************************
*****
* Device Driver based on
*
Kernel Mode Driver Framework (KMDF) - A sub-division of the Windows Driver Foundation's (WDF) Windows Driver Kit (WDK)
*
_In_ & _Out_ are Function parameter annotations; see http://msdn.microsoft.com/en-us/library/hh916382.aspx
*
Drivers export a standard set of entry point in its DriverEntry() by filling in a data-structure created by the OS called DRIVER_OBJECT
*
OS looks at the data-structure of function pointers to call when a request is targeted to a device described by DEVICE_OBJECT
*
Function dispatch table = contains a function pointer for each major function code the OS system supports
*
28-functions can be supported but usually only 8 are: IRP_MJ_CREATE, CLOSE, READ, WRITE, PNP, POWER, DEVICE_CONTROL, and SYSTEM_CONTROL
*
by default all these functions point to a routine which indicates that major function is NOT supported.
***********************************************************************************************************************************************
*****/
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfEvtDeviceAdd;
// All global variables must be defined in 'DeviceEntry' File ; This File
// All Device Drivers START at DriverEntry() which creates the DriverObject when the driver is loaded
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
WDF_DRIVER_CONFIG config;
//--- sends a string to the kernel debugger --//
KdPrintEx(( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: DriverEntry\n" ));
/*ULONG KdPrintEx(
ULONG ComponentId,
ULONG Level,
PCSTR Format,
... arguments);*/
//-- Initializes WDF_DRIVER_CONFIG object; a driver's config structure --//
WDF_DRIVER_CONFIG_INIT(&config, KmdfEvtDeviceAdd);
/* WDF_DRIVER_CONFIG_INIT(
PWDF_DRIVER_CONFIG
Config,
PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd );*/
//-- Creates a framework driver object for the calling driver --//
status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
/*NTSTATUS WdfDriverCreate(
PDRIVER_OBJECT
DriverObject,
PCUNICODE_STRING
RegistryPath,
PWDF_OBJECT_ATTRIBUTES
DriverAttributes,
PWDF_DRIVER_CONFIG
DriverConfig,
WDFDRIVER
*Driver);*/
return status;
}
//-- Each Device gets added --//
NTSTATUS KmdfEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
{
NTSTATUS status;
WDFDEVICE hDevice;
UNREFERENCED_PARAMETER(Driver);
KdPrintEx(( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: KmdfHelloWorldEvtDeviceAdd\n" ));
status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);
return status;
}
*/
WDK Kit
Differences between WDM and WDF
Device Driver Classes/Models
http://msdn.microsoft.com/en-US/windows/hardware/gg454513
http://msdn.microsoft.com/en-us/library/windows/hardware/gg583838%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/Library/Windows/Hardware/ff557557%28v=vs.85%29.aspx
7.3.4 Linux
A. Overview
Linux device drivers have 3-sides
Kernel Communications
driver registers functions that will respond to events (open file, page fault, plug and play)
talk through initialization function, register_chrdev, hooking into timer interrupt
Hardware Communications
User Communications
User driver interface via device files (character / block device files) e.g. /dev/klife device file
B. Code
'init' is called on driver initialization and 'exit' is called when driver is removed
init() will register hooks that will call driver code when an event occurs
Driver registers chardev tied to a given major number
Static int __init klife_module_init(void) {
int ret;
pr_debug(klife module init called\n);
if (( ret = register_chrdev(KLIFE_MAJOR_NUM, klife, &klife_fops) ) < 0 )
printk(KERN_ERR register_chrdev: %d\n, ret);
return ret;
}
//
//
//
//
//
//
// creates file
Use File
if ((kdf = open(/dev/klife, O_RDWR)) < 0 ) {
perror(open /dev/klife);
exit(EXIT_FAILURE);
}
- Data is pushed on and popped off (ESP always points at the first of the stack)
- Keeps track of parent function while going into called function (Just like Higher-Level-Language stacks)
- PUSH = Push value (Constants/Register Address's Value) onto stack (Not EIP; caller/jump handles that)
- POP = Gets top stack value puts into a register
- Calling Conventions
2. Libraries
StdLib
STL
Boost
3. Standards = Committees have been organized to produce standard programming language specifications that compiler writers are encouraged to follow
ANSI
Developed the ANSI C standard
ISO/IEC
Developed the C++ Standard
https://isocpp.org/std/the-committee
Reserved ID naming
'__' and '_[A-Z]'
- double underscore and underscore + capitol letter are reserved naming notations
'_*'
- prefixed underscore is reserved at the global namespace; class and local naming is okay
is[a-z]* , mem[a-z]* , str[a-z]* , to[a-z]* , wcs[a-z]* are all reserved naming conventions and should not be used
E[A-Z]*, LC_[A-Z]* , SIG[A-Z]*, SIG_[A-Z]*
are all reserved macro naming conventions and should not be used
C++ keywords are reserved
and
new
private
signed
template typeid
and_eq case
break const
double
extern if
inline
not
protected
sizeof
this
typename volatile
asm
catch
continue
else
float
int
not_eq
public
static
throw
union
auto
char
default
enum
for
long
operator register
bitand
class
delete
explicit
friend mutable
bitor
compl do
export
goto
or
namespace or_eq
static_cast TRUE
void
wchar_t
unsigned while
reintepret_cast struct
try
using
xor
return
typedef
virtual
xor_eq
switch
bool
Literals
= integer, float, boolean, char or string constant
Notation = dec, oct, hex
+ GNU Compiler Collection = An Integrated Compiler supporting multiple languages. (The abbreviation formerly stood for GNU C Compiler).
7.5.2 C++
Standard Variables
Data Types
Name
char
OPERATORS
Description
Character or small integer.
Size*
1byte
Range*
signed: -128 to 127
unsigned: 0 to 255
addition
subtraction
signed: -2147483648 to 2147483647 *
multiplication
unsigned: 0 to 4294967295
/
division
bool
Boolean value. (values: true or false)
1byte
true or false
%
modulo
short int (short)
Short Integer.
2bytes
signed: -32768 to 32767
unsigned: 0 to 65535
long int (long)
Long integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
CONDITIONAL
float
Floating point number.
4bytes
+/- 3.4e +/- 38 (~7 digits)
double
Double precision floating point number. 8bytes
+/- 1.7e +/- 308 (~15 digits)
== Equal to
long double
Long double precision floating point.
8bytes
+/- 1.7e +/- 308 (~15 digits)
!=
Not equal to
wchar_t
Wide character.
2 or 4 bytes
1 wide character
>
Greater than
operators which can appear in C++. From greatest to lowest priority, the priority order is as follows:
<
Less than
Level
Operator
Description
Grouping
>= Greater than or equal to
1
::
scope
Left-to-right
<= Less than or equal to
2
() [] . -> ++
postfix
Left-to-right
&& AND
dynamic_cast
static_cast
reinterpret_cast
const_cast
typeid
3
++ -- ~ ! sizeof new delete
unary (prefix)
Right-to-left
||
OR
*&
indirection and reference (pointers)
?:
Condition ? True : False
+unary sign operator
ESCAPE CHARACTERS
4
(type)
type casting
Right-to-left
\n
newline
5
.* ->*
pointer-to-member
Left-to-right
\r
carriage return
6
*/%
multiplicative
Left-to-right
\t
tab
7
+additive
Left-to-right
\v
vertical tab
8
<< >>
shift
Left-to-right
\b
backspace
9
< > <= >=
relational
Left-to-right
\f
form feed (page feed)
10
== !=
equality
Left-to-right
\a
alert (beep)
11
&
bitwise AND
Left-to-right
\'
single quote (')
12
^
bitwise XOR
Left-to-right
\"
double quote (")
13
|
bitwise OR
Left-to-right
\?
question mark (?)
14
&&
logical AND
Left-to-right
\\
backslash (\)
15
||
logical OR
Left-to-right
16
?:
conditional
Right-to-left
17
= *= /= %= += -= >>= <<= &= ^= |= assignment
Right-to-left
18
,
comma
Left-to-right
COMPOUND OPERATORS
BITWISE OPERATORS
expression
is equivalent to
&
AND Bitwise AND
value += increase; value = value + increase;
|
OR Bitwise Inclusive OR
a -= 5;
a = a - 5;
^
XOR Bitwise Exclusive OR
a /= b;
a = a / b;
~
NOT Unary complement (bit inversion)
price *= units + 1; price = price * (units + 1);
<<
SHL Shift Left
>>
SHR Shift Right
int
Integer.
4bytes
A. Header File
// C++ source code is typically broken out into 2-text files (.h/.cpp)
/***********************************************************************************************************
* (.h) Header files = Define the Interface ( Classes / Prototypes / Structure )
*
- #includes
Inherited classes that are required
*
- structure declares
Struct, class, union
*
- global prototypes
Global (non-member) function signatures, constants and variables
*
- see also: http://embeddedgurus.com/barr-code/2010/11/what-belongs-in-a-c-h-header-file/
************************************************************************************************************/
// PRE-PROCESSOR directives = Source code manipuation before compilation(ie: code -> executable)
// 'MYHEADER_H' = If pre-processor variable is not defined THEN
//
Set MYHEADER_H as defined and include code block (#if->#endif)
A.2 #Include/Using
<iostream> C++ standard library 'std' namespace = <stdio.h> in C
New style #include doesn't necessarily represent a file-name (why .h was removed) the actual file is decoded by the compiler.
New header files
= Includes with no (.h) and prefix of 'c' (e.g. <cstring>) and all 'c' prefixes are part of the 'std' namespace.
(prevents name collisions)
- puts the 'std' name-space into the global name-space for default non-name-space identified calls.
<stdafx.h>
<iostream>
<string>
<array>
<vector>
<list>
<set>
<map>
<stack>
<queue>
A.3 Namespace/Class/Struct/Union
namespace myspace {
//------------------ BLOCK STRUCTURES
------------------------------------------------------------------// namespace
= Named block of top-level code (typically one namespace per project)
// class
= Named design containing data and/or function code (all members are 'private' by
default)
class Arrays;
// struct
= Named class typically for data structures only
(all members are 'public' by
default)
union aunion;
// union
= Named single storage compartment having various data types associated with it
(protocol usage)
// --- Class Types --class AbstractABC;
// ABC
= Abstract base class cannot be initialized / objectified
(1+ pure-virtual
members)
template<class T> class Concrete;
// Concrete
= a class that allows object instances
(No pure-virtual
members)
class Interface {
// Interface
= An abstract-base-class(ABC) never having any functionality (All pure-virtual
members)
public:
virtual void Input(int) = 0; // virtual
= allows the function to be over-ridden in a derived classes
virtual int Output() = 0;
// pure-virtual = a member "func() =0" which makes the class abstract(ABC)
};
struct Fundamental_Data_Types {
//--------------------- DATA TYPES
---------------------------------------------------------------------bool Abool;
// Boolean
= true/false
1-byte
short AShort;
// Short
= 32,767(+/-)
2-byte
int AnInt;
// Integer
= 2,147,483,648(+/-)
4-byte
long ALong;
// Long
= 2,147,483,648(+/-)
4-byte
float Afloat;
// Float
= E+/-38 ~7 digits
4-byte
double Adouble;
// Double
= precision ~15 digits
8-byte
char AChar;
// character
= (1)ASCII character 1-byte
others: char16_t, char32_t, wchar_t(2/4-byte)
wchar_t AWChar;
char Charray[5][5];
// arrays
- Any data type can be a single[index] or multi[5][5] dimensional array.
ulong ultype;
// user-defined = typedef name (See 'typedef' above)
} FData;
// ** Optionally ** classes, struct, and union can initiate objects(CSV) right away (e.g. 'FData'
object)
struct STL_Containers {
std::string name;
std::vector<int> vect;
std::list<int> linklist;
std::set<int> aset;
std::map<string,int> amap;
std::stack<string> astack;
std::queue<string> aqueue;
} STLCon;
//
//
//
//
//
//
//
Multi-character strings
Dynamic array type
Link list
Data Sets
Dictionary - Hash Table
Stack
Queue
}
//#endif
B. Source File
/***********************************************************************************************************
* (.cpp) C++ source code "body" file
*
- File where header(.h) declaration are defined (over-riding the empty declarations)
*
************************************************************************************************************/
// #include <ThisFile.h>
using namespace myspace;
class myspace::AbstractABC {
//---------------------------- MEMBERS
-----------------------------------------------------------------private:
// private
= members that are visible/accessible in-class
protected: string thewords;
// protected
= members that are visible/accessible in-class and derived-classes
public:
int LetterCount;
virtual void Words(string in) {
this->thewords = in;}
virtual string Words() {
function to use)
return this->thewords;}
//
//
//
//
//
public
Field
Property(Set)
this
Property(Get)
// return
=
=
=
=
=
is type returned)
virtual void Display() = 0;
};
// Function()
template<class T>
// template<T>
= Identifies 'data type' used in the class; set by the initializing
caller
class myspace::Concrete :
// [:]
= Inherits
public Interface,
// ***** NOTE: Variables cannot be initialized in the original class definitions *****
public AbstractABC {
//
private: T iIn;
// typename T
= is the received template argument passed to this class @ initialization
public:
//
Concrete(int a) { iIn = a;}
// Constructor
= Gets called automatically when an object of this class is created
(ie: 'new')
~Concrete() { iIn = 0;}
// Destructor
= Gets called automatically when an object of this class is destroyed
(ie: 'delete')
void Input(T In) { this->iIn = In;}
// Implement code-bodies for the Interface members
T Output() { return this->iIn; }
//
void Display() {
// Implement code-bodies for the AbstractABC class - Only Display() is still a pure-virtual
std::cout << "Input = " << Output()<< "\n";
std::cout << "Words = " << Words() << "\n";
printf("Protected 'thewords' = %s\n",this->thewords);
}
};
int main()
---------------------------------------{
type [*]
printf
[&]
[=]
=
=
=
=
[*]
type 'name'
new
[.]
[->]
STLCon.name = "Hello";
std::cout << InlineAdd(2,3);
//----------------------------- Flow Control
-------------------------------------------------------for(int i = 0; i < 5; i++) {
// for-loop
= for(variable; loop again condition; per loop command) { commands }
if (i == 1)
// if
STLCon.name = "One\n";
else if (i == 2)
// else if
continue;
// continue
= immediate next-iteration
ie: skip the rest of the loop
else if (i == 4)
break;
// break
= immediate exit
ie: Exit the loop without finishing
else
// else
=
if (i != 0)
STLCon.name = "Empty\n";
try {
// try
= Error Handling routine
std::cout << STLCon.name;
// cout
= C++ send to standard output (e.g. standard output(console) receives
STLCon.name)
throw exception("My Exception");
// throw
= Raise a runtime error
} catch (...) {
std::cerr << "Something";
}
}
for(char c : STLCon.name) {
std::cout << "[" << c << "]";}
while (IntVal > 0 ) {
std::cout << IntVal << "\n";
IntVal--;}
do {
std::cout << IntVal++ << "\n";
} while (IntVal <= 5);
switch (IntVal) {
case 1:
std::cout << "One";
break;
case 2:
std::cout << "Two";
break;
default:
std::cout << "Not One or Two";
}
return 0;
// catch
// cerr
// for :
//
// while
// do-while
// switch-case
// case
// if 'break' is missing both 'case 1' block and 'default' block would execute when IntVal = 1
//
// default
// main return
B.1 Details
int main() in C++ = int main(void) in C
('void' isn't required in C++)
'<<' (output operator) in C++ shifts something into 'cout' the screen - C uses printf() to print on screen (C++ supports printf also)
'>>' (input operator) in C++ 'cin' = standard input device
Single value initial assignments
Type X(99); is the same as Type X = 99;
char me[] = "String Literal"; //Which is a character array with terminator \0
void* - Any data type but must be defined before *
NULL = 0 or pointer that goes no-where
Lambda functions are code blocks (ie: Like a function w/o a name)
auto is like template T but determines type automatically (need to look into this one a little more)
Struct, Class, Union
struct A UDT or Class generally used to declared plain data structures, can also be used to declare classes that have member functions, with the
same syntax as with keyword class. The only difference between both is that members of classes declared with the keyword struct have public
access by default, while members of classes declared with the keyword class have private access by default. For all other purposes both keywords
are equivalent in this context.
Unions - is different from that of classes declared with struct and class, since unions only store one data member at a time, but nevertheless they are
also classes and can thus also hold member functions. The default access in union classes is public.
Only base classes are allowed 'pure-virtual' members
C++ Dynamic Link Library (DLL)
Has a main entry point DllMain() that gets called by each connecting application
DLL defines its own interface which is exported as a (.LIB) file that applications link to
D. Makefile
Variables
NAME = VALUE
Special
$@ = Name of the file to be made
$? = Names of the changed dependents
MS editions of Make is Nmake
Research also
Line types:
-File dependancies
-shell commands
-variable assignments
-include statements
-conditional (loops & comments)
Extenting a line via \
Visual Studio
Command
devenv.exe
make Utility
make
Makefile
Dependency
.sln has list of projects and dependencies The root directory Makefile will recursively find other makefiles via the command $(MAKE)
Compiler
cl.exe
Linker
link.exe
7.6 Java
Java Source Compiler Java Byte-Code (object file) Java Virtual Machine (Interpreter) Machine Language
Java Incorporates both compiling and interpreting machine code generation methods
Compilation Java Byte Code (Platform Independant)
Java Byte Code Java Virtual Machine (JVM) Machine Code
JVM can be installed at the hardware (Java Processor), system software (JVM) or application layer (JVM)
Contains 2-Components; JVM Classes / (Compiled Libraries) / Java APIs & Execution Engine
See http://www.oracle.com/technetwork/java/embedded/javame/embed-me/documentation/javame-embedded-apis-2181154.html
Java Technologies
See https://www.oracle.com/java/technologies/solutions.html
Java Card
Java Cloud Service
Java EE
- Enterprise Edition with HTML5
Java Embedded
Java ME Embedded Client
- Micro Edition for small embedded devices.
Java ME SDK
Java SE
- Standard Edition
Java SE Advanced and Suite
Java SE Embedded
Java SE Support
Java TV
Java Wireless Client
Jrockit
JIT
Just In Time Compilation ( Interprets source once and stores the native form; allowing redundant code to be executed w/o
reinterpreting )
Variations on the JIT compiler are referred to as translators or dynamic adaptive compilation (DAC)
Compilation to an Intermediate Language (.NET Common Intermediate Language (CIL))
See http://connect.smithmicro.com/insignia-device-management
7.7 C#
Features of C#
Versioning
Generics
Delegates
Data Types
Value Types variables that directly contain a value (copies the contained value ie: a=b)
Reference Types variables that contain a pointer to an object but not the object itself.
To write/read a file:
iFileHandler = FreeFile
Open <filename> For Output As #iFileHandler
Write #iFileHandler <string>
Close #iFileHandler
Late Binding:
Public Me as Object
Me = CreateObject(<Class(name)>)
Set Me = ObejctFromSomewhere that is type identified.
Early Binding:
Public Me as New <ClassName>
To check if an array is initialized use If ((Not Array) = -1) Returns -1 if NOT initialized
Above notation only works on base variable types, UDT (User-Defined Type Arrays will not work)
If an empty string array is cast into a variant the above will not flag correctly;
Use LenB(Join(VariantArrayName)) = 0 to determine if a String() that is passed as a variant has been initialized.
Variants received as Non-Array Cannot be Cast to Array (Ex: variant = split(variant)) DOESNT WORK.
For this a second Variable Dim VariantArray() as ?? need to be setup and only If Then structure will work
Example; If IsArray(Variant) Then VariantArray = Split(Variant) Else VariantArray = Variant
Compiled vs Debugging VB6 ( Unexpected differences between)
Util.Average Throws a Expression Too Complex during DLL debugging, but works OK when not debugging.
If a Function returns a String() then a For Each <Variant> will cause a compiled DLLs to Crash Excel but not during VB6 debugging.
Never Use On Error Resume Next during a Open FILE operation because EOF() is never reached (endless-loop) with a compiled DLL but works with
VB6 debugger.
Conditional Compilation Arguments
Pre-Compilation Options (ie: #IF something THEN) can be set either locally or project globally.
Local - Use #Const something = <Integer> will apply only to the class/Module.
Be careful since local #Const something = Can be a string BUT global ones can only be integers. (+/- are supported)
Global - Use VB6 or VBA Menu item Project Properties Conditional Compilation Arguments (Under Make Tab in VB6).
Example; See UseEmulator setting below which will set all #If UseEmulator = 1 Then Statements in all modules and classes.
Multiple items can be assigned by separating them with a (:)
Grabbing object from Excel VBA into VB6 automatically (TheHdw & TheExec) without passing the object.
Note: The VBA call function that returns the object must be a function (ie: It cannot be a property get)
If TheHdw Is Nothing Or TheExec Is Nothing Then
'vvv[ Get TheHdw & TheExec Objects from Excel ]vvvvvvvvvv
Dim ExApp As Excel.Application
Set ExApp = GetObject(, "Excel.Application")
Set TheHdw = ExApp.Run("tl_tm_GetTheHdw")
Set TheExec = ExApp.Run("tl_tm_GetTheExec")
Set ExApp = Nothing
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
End If
Excel crashes when VB6 DLL Module has global names conflict with VBA names
Its always a good idea to make VB6 modules Private to the VB6 Project.
Option Explicit
Option Private Module '//Prevent module clashes with Excel VBA - Keeps Module private to this Project.
Notes about VB6 Events (ie: Private WithEvents OBJ as CLS & Public Event Something())
Events CANNOT be handled in a Module (Must be contained in classes)
Object that trigger or handles Events must be put into a class.
Objects must be early-binded (late-binding doesn't cause events to trigger)
The class containing the Handling object Public WithEvents OBJ as CLS must also contain all Event handlers
An object with events cannot be passed into a class that handles the events
All object variables must reside in the same class with the event handling subs.
Event handler subs can objects CAN be Private
Any object variable WithEvents cannot be assigned within a TYPE structure.
When events don't work (something is out of place) there is no error trapping/messages available that I know of.
Mostly composed of remote terminal units (RTU) across larger areas geographically
Generally includes a network of PLC controllers
Micro-controller device for industrial use
Device control with an interface to DCS or SCADA systems
SLC-500 System
http://ab.rockwellautomation.com/Programmable-Controllers/SLC-500
Programming Software = Rockwell RSLogix500
Point I/O
CompactBlock LDX
Communications
EtherNet/IP
ControlNet
DeviceNet
Universal Remote I/O
DH+, DH-486 (RS-232)
8.2 Siemens
STEP 7
CONFIGURATOR
8.3 Omron
Syswin
CX-Programmer
WINNT
Ladder-Logic components
Rungs (horizontal lines span edge-to-edge)
Nodes (Internal Input / Output Points bits)
Inputs ( I:1.0 would be found on the PLC-Controller as ??? )
Outputs ( O:2.0 would be ??? on the PLC I/O Rack )
Vendor Specific Software is Used to Program ladder-logic
Allen-Bradley RSLOGIX
Omron
CXP, SYSWIN
(Believe NTWIN is come kind of Omron Table)
Siemens
STEP 7
--[ References ]---------------------------------------------------------------------------------------------------------------------------------------------------Diagrams here include Ladder-Diagrams and how they relate to Gate Logic Circuits http://www.allaboutcircuits.com/
A Company specifically for HMI Interfaces that supports various PLC Manufacturers out there.
Industrial Application Server (by ArchestrA)
HMI development software
Wonderware FactorySuite
Wonderware System Platform
Appliation Server
Historian
Information Server
Device Integration Products
8.6 Instrumentation
Motor Control
Starter
Contactor
Drives
VFD
Encoder
Meger
Safe starts a large-load motor and protects against under-voltage overload protection
Heavy current relay
Sometimes short for VFD or to describe large scale VFD.
= Variable Frequency Drives
Adjusts AC frequency and voltage to produce motor speed control
Measures motor rotations / speed
Hand-Held test equipment to measure wire insulation (Commonly used to find a faulty motor)
Valves
Solenoid Valves
I/P Transducer
Butter Fly Valve
Angle Seat Valve
= Commonly used device the PLC activates to turn on/off air pressure to devices like pneumatic vales / cylinders (rams) and etc.
= Converts electrical current/voltage to output pressure (I/P= Current Pneumatic Pressure)
= 90-degree angle pipe valve
= Common Pneumatic actuated tank outlet valve
Sensors ( Transducers )
Condition
Temperature
RTD = Resistance temperature detectors
Thermo-couples
Thermisters
Pressure
Level
Flow
Speed
HVAC
pH Sensor
Proximity
Capacitive( Non-metal detection )
Inductive ( Metal object detection )
Photoelectric (Beam or Reflective)
Ultrasonic ( Reflective Sound Level of water in tank )
Switches
Limit Switches
Safety Interlock switches
Flow
EMF Electromagnetic Flow Meter (ie: MagMeter)
UFM = Ultrasonic Flow Meter
Acronyms
CIP = Cleaning In Place
An equipment cleaning process that doesn't require tear-down or removal (Flush/Clean pipes with chemicals)
SIP = Sterilization In Place
Illustration 11: PLC Panel with ControlLogix PLC(Top), VFDs(Center) and Starters(Bottom)
9. NETWORKING
IEEE Committees
802.3
802.11 / 802.16 / 802.20
Cellular
= Ethernet
= Wireless Local Area Networks (WLAN)
DMTF
DMI
MIB
SNMP
= Distributed Management Task Force (IT Enterprise Infrastructure Technology for containing routers, printers, and etc... on a common network)
= Desktop Management Interface
= Management Information Base/Database
= Simple Network Management Protocol
The DMTF DMI MIB provides the framework for accessing DMI instrumented information and receiving Desktop Management Interface (DMI) indications
through an SNMP/DMI Mapping Agent.
4G Networks
FDMA (Frequency-division) Multiplexing
www.cdg.org
www.etsi.org
IEEE 802.15
www.ieee802.org/15/
IEEE 802.11
www.ieee802.org/11/;
www.standards.ieee.org
www.irda.org
www.imt-2000.org
www.itu.int/home/index.html
www.mobitex.org
QUALCOMM CDMA
www.qualcomm.com/cdma/index.html
www.3gpp.org
www.3gpp2.org
3G Americas
www.3gamericas.com
3G information
www.3g.co.uk
www.umts-forum.org
Wi-Fi Alliance
www.wi-fi.org
DCE
CSU
DSU
M2M
NMS
IoT
CO / POP
Local Loop
Toll Network
MTU
+ Machine to Machine
+ Network management stations
+ Internet of Things
+ Central Office / Point of Presence
- Closest CO Demarc
= Trunk line in providers network
+ Maximum Transmission Unit
Domain
AS
ES
IS
= Collection of networks under common administration and sharing a common routing strategy
+ Autonomous System (ie: Domain)
+ End System
Does not preform routing or forwarding (e.g. Printers, Workstations, Servers)
+ Wireless Wide Area Network (Mid to Long Range / Cellular Standards (Outdoor Networks))
+ Wireless Metropolitan Area Networks
= No Base Router Node to Node connection (e.g. Only a Crossover Cable / Hub )
Network Devices
Communication Basics
Device Addressing = Scheme used to identify a network device
Logical
Typically; IP-Address (IPv4 or IPv6 )
Physical
Typically; MAC-Address
Collision Domains
= Parallel connected devices all receiving the same line signal; only one device can communicate at a time; Destination NIC filters
the traffic
Hub
All-ports are on the same Collision Domain
Switch
Per-port Collision Domain (Layer-2)
Router
Per-port Collision Domain (Layer-2)
Private Collision Domain = One host per Port (Private within the plug/port)
Broadcast Domains
Network)
Hub
Switch
Router
= Group of devices that all receive the Broadcast signals (ie: Signals sent to IP - ###.###.###.255 or MAC xx:xx:xx:ff on a Class C
All ports are on the same Broadcast Domain
All ports are on the same Broadcast Domain
Per-port Broadcast Domain (Layer-3)
Domain Networks use the Domain Name Service (DNS) to obtain destination MAC address
MS-Windows also allows a generic Data-Link Broadcast (ie: IP - ### . ### . ### . 255 , MAC ff:ff:ff:ff ) for Host Name to MAC address resolution
Source Device Sends:
Src: 192.168.0.2 - Dst: 192.168.0.255(ie: Data-Link Broadcasting Address) - Protocol: NBNS - Info: Name Query
NB<DstHost><00>
Destination Response:
EthernetII,Src:192.168.0.2(00:14:22:be:18:3b),Dst:Broadcast(ff:ff:=ff:ff:ff:ff)
Source Device Sends:
Src: 192.168.0.2 - Dst: 192.168.0.255 - Protocol: ARP - Info: Who has 192.168.0.37 Tell 192.168.0.2
Destination Response:
Src: 192.168.0.3 Dst: 192.168.0.2 Protocol: ARP Info: 192.168.0.3 is at 00: db:db:99:d3:5e
Destination Response:
Src: 192.168.0.3 Dst: 192.168.0.2 Protocol: NBNS Info: Name query response NB 192.168.0.3
Communication Types
Layer-2/Hardware Broadcasts
Layer-3 Broadcasts
Unicast
Multicast
= Using MAC Wild-Card (ff) to address all nodes on a LAN ( Broadcast doesn't go past any routers / LAN only )
= Using IP Wild-Card (255) to signal all nodes on a LAN
= Single destination host (e.g. DHCP)
= Single source many devices on different networks (Subscribed in a group address list )
Reference
Cisco Wiki @ http://docwiki.cisco.com/wiki/Main_Page
Protocol
methods/rules
Protocol Categories
Interconnection
LAN Protocols
WAN Protocols
Network Protocols
(ie: Router/Switch Protocols) Handle data transfers and routing from point to point
Protocol Documentation
IANA
Internet Assigned Numbers Authority Group that carries many of the protocols and standards used on the Internet
IETF
Internet Engineering Task Force
The group that creates Internet protocols and standards published as RFC(s)
RFC Request for Comments
Documentation scheme used to document a technology and/or standards
FYI
= For Your Information
An RFC that is for Information
BCP
= Best Current Practices
An RFC describing a Best practice
STD
= Standards
An RFC Numbered separately and used for describing an Internet Protocol
TS = Technical Specification
A STD RFC that defines the protocol; Progressively staged as 1 st Proposed, 2nd Draft, then 3rd
Internet Standard.
AS = Applicability Statement
A STD RFC Document that describes when the protocol is to be used (e.g. Required,
Recommended, Elective )
Reference
Wiki List of Network Protocols (OSI model ) http://en.wikipedia.org/wiki/List_of_network_protocols_%28OSI_model%29
= TCP/UDP:Port# ( 0-1023 reserved ); like virtual mail-boxes for Application protocol specific delivery; Used by the
= IP : Port# (e.g. 192.168.10.20:80) Created for each communication task
= Includes the Socket identifier of both source and destination requiring at least one unique item per communication
At http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
View C:\Windows\System32\Drivers\Etc\SERVICES
B. Presentation (Layer-6)
Presentation Layer= Manages a common data representation method between systems for communication data translation (OS-Layer)
Big / Little Endian Negotiates the Byte Order between systems
Encryption
Enables encrypted data to be deciphered at the destination
Compression
Enables data compressed at the source to be DE-compressed at the destination
Text / Data
Negotiates common character sets (ie: US-ASCII, EBCDIC)
Video
Like QuickTime, Motion Picture Experts Group (MPEG)
Graphics
Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG), Tagged Image File Format (TIFF)
Protocols
NVT
= Network Virtual Terminal (Subset of the Telnet Specification)
IBM NetBIOS
XDR
= Sun's External Data Representation
DCE RPC
= Distributed Computing Environment's Remote Procedure Call
C. Session (Layer-5)
Session Layer
= Establishes, Manages, and Terminates Communication Sessions between two systems (ie: Service Requests / Service
Responses) per application
ZIP
= Zone Information Protocol
AppleTalk
= Coordinates the name binding process
SCP
DECnet Phase IV
Duplexing Control
Simplex
Half Duplex = Hubs
10Mbps / 10BaseT ; Uses one set of wires ( Send -or- Receive )
Full Duplex
= Switch / Crossover Cable 100Mbps; Uses two sets of wires ( Send -and- Receive ) ; No collisions
= No reliability; Used occasionally for a status update broadcast (like printer toner low)
= Uses Sequencing, ACK, and Windowing flow control for reliability
Interconnection Protocols
IP
ICMP
ARP
RARP
Proxy ARP
+ Internet Protocol
+ Internet Control Message Protocol
+ Address Resolution Protocol
+ Reverse Address Resolution Protocol
- Allows Hot swap-able router additions
= Routed Protocol; Logical addressing and physical location for path determination
= Runs on top of IP ( Generated by Routers ); ICMP Echo is commonly named Ping
= IP MAC Address resolution (Doesn't use IP Transport)
= MAC IP Address resolution
= See also Cisco Host Standby Router Protocol (HSRP)
Other Protocols
IPX
MPLS
IP-Class Schemes = An IP-Address has various schemes (ie: IP-Class) that is identified by it's first octet range
Class A = 0 127
Prefix 0
Subnets CIDR /8 /15
Class B = 128 191 Prefix 10
Subnets CIDR /16 /23
Class C = 192 223 Prefix 110 Subnets CIDR /24 /30 (2-bits for hosts are required)
Class D = 224 239 Multi-cast
Class E
= 240 255 Scientific
** e.g. 192.168.0.1 is a Class C IP which means its on Network (ie: LAN) 192.168.0 host 1
Wild-Card (0)
0.0.0.0
1.1.1.1
0.0.16.23
1.1.16.23
127.0.0.1
= Typically used to address an entire Network (e.g. Class A: 10.0.0.0, Class B: 172.16.0.0, Class C: 192.168.10.0)
Default route or any network
All 1s Broadcast / Limited broadcast; reacts same as 255.255.255.255
This(0) network where network bytes are (0)
All(1) networks node 16.23
Loop-back (local node)
Wild-Card (255)
255.255.255.255
172.16.255.255
Private IP
= Addresses for local network only ( Not routable )
NAT = Network Address Translation Converts Private IP to a routable one
Static NAT
= One to one mapping between local and global addresses
Dynamic NAT
= Map unregistered IP addresses to registered IP(s)
PAT (ie: NAT Overloading)
= Port Address Translation Most popular; Maps multiple unregistered IP-Addresses to a single
registered IP-Address
CIDR
CIDR
Supports TCP/UDP Port protocols at the data-link layer (see IEEE 802.2 Spec)
Provides protocol access to the physical network medium.
Preamble
SFD/Sync
DA + Destination Address ff:ff:ff:ff:ff:ff:ff address is a Ethernet Broadcast going out to all devices
SA + Source Address
Length (802.3)
= Must be used with a proprietary LAN (e.g. IPX)
Type (Eth II)
= Network layer protocol type (0x800 = IPv4, 0x86DD = IPv6 )
Data
FCS
Frame Data
Routing Protocols
STP + Spanning Tree Protocol Used to stop network loops from occurring
UN-Managed doesn't have routing loop prevention (When two switches are connected together using non-Trunk ports)
Allows switches to talk to each other and route packet fastest way from A B
Prevents routing loops
WAN Protocols
Serial Interface Protocols
HDLC
+ High-Level Data-Link Control Protocol = ISO-standard encapsulation for data on synchronous serial links (Point-to-Point Protocol)
PPP
+ Point-to-Point Protocol
LCP
+ Link Control Protocol
NCP
+ Network Control Protocol
IPCP
IPXCP
Frame Relay
= Links for carrying HDLC (e.g. Asynchronous (dial-up) / Synchronous (ISDN) serial media)
= Method of establishing, configuring and terminating P2P connections
= Establishing/Configuring multiple network layer protocols (routed protocols) on a P2P
Data-Link/Physical Protocol; successor to X.25; Provides dynamic bandwidth and congestion control
Classified as a Non-Broadcast Multi-Access (NBMA) Network; Doesn't send any broadcasts like RIP updates
Roots of X.25; It is a Leased-Line network (but not a HDLC/PPP network) TELCO Network
Is a Packet-Switched technology (ie: Splits one communication path into multiple paths / inputs to routers)
CIR
= Committed Information Rate Guaranteed maximum bandwidth
Packet Encapsulation
Cisco
= Used if both devices connected are Cisco devices
= Like a phone call only established when data needs transferred (for Private usage)
Protocols
Ethernet Protocol
[ 802.3 ]
Cabling
Networking Cables
RJ45 Connector is used in Twisted pair cables
Straight-Through
= Cable is used for host/device to hub/switch/router
Crossover Cable
= is used for no network device PC to PC networking
Rolled Cable
= Fancy word for an RS-232 Cat5 cable used for Network equipment's Terminal Emulation
SAP
+ Service Access Point
=The cable ending/plug standards
EIA/TIA-232 or TIA-449
V.35
= For CSU/DSU connection points
EIA-530
HSSI
= High Speed Serial Interface
G.1 WAN Physical Layer
Terms
HSSI
CATV
DSL
= Digital Subscribe Line
Symmetrical DSL = Up/Download speeds the same
Asymmetrical DSL = Different Up/Download Speeds
ADSL
= ?? (Carries voice/data together)
HDSL
= High-bit-rate DSL
RADSL
= Rate Adaptive DSL
SDSL
= Synchronous DSL (data only)
IDSL
= ISDN DSL (data only)
VDSL
= Very-high-data-rate DSL (Carries voice/data together)
LRE
= Cisco's Long Range Ethernet (Employs VDSL)
MPLS
ATM
Speeds
64Kbps
1.544Mbps(T1)
4.5Mbps(T3)
WLAN + Wireless Local Area Networks
802.11 Wireless specification is like hub Ethernet; Uses Half-Duplex over Radio Frequency (RF)
802.11b ( Released ? - 2.4GHz )
Rate Shifting 1, 2, 5.5 and 11Mbps depending on signal integrity
CSMA/CA
= Carrier Sense Multiple Access w/ Collision Avoidance using Request-To-Send (RTS) and Clear-To-Send (CTS)
CSMA/CD
= Carrier Sense Multiple Access with Collision Detection
Modulation via Direct Sequence Spread Spectrum (DSSS)
802.11g ( Released 2003 2.4GHz , 54 Mbps )
802.11b compatible (DSSS Modulation) but delivers 54Mbps on OFDM Access Points (AP)
Modulation by Orthogonal Frequency Division Multiplexing (OFDM)
802.11h
Adds Multiple Input Multiple Output (MIMO) providing 250Mbps.
802.11a ( Released 1999 5GHz , 54Mbps )
Originally very expensive
Rate Shifts of 6, 9, 12, 18, 24, 36, 48 and 54Mbps
Extended as 802.11h adding Transmit Power Control (TPC) (For battery conservation) and Dynamic Frequency Selection (DFS)
Cisco Unified Wireless Solution
WMAN = Wireless Metropolitan Area Networks
FCC Released Frequencies for Public Use
900MHz Referred to as the Industrial, Scientific, and Medical (ISM Band)
2.4GHz Also Referred to as the Industrial, Scientific, and Medical (ISM Band)
5.7GHz Referred to as the Unlicensed National Information Infrastructure (UNII Band)
802.11b/g/n
802.11a/h
CLI
+ Command Line Interface
= CLI Session also called an EXEC session.
Aux Port
Terminal access via Callable Telephone Modem (ie: out-of-band)
Ethernet
Terminal access via Ethernet (ie: In-band)
Serial Port
Terminal access via a serial RJ45
>ip subnet-zero
10. RESOURCES
1. EDA.org
a)
2. Electronic Circuits
a) Circuit tutorials
b) Circuit exampels (DIY)
http://www.eda.org/
http://www.electronics-circuits.com/index.html
http://www.ce.org/
JavaTV
DVB
MHP
DAVIC
ATSC
DASE
ATVEF
SMPTE
DTVIA
ARIB-BML
OCAP
OSGi
OpenTV
MicrosoftTV
http://www.oracle.com/technetwork/java/embedded/javame/index.html
Digital Video Broadcasting
Multimedia Home Platform
Digital Audio Visual Council (ISO/IEC 16500)
Advanced Television Standards Committee
Digital TV Applications Software Environment
Advanced Television Enhancement Forum
Society of Motion Picture and Television Engineers (DDE-1)
Digital Television Industrial Alliance of China
Association of Radio Industries and Business of Japan
OpenCable Application Forum
Open Services Gateway Initiative
DVB-Compliant
https://www.dvb.org/standards
http://en.wikipedia.org/wiki/Multimedia_Home_Platform
http://www.davic.org/ http://www.iso.org/iso/home.html
http://www.atsc.org/cms/
http://www.atvef.com/
https://www.smpte.org/
http://www.arib.or.jp/
http://www.cablelabs.com/specs/specification-search/?cat=video
http://www.osgi.org/Main/HomePage
http://www.nagra.com/
http://windows.microsoft.com/en-us/windows/understanding-tv-signals-
tuners#1TC=windows-7
HAVi
Home Audio Video Initiative
Medical Devices
FDA
US Food and Drug Administration
http://www.fda.gov/
Medical Devices Directive
Medical Device Communications
IEEE1073
Industrial Automation and Controls
IEC
International Electrotechnical Commission
http://www.iec.ch/
ISO
International Standards Organization
http://www.iso.org/iso/home.html
DICOM
Digital Imaging and Communications in Medicine `
http://medical.nema.org/
Department of Commerce
http://trade.gov/td/health/
The Machinery Directive
Networking and Communications
Ethernet
Institute of Electronics and Electrical Engineers
IEEE 802.3
http://www.ieee.org/index.html
TCP/IP
Transmission Control Protocol / Internet Protocol - RFC 791(IP) & 793(TCP) http://www.faqs.org/rfcs/
PPP
Point-to-Point Protocol
Cellular
http://www.cdg.org/
http://www.tiaonline.org/
HTTP
Hypertext Transfer Protocol
http://www.w3.org/Protocols/Specs.html
SIG-Bluetooth
Bluetooth Special Interest Group
https://www.bluetooth.org/en-us
HTML
Hyper Text Markup Language
Automotive
OPEL
Engineering Material Specifications
https://www.ihs.com/products/design-industry-standards-organizations-
index.html
FMVSS
Federal Motor Vehicle Safety Standards
http://www.nhtsa.gov/cars/rules/standards/
ISO/TS 16949
The Harmonized Standard for the Automotive Supply Chain
http://www.iaob.org/
GM Global
https://www.ihs.com/products/design-industry-standards-organizations-index.html
Ford Standards
same as above
Aerospace and Defense
SAE
Society of Automotive Engineers
http://www.sae.org/
AIA/NAS
Aerospace Industries Association of America
http://www.aia-aerospace.org/
DOD
Department of Defense
DISA
Defense Information Systems Agency
http://www.disa.mil/
JTA
Joint Technical Architecture
Office
TIP/SI
TechnologyTransport Independent Printer/System Interface
IEEE Std 1284.1 1997 IEEE
Postscript
http://www.adobe.com/
ANSI/AIM
Uniform Symbology Specification for Bar Codes
http://www.aimglobal.org/standards/aimpubs.htm
http://netscape.aol.com/
http://www.ieee802.org/
10.4 Symbols
10.4.1 Timing Diagrams