Академический Документы
Профессиональный Документы
Культура Документы
Tato prezentace je spolufinancovna Evropskm socilnm fondem a sttnm rozpotem esk republiky.
29. 6. 2012 1
Obsah seminra
1. vod do CompactRIO platformy 2. Konfigurcia zariadenia 3. Architektra aplikci 4. Scan mode snmania dt 5. Prca s programovatenm hradlovm poom 6. Vvoj Real-time aplikci 7. Vvoj aplikcie na riadiacom potai 8. Transfer dt
29. 6. 2012
Lekcia 1
29. 6. 2012
A. CompactRIO
Programmable Automation Controller (PAC) Analog and digital I/O Floating-point processing Seamless connectivity EmbeddedA component in a larger system. HeadlessOperates without a user interface and when the host computer is unavailable Rugged50 g shock, 40 to 70 C
29. 6. 2012
B. Applications
Machine Control
High-speed motion control Real-time signal processing and control of power electronics, hydraulic systems Custom motion and vision inspection, material handling
29. 6. 2012
B. Applications
Machine Condition Monitoring Bearing order analysis, lubrication monitoring Mobile/portable DSA Noise, vibration, dynamic signal analysis, acoustics Distributed Acquisition Central controller with distributed I/O nodes over Ethernet/wireless
29. 6. 2012
B. Applications
Automotive & Aerospace In-Vehicle Data Acquisition Automobiles, motorcycles, recreational vehicles, research aircraft, trains Engine and ECU test cells HIL testing of engines and engine controllers, sensor simulation using FPGA Rapid Control Prototyping Automotive/aerospace control prototyping
29. 6. 2012
C. Application Architecture
29. 6. 2012
C. Application Architecture
Alternate Architectures
Windows host VI and RT controller VI Standalone RT controller VI Stand-alone FPGA VI Stand-alone FPGA VI and RT controller VI
29. 6. 2012
C. Application Architecture
FPGA Functions
I/O, Hardware-based timing and triggering Low-level signal processing
29. 6. 2012
10
C. Application Architecture
Real-Time Controller Functions
FPGA interaction
Configuring Communicating data Controlling
29. 6. 2012
11
C. Application Architecture
Windows PC Functions
Logging data Accessing databases Integrating with enterprise systems Providing a human-machine (User) interface (HMI) and display Supporting supervisory control
29. 6. 2012
12
D. Components
FPGA 1M-5M Gate
PCI Bus
29. 6. 2012
13
D. Components
29. 6. 2012
14
D. Components
29. 6. 2012
15
D. Components
9012 RT Controller Memory
Nonvolatile memory stores information even when not powered
Nonvolatile 128 MB
DRAM 64 MB
Used for drivers, storing VIs, and the Shared Variable Engine
29. 6. 2012
16
D. Components
29. 6. 2012
17
D. Components
Custom circuitry for per the measurement type. Direct connection to Industrial sensors and actuators
29. 6. 2012
18
29. 6. 2012
19
G. Accessories
Industrial enclosures Flat-panel touch-screen industrial computers Power supplies
29. 6. 2012
20
Find Specifications
Hardware ships with
User Manual Getting Started Guide Installation Guide
All product listings on ni.com contain links Data Sheets and manuals
29. 6. 2012 21
H. Operation
Power-on Self Test Power-on Self Test (POST) 1. Power LED ON 2. Status LED ON 3. User1 LED ON
POST Complete 1. Power LED ON 2. Status LED OFF 3. User1 LED OFF
29. 6. 2012
22
H. Operation
DIP switches
29. 6. 2012
23
H. Operation
Safe Mode Switch
Determines whether the embedded LabVIEW Real-Time engine launches when the controller boots. Normal operation is the OFF position. If ON only the essential services required for updating configuration and installing software are loaded. Use ON if the software on the controller is corrupted. ON required to reformat the drive Refer to MAX Help for more about installing software and reformatting the drive.
29. 6. 2012
24
H. Operation
Console Out Switch
Serial Communication Serial-port Configuration:
9,600 bits per second Eight data bits No parity One stop bit No flow control
Keep the Console Out switch in the OFF position during normal operation.
29. 6. 2012
25
H. Operation
IP Reset Switch
ON position and reboot resets the IP address to 0.0.0.0. If on your local subnet and the IP Reset switch is ON, the controller appears in MAX with IP address 0.0.0.0. Configure a new IP address for the controller in MAX. ON unlocks a controller that was locked in MAX. Keep the IP Reset switch in the OFF position during normal operation.
29. 6. 2012
26
H. Operation
Restore Defaults
If the controller is not able to communicate with the network Changes the IP address, subnet mask, DNS address, and gateway to 0.0.0.0 Does not affect power-on defaults, watchdog settings, or VIs
To restore defaults:
Move the IP Reset DIP switch to the ON position. Push the Reset button to cycle power to the controller. The Status LED flashes once, indicating that the controller IP address is unconfigured. Move the IP Reset switch to the OFF position.
29. 6. 2012
27
H. Operation
No App Switch
ON prevents a LabVIEW startup application from running when the controller powers on. To permanently disable the application from running at power up, disable it in LabVIEW. To run an application when the controller powers on, push the No App switch to the OFF position, and configure the application in LabVIEW to launch when the controller powers on.
29. 6. 2012
28
H. Operation
User1 Switch
User defines the behavior of the User1 switch with the RT Read Switch VI in a LabVIEW Real-Time embedded application.
29. 6. 2012
29
H. Operation
9012 Controller LEDs
29. 6. 2012
30
H. Operation
Power LED Lit indicates the power supply is adequate, and the controller is supplying power to the CompactRIO system. FPGA LED Programmable for application debugging or status. Refer to LabVIEW Help for information about programming. User1 LED Programmatically definable to meet the needs of your application in the RT VI.
29. 6. 2012
31
H. Operation
Status LED
Off during normal operation. Indicates errors by flashing certain patterns:
Slow, continuous flashing. The controller is unconfigured. Use MAX to configure. 2 flashes Software error. Reinstall software. Use MAX Help. 3 flashes Safe Mode DIP switch is in the ON position. 4 flashes The controller software has crashed twice without rebooting or cycling power between crashes. Controller may be out of memory. Review your RT VI. Continuous flashing Unrecoverable error. Contact NI. Continuously lit The flash memory card is corrupt. Reformat the hard drive on the controller. Refer to MAX Help.
29. 6. 2012 32
Lekcia 2
KONFIGURCIA ZARIADENIA
29. 6. 2012
33
Konfigurcia zariadenia
Detect the Remote Target Configure Network Settings View Devices and Interfaces Add/Remove Software
29. 6. 2012
34
29. 6. 2012
35
29. 6. 2012
36
29. 6. 2012
37
38
29. 6. 2012
39
29. 6. 2012
40
29. 6. 2012
41
29. 6. 2012
42
29. 6. 2012
43
29. 6. 2012
44
D. Add/Remove Software
29. 6. 2012
45
D. Add/Remove Software
Default is to install minimal software necessary
Good for simple applications without
Network Variables Watchdogs PID Loops Modbus Communication
29. 6. 2012
46
D. Add/Remove Software
Custom software installation is for advanced applications
Uses more nonvolatile memory
Only install what is necessary to avoid wasting space
29. 6. 2012
47
D. Add/Remove Software
Verify proper installation settings
After proper configuration is set click Next to install
After install, reboot the RT Controller
29. 6. 2012
48
D. Add/Remove Software
Use FTP to display software on CompactRIO Can check Modified column to see last update
29. 6. 2012
49
Lekcia 3
ARCHITEKTRA APLIKCI
29. 6. 2012
50
Architektra aplikci
Create a Project Add the CompactRIO Target
29. 6. 2012
51
A. Create a Project
29. 6. 2012
52
A. Create a Project
Two programming modes available:
Scan Interface LabVIEW FPGA Interface
29. 6. 2012
53
29. 6. 2012
54
29. 6. 2012
55
29. 6. 2012
56
29. 6. 2012
57
A. Create a Project
Software architecture mirrors hardware architecture
29. 6. 2012
58
29. 6. 2012
59
29. 6. 2012
60
61
29. 6. 2012
62
I/O Modules
Change Properties of a Module Can configure
Alias in Project
29. 6. 2012
63
I/O Modules
Module-specific information in LabVIEW Help
29. 6. 2012
64
Categorized by module
Default Naming Convention
Scan Mode: ModX ChannelY FPGA Mode: ModX ModX/ChannelY
29. 6. 2012
65
Lekcia 4
29. 6. 2012
66
29. 6. 2012
67
29. 6. 2012
68
29. 6. 2012
69
Supported backplanes
Examples : 9103, 9104, 9073, 9074
29. 6. 2012
70
29. 6. 2012
72
73
29. 6. 2012
74
75
Right-click on the I/O variable and select either Change to Scanned or Change to Direct, depending on the current state of the variable
29. 6. 2012
76
29. 6. 2012
77
29. 6. 2012
78
79
Scan Engine Priority Priority of the NI Scan Engine thread on the Real-Time target
29. 6. 2012
80
29. 6. 2012
81
No programming required Settings are configured from the LabVIEW project, but run on the FPGA for accuracy and speed
29. 6. 2012
82
29. 6. 2012
83
29. 6. 2012
84
85
86
87
D. Programming with CompactRIO Scan Mode NI Scan Engine VIs (Installed with LabVIEW RealTime)
29. 6. 2012
Synchronize to Scan Engine Get Scan Engine Period Set Scan Engine Period Get Scan Engine Mode Set Scan Engine Mode Forcing Subpalette Faults Subpalette
88
Disable Variable Forcing Enable Variable Forcing Force Variable Unforce Variable Get Fault List Set Fault Clear Fault Clear all Faults
89
Faults VIs
29. 6. 2012
90
Lekcia 5
91
29. 6. 2012
92
A. Introduction
An FPGA is a chip that can be reconfigured with software. FPGAs are used in NI R Series DAQ, Compact Vision, and CompactRIO. An FPGA replaces millions of logic gates.
29. 6. 2012
93
A. Introduction
94
A. Introduction
Programmable interconnect switches and wires route signals in an FPGA. Switches are known as Register Flip-Flops. Flip-Flops pass data on a rising edge of the clock. Compiled LabVIEW code produces a Look-up Table (LUT) that defines outputs from all possible input values to a logic function. The LUT defines the interconnections between configurable logic blocks (CLBs).
29. 6. 2012
95
A. Introduction
Implements a VI that calculates a value for F from inputs A, B, C, and D where F= CD(A+B)
29. 6. 2012
96
B. Fixed-Point Math
Greatly simplifies arithmetic on the FPGA
Simplifies computations Size and speed advantages of integer math Must configure the appropriate range when using fixedpoint math
29. 6. 2012
97
B. Fixed-Point Math
Encoding, Word Length and Integer Word Length
Encoding Fixed Point numbers are either Signed () or Unsigned (+).
Word Length The total number of bits used for the FixedPoint data.
29. 6. 2012
Integer Word Length The number of bits used in the integer portion of the FixedPoint data.
98
B. Fixed-Point Math
Numeric Representation Examples
Representation U8 I8 FXP <+,8,7> FXP <+,8,6> FXP <,8,7> FXP <,8,6> delta 1 1 0.5 0.25 0.5 0.25 Min Value 0 -128 0 0 -64 -32 Max Value 255 127 127.5 63.75 63.5 31.75
29. 6. 2012
99
29. 6. 2012
100
101
B. Fixed-Point Math
Selecting an Overflow and Rounding Mode
Use same format for all related functions Mixing fixed-point configuration types can cause data loss
29. 6. 2012
102
FPGA Module Do not have to learn VHDL True parallel execution Deterministic
29. 6. 2012
103
104
A bitstream file results Bitstream loads at run time Bitstream reloads at power-up
On-board flash memory Controller over PCI Bus
29. 6. 2012
C o m p ile S e rv e r
105
Each fixed I/O uses a portion of the FPGA logic The PCI interface also uses a portion of the FPGA logic
29. 6. 2012
106
29. 6. 2012
107
Z=X+Y+M
29. 6. 2012
108
29. 6. 2012
109
29. 6. 2012
110
29. 6. 2012
111
29. 6. 2012
112
29. 6. 2012
113
29. 6. 2012
114
29. 6. 2012
115
FPGA I/O items connect I/O to the FPGA logic Each FPGA I/O item has a type like analog or digital FPGA VIs can have multiple types of I/O items
29. 6. 2012
116
29. 6. 2012
117
29. 6. 2012
118
29. 6. 2012
119
Right-click the I/O Node to show error terminals Error information is useful for debugging and validating data, but it uses space on the FPGA and can slow execution
29. 6. 2012
120
29. 6. 2012
121
Wait
Adds explicit delay Pulse length control
Tick Count
Returns current value of FPGA clock. Benchmark loop rates Create custom timers
29. 6. 2012 122
Second execution adds timer count to initial time and waits until count has elapsed
Subsequent iterations match desired timing synchronization.
29. 6. 2012
123
Size of Internal Counter 8, 16, or 32 bit = maximum time a timer can track. To save space on the FPGA, use the smallest Size of Internal Counter possible.
29. 6. 2012 124
29. 6. 2012
125
29. 6. 2012
126
127
Host VI
FPGA VI
29. 6. 2012
128
129
29. 6. 2012
130
29. 6. 2012
131
When testing is complete, set the FPGA Target to execute VI on the FPGA target.
29. 6. 2012
132
Front Panel displayed on Host PC Block Diagram executes on FPGA as compiled Communication layer shares all control and indicator values Cannot use debugging tools when running FPGA VI
Test with Emulator first, or add indicators as probes
29. 6. 2012
133
29. 6. 2012
134
Click the Run button Converts graphical code to VHDL Generates intermediate files
29. 6. 2012
135
Disconnect Disconnects from the Compile Server to continue working in LabVIEW Run the VI again to reconnect
29. 6. 2012
136
29. 6. 2012
137
29. 6. 2012
138
29. 6. 2012
139
29. 6. 2012
141
29. 6. 2012
142
29. 6. 2012
143
144
FPGA space requirements Minimum of two DMA channels needed System memory resources used CPU time scales with the scan period
145
Lekcia 6
REAL-TIME CONTROLLER
29. 6. 2012
146
Real-Time Controller
A. Introduction B. LabVIEW Real-Time Applications C. Development Course D. Deterministic Operating Systems E. Timing Methods
E. F.
E.
Developing an RT Host VI Rebooting the CompactRIO RT Controller Reusing Code in Multiple Targets
29. 6. 2012
147
A. Introduction
29. 6. 2012
148
A. Introduction
RT VI common tasks:
Data processing Perform operations not available on the FPGA target Log data Run multiple VIs Control the timing and sequencing of data transfer
29. 6. 2012
149
A. Introduction
150
A. Introduction
Common RT Configurations
29. 6. 2012
151
Event response TCP/IP communications Verifying timing and memory usage Execution Trace Tool Kit Deploying an application Remote panels RT Wizard
152
Deterministic: responds reliably to an event, or performs an operation, within a guaranteed time period.
29. 6. 2012
153
J it te r R a n g e
M a x im u m J itt e r
L o o p It e r a t io n
1 2 3 4 5 L o o p T im e ( s e c o n d s )
29. 6. 2012
154
Task 2
A fte r T a s k 1 fin is h e s , T a s k 2 c a n p r o c e e d .
Task 1
W a itin g
S h a re d R e s o u rc e
Task 2
R u n n in g
Examples: I/O, memory (variables and FIFOs), non-reentrant VIs FPGA does not need to share resources jitter can be as low as 250 picoseconds
29. 6. 2012
155
D. Timing Methods
Deterministic tasks can consume all processor resources. Use Wait (ms) and Wait Until Next ms Multiple VIs to pause deterministic loops and allow non-deterministic tasks to execute.
29. 6. 2012
156
D. Timing Methods
Wait VI Constant time of execution Execute A, Execute B, sleep 10 ms
Wait Until Next Multiple VI Variable time of execution Execute A, Execute B, sleep until OS timer reaches next multiple of 20 ms
29. 6. 2012
157
Period = 100 ms, Acquire = 50 ms, Loop idle = 50 ms LabVIEW executes lower priority tasks during idle time.
29. 6. 2012
158
E. Developing an RT Host VI
Add a VI under the cRIO target
29. 6. 2012
159
Must open a reference to the FPGA target before you can communicate between the host VI and the FPGA VI. Configure for Open or Open and Run
Use free label to describe functionality
29. 6. 2012 161
download abort run wait for and acknowledge interrupts, read DMA FIFOs write DMA FIFOs
162
E. Developing an RT Host VI
Read/Write Control
Reads a value from or writes a value to a control or indicator in the FPGA VI on the FPGA target.
29. 6. 2012
163
E. Developing an RT Host VI
Upcast
Converts an FPGA VI-specific reference to a more generic reference Enables using common code to interact with different FPGA VIs. The FPGA targets must be of the same class. You cannot use this function with DMA FIFOs
29. 6. 2012
164
E. Developing an RT Host VI
Close FPGA VI Reference
Stops and resets the FPGA Right-click and select Close from the shortcut menu to close the reference without resetting Default is Close and Reset, which closes the reference, stops the FPGA VI, and resets the FPGA Use free label to describe functionality
29. 6. 2012
165
E. Developing an RT Host VI
After developing the RT host VI, run it
Deploying Status Window:
29. 6. 2012
166
29. 6. 2012
168
29. 6. 2012
169
29. 6. 2012
170
Lekcia 7
WINDOWS PC HOST
29. 6. 2012
171
Windows PC Host
Overview Shared Variable Network Communications
29. 6. 2012
172
A. Overview
Interactive Front Panel Communication
Works between PC and RT controller, like it did between the PC and FPGA Is good for development and debugging Is not deterministic
29. 6. 2012
173
A. Overview
Use Network Communications for deterministic communication between PC and RT Controller Network communication allows you to
Run another VI on the host computer. Control the data exchanged
which front panel objects get updated and when which components are visible on the front panel
Control timing and sequencing of the data transfer Perform additional data processing or logging
29. 6. 2012
174
29. 6. 2012
175
29. 6. 2012
176
29. 6. 2012
177
29. 6. 2012
178
29. 6. 2012
179
Difficult to debug
Can return the same value 1000s of times Capable of returning a different value at any time
Lekcia 8
DATA TRANSFER
29. 6. 2012
181
A. Race Conditions
FPGA, RT and PC applications run asynchronously on their own. The FPGA can run at nanosecond loop times. The RT controller can run at microsecond loop times. The Windows PC can run at millisecond loop times. This presents problems for communicating data.
Data can be lost. Data can be read multiple times.
29. 6. 2012
182
A. Race Conditions
1. What will the value of the Race Sequence VI be after the first run? 2. After the second? 3. After the third?
29. 6. 2012
183
A. Race Conditions
A possible result
29. 6. 2012
184
A. Race Conditions
29. 6. 2012
185
A. Race Conditions
Avoid race conditions by:
Controlling shared resources Properly sequencing instructions Identifying and protecting critical sections within your code Reducing use of variables
Initialize shared variables. Otherwise, they retain values from previous executions or default values of associated front panel objects.
29. 6. 2012
186
A. Race Conditions
Parallel loops: Write Loop running at the same rate as the Read Loop
29. 6. 2012
187
A. Race Conditions
Parallel loops: Write loop running slower than Read Loop (Underflow)
29. 6. 2012
188
A. Race Conditions
Parallel loops: Write loop running faster than Read Loop (Overflow)
29. 6. 2012
189
Buffer An area of computer memory where multiple data items are stored.
Synchronization Tasks occur at the same time or in unison using clock, triggers, or events.
29. 6. 2012
190
29. 6. 2012
191
C. FPGA FIFOs
FIFO First-in first-out buffer. The first data item written to memory is the first item read and removed from memory.
VI-Scoped A single FIFO transfers data between multiple loops in the same VI. Target-Scoped A single FIFO transfers data between loops on multiple VIs running on the same target. DMA A single FIFO transfers data to and from RT VIs by directly accessing memory.
29. 6. 2012
192
C. FPGA FIFOs
Create Target-Scoped or DMA FIFOs from the Project Explorer window
29. 6. 2012
193
C. FPGA FIFOs
Configure
29. 6. 2012
194
C. FPGA FIFOs
Type
Select Target-Scoped from the Type pull-down menu in the Properties Dialog if you want to use a targetscoped FIFO. Select Host to Target-DMA or Target to Host-DMA from the Type pull-down menu if you want to use a DMA FIFO.
29. 6. 2012
195
C. FPGA FIFOs
Implementation (disabled for DMA FIFOs)
Flip-Flops Use gates on the FPGA to provide the fastest performance. Recommended only for very small FIFOs < 100 bytes. Look-up Tables Store data in look-up tables available on the FPGA (2 per slice). Recommended only for small FIFOs < 300 bytes.
Allocate the FIFO in user (block) memory to preserve FPGA space for your VI.
80 kB on a 1M gate FPGA 192 kB on a 3M gate FPGA
29. 6. 2012
196
C. FPGA FIFOs
Number of Elements
Number of elements FIFO can hold Maximum depends on the Implementation that has been selected and the amount of space available on the FPGA for the implementation
29. 6. 2012
197
C. FPGA FIFOs
Create a VI-Scoped FIFO from the Functions palette
29. 6. 2012
198
C. FPGA FIFOs
Put data into the FIFO with the FIFO Write function Retrieve data with the FIFO Read function
29. 6. 2012
199
C. FPGA FIFOs
Place an FPGA FIFO Write or Read from the Functions palette Right-click the object and choose Select FIFO
Associates node with a defined FIFO
29. 6. 2012
200
C. FPGA FIFOs
FPGA FIFO Write Terminals
Element Inputs the data element to store Timeout Sets number of ticks the function waits for space if the FIFO is full. 0 (default) = no wait, 1 prevents timeout. Timed Out? Is True if FIFO is not available. Does not overwrite. Does not add new element. Can be lossy
29. 6. 2012
201
C. FPGA FIFOs
Resetting a FIFO
FIFOs reset when the VI stops and restarts using the development machine To reset programmatically:
Use the Invoke Method function Or Use the Close FPGA VI function configured to Close and Reset
29. 6. 2012
202
C. FPGA FIFOs
VI scoped FIFO with Programmatic Front Panel Communication:
1. I/O writes to FIFO and notifies host 2. Transfer loop reads FIFO and passes data to host using Front Panel Communication 3. Host acknowledges transfer and transfer loop sends another data value RT Host FPG A
A c q u is itio n
F P G A F IF O
F P G A F IF O R T H ost VI In d ic a to r
D a ta F lo w
N o tifie r
29. 6. 2012
203
C. FPGA FIFOs
Separate I/O and data transfer to speed I/O
Top loop acquires data. Transfer loop reads FIFO and passes data to host using Front Panel Communication.
29. 6. 2012
204
C. FPGA FIFOs
Clear Method
Use the Clear Method to empty a target- or VI-scoped FIFO
Or call Reset VI method from host.
29. 6. 2012
205
D. Handshaking
Handshaking Checking that a receiving device is ready to receive or a transmitting device is ready to transmit
Host uses Boolean controls and indicators (data available and data read flags) on the target to coordinate operations Requires polling
29. 6. 2012
206
D. Handshaking
1. FPGA acquires data and writes True to Data Available? 2. When Data Available? is True, host reads data. 3. After data is read, host writes True to Data Received. 4. FPGA loop iterates when Data Received is True.
29. 6. 2012
207
E. Interrupts
Communicate over a physical hardware line.
FPGA Interrupts send a trigger to the host. Eliminate polling. Allow host to perform other operations while waiting for the Interrupt signal.
29. 6. 2012
208
E. Interrupts
29. 6. 2012
209
E. Interrupts
IRQ Number specifies which logical interrupt (0 31) to assert. The default is 0. Wait Until Cleared specifies if this VI waits until the host VI acknowledges the logical interrupt. The default is FALSE.
29. 6. 2012
210
E. Interrupts
RT Host and Interrupts
RT host must acknowledge interrupts. Use Wait on IRQ and Acknowledge IRQ methods.
IRQ Number(s) specifies the logical interrupt for which the function waits. Timeout (ms) specifies the number of milliseconds the VI waits before timing out. 1 = infinite timeout. Timed Out returns TRUE if this method has timed out. IRQ(s) Asserted returns the asserted interrupts. Empty or 1 array indicates that no interrupts were received.
29. 6. 2012
211
E. Interrupts
29. 6. 2012
212
E. Interrupts
Interrupt implementation.
29. 6. 2012
213
214
29. 6. 2012
215
29. 6. 2012
216
29. 6. 2012
217
29. 6. 2012
218
29. 6. 2012
219
29. 6. 2012
220
29. 6. 2012
221
29. 6. 2012
222
223
Read a DMA FIFO in the host: 1. Open a reference to the FPGA. 2. Add an Invoke Method function. 3. Choose the Data Read Method.
29. 6. 2012
224
Timeout length of time to wait before timeout. Default is 5,000 ms. 1 = indefinite wait. Data returns data read Elements Remaining indicates elements remaining in the host part of the DMA FIFO
29. 6. 2012
225
226
29. 6. 2012
227
29. 6. 2012
228
29. 6. 2012
229
29. 6. 2012
230
29. 6. 2012
231
29. 6. 2012
232
Show how an overflow of the DMA FIFO can occur if the RT host VI code is too complex
29. 6. 2012
233
29. 6. 2012
234
29. 6. 2012
235
29. 6. 2012
236
29. 6. 2012
237
29. 6. 2012
238
29. 6. 2012
239
29. 6. 2012
240
29. 6. 2012
241
29. 6. 2012
242
29. 6. 2012
243
Optimization Techniques Benchmarking FPGA VIs Basic Optimizations Architectural Optimizations Advanced Optimizations
DODATOK
FPGA OPTIMALIZCIA
29. 6. 2012
244
A. Optimization Techniques
FPGA VIs are limited primarily in two areas: Speed
Execution rate too slow for specifications
Size
Requires too much space on the FPGA Uses so much RAM that it will not compile
29. 6. 2012
245
A. Optimization Techniques
Some techniques sacrifice speed for size and vice versa Can use multiple techniques in one VI
FPGA Optimization Technique Limit Font Panel Objects Use Small Data Types
Speed
Size X X
X
X X
X
X
Use Pipelining
Use Single-Cycle Timed Loops
X
X X
29. 6. 2012
246
29. 6. 2012
247
248
249
29. 6. 2012
251
C. Basic Optimizations
These types of optimizations are relatively easy to implement
Require no major changes in code architecture Should be basic programming practice for all FPGA VIs Basic Optimizations primarily affect FPGA size
29. 6. 2012
252
C. Basic Optimizations
Types of Basic Optimizations:
Limit Front Panel Objects Bitpack Boolean Logic Use Small Data Types Avoid Large Functions Optimize Comparisons Reentrant vs. Non-Reentrant SubVIs
29. 6. 2012
253
C. Basic Optimizations
Limit Front Panel Objects Each Front Panel Object on the Top-Level VI must have logic to interact with the host VI. Each read and write from the host to the FPGA is broken down into 32-bit packets to transfer across the bus.
29. 6. 2012
254
C. Basic Optimizations
Limit Front Panel Objects Avoid using Arrays on the Front Panel
Compile fails if more bytes in array than are available in RAM
Device 1M Gate FPGA 3M Gate FPGA RAM 81,920 196,608
255
C. Basic Optimizations
Limit Front Panel Objects Avoid using Arrays on the Front Panel
Can quickly use large amounts of FPGA size
Each bit in the array uses its own flip-flop on the FPGA
29. 6. 2012
256
C. Basic Optimizations
Limit Front Panel Objects
Replace Large Front Panel Array Controls with LookUp Table VI.
Provides a general-purpose block of initialized memory. Use look-up tables to store waveforms for
Signal generation Model nonlinear systems Arithmetic computations.
29. 6. 2012
257
C. Basic Optimizations
Bitpack Boolean Logic Display data in integer as binary data
U8 Numeric Control can replace eight Boolean Controls Maintains same information using 1/8th as many controls Use functions to still manipulate data in same manner
29. 6. 2012
258
C. Basic Optimizations
Use Small Data Types
29. 6. 2012
259
C. Basic Optimizations
Use Small Data Types Eliminate coercion dots
Determine necessary input format Insert conversion function Intentional coercion creates a more efficient compile
29. 6. 2012
260
C. Basic Optimizations
Avoid Large Functions Not all functions are equal
Quotient Remainder Scale By Power of 2 (free if use constant for power) Array Functions (should use constants where possible)
29. 6. 2012
261
C. Basic Optimizations
Optimize Comparisons Often comparisons can be replaced with lower level functions.
Refactor the code with simplified comparisons
29. 6. 2012
262
C. Basic Optimizations
Optimize Comparisons Can replace comparison functions with bit logic
Easiest to compare power of 2 Must restructure code to change comparison value
Same result, but uses half the FPGA resources and executes almost twice as fast
29. 6. 2012
263
Reentrant
29. 6. 2012
264
C. Basic Optimizations
Reentrant vs. Non-Reentrant SubVIs By default, VIs created under an FPGA target are reentrant.
To make a subVI non-reentrant change VI Properties Multiple copies of reentrant VIs allow for quick creation of similar code
29. 6. 2012
265
D. Architecture Optimizations
Dataflow within the FPGA
Parallel Operations Pipelining Single Cycle Timed Loops Combining Optimizations
29. 6. 2012
266
D. Architecture Optimizations
Dataflow within the FPGA
Each function or VI takes a minimum of 1 clock tick Functions can run in parallel Some dependent functions must run in sequence Application can only run as quickly as the sum of items in a sequence. While Loops have a 2 clock tick overhead
If prior slide was in a loop
Required 3 clock ticks, plus 2 clock ticks for loop Max Rate = 40 MHz / 5 = 8 MHz
29. 6. 2012
267
D. Architecture Optimizations
Parallel Operations Graphical programming promotes parallel code architectures LabVIEW Windows and Real-Time serialize execution LabVIEW FPGA implements truly parallel execution
29. 6. 2012
268
D. Architecture Optimizations
Parallel Operations Two parallel loops with different sampling rates
Run in parallel because there are no shared resources between the two loops.
29. 6. 2012
269
D. Architecture Optimizations
Parallel Operations Loop rates limited by longest path
A0 takes about 35 ticks, DI takes 1 tick (HW Specific) DI limited by AO when in same loop
38 Ticks ~ 1uSec
29. 6. 2012
270
D. Architecture Optimizations
Parallel Operations Loop rates limited by longest path
A0 takes about 35 ticks, DI takes 1 tick (HW Specific) Separate functions to allow DI to run independent of AO This allows DI to be sampled 10 times faster by using a separate loop
4 Ticks ~ .1 uSec
38 Ticks ~ 1uSec
29. 6. 2012
271
D. Architecture Optimizations
Pipelining Within a loop you can split up your code into different loop iterations to reduce the duration of each iteration
Handle different parts of the process flow in parallel within one loop iteration Pass data to next piece of code using shift registers
29. 6. 2012
272
Pipelining
Can maintain look and feel of original application by using Feedback Nodes
Same functionality as a Shift Register Maintains more congruous VI appearance
29. 6. 2012
273
D. Architecture Optimizations
Pipelining is a technique you can use to increase the throughput or speed of the FPGA VI.
Takes advantage of the parallel processing capabilities of the FPGA
By using parallel processing increases the efficiency of sequential code
29. 6. 2012
274
Pipelining
Pipelining Drawbacks
Require code to be restructured
Greatly reduced by using Feedback Nodes
29. 6. 2012
275
Pipelining
Basic Example
Simple set of code with inputs and outputs Takes 7 clock cycles to execute
5 cycles for the code, 2 for the loop
29. 6. 2012
276
Pipelining
Basic Example
Pass data to next step of code by using shift registers Takes 5 clock cycles to execute
3 cycles for the code, 2 for the loop
29. 6. 2012
277
Pipelining
Basic Example Can maintain look and feel of original application by using Feedback Nodes in sequence with code
Same functionality as a Shift Register Maintains more congruous VI appearance
29. 6. 2012
278
Pipelining
29. 6. 2012
279
D. Architecture Optimizations
Pipelining What to do if your diagram executes too slowly? 12 clock cycles
1 2 3 4 5 6 7 8 9 10 11 12
FFs FFs
FFs FFs
29. 6. 2012
280
D. Architecture Optimizations
Pipelining Shorten the longest path 9 clock cycles
1 2 3 4 5 6 7 8 9
FFs
FFs
281
D. Architecture Optimizations
Pipelining Watch out for pipeline effects including increased latency 6 clock cycles
1 2 3 4 5 6
FFs
FFs
FFs
282
29. 6. 2012
283
D. Architecture Optimizations
Single Cycle Timed Loop (SCTL) Can use a Single-Cycle Timed Loop to turn this 12 clockcycle While Loop
29. 6. 2012
284
29. 6. 2012
285
8%
29. 6. 2012
287
29. 6. 2012
288