Beruflich Dokumente
Kultur Dokumente
Cache
UART
CPU
Debug GPIO
On-Chip Timer
ROM
SPI
On-Chip SDRAM
RAM Controller
FPGA
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
4
Problem: Reduce Cost, Complexity & Power
I/O Flash
CPU
SDRAM
I/O
I/O I/O I/O
DSP
I/O FPGA
CPU DSP
Solution:
Solution: Replace External Devices
with Programmable Logic
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
5
Problem: On
System Reduce Cost, ComplexityChip
A Programmable & Power
(SOPC)
Flash
FPGA
SDRAM
10/100 Ethernet
MAC/PHY &
RJ-45 Connector
CPU Reset Expansion
Prototype
8 MB Flash Connectors
(40 I/O pins each)
16 MB SDRAM
FPGA
1MB SRAM
Nios II Processor
Compact
Level Shifter
Address (32) Tri-State Tri-State SDRAM
Flash
Bridge Bridge Controller
Read PIOs
32-Bit
Write
Nios II UART
Processor Data In (32)
General
Data Out (32) Internal Periodic
Purpose JTAG_UART
RAM/ROM Timer
Timer
Reconfig PIO
IRQ
IRQ #(6) 7-Segment
LED PIO LCD PIO Button PIO
PLL LED PIO
Expansion 4
2 Digit
On-Chip Off-Chip 8 LEDs Header Momentary
Display
J12 buttons
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
12
Typical System Architecture
Address Avalon-MM UART 0
Instr. Decoder Master/ UART n
Nios II Slave
CPU Data Interrupt Port
Timer 0
Controller Interfaces Timer n
Instruction and
clock Program Purpose Port
Data Trace
Controller Registers Instruction
JTAG interface Hardware- & Cache
to Software Assisted Address
Debugger Debug Module Generation Status &
Control
Registers Tightly
High Speed Trace Coupled
Connection Trace port I-Memory
Memory
to Trace Pod
Breakpoints
MMU*
Exception Tightly
HW
Controller Coupled
D-Memory
Interrupt MPU *
irq[31..0] Controller Data
Master
Port
Data
Custom Cache
Custom Instruction Arithmetic
I/O Signals Logic Logic Unit
Software
Code is Binary Compatible
No Changes Required When CPU is Changed
None 250
Standard
MUL in Stratix 3
FPGA
Fast
MUL in Stratix 1
FPGA
250 3000
Performance (DMIPS*)
Component
Connection
Panel
Master
Control System Interconnect Fabric
Plane
Slave
FIR
FIR
FIR
Data
FIR
Path
FIR
FIR
FIR
Sink Source
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
28
Insert Peripherals Including Nios II Processor
Double-click on peripheral or press Add
Build up memory map of your embedded system
Eg.
SDRAM
0x000800000
Re-organized to help
Other
you easily find
components to add to Peripherals 0x000400000
your system
Flash
0x0
Memories
must be
defined in
order to
select reset
2009 Altera CorporationConfidential
or exception
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation address
31
Reset and Exception Addresses
Set after memory component added to system
Reset should be in non-volatile memory
In systems not connected to Quartus II Programmer
Exceptions processed at exception location
Exception handler code provided by HAL system library
Supported Exception Types
Software Exceptions
Software Traps (currently, not implemented)
Unimplemented instructions
Maintains compatibility between Nios II processor cores
Hardware Interrupts
32 Level-sensitive interrupts are supported.
More exceptions will be supported as features are added
Performance Enhancement!
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
34
Tightly Coupled Masters
Connected to tightly-coupled slaves through
Tightly Coupled Memory Interfaces
To on-chip true dual port memories, allowing Normal data master to
connect to second port, allowing reading and writing of data
Slave
32
Slave
Tightly Coupled Memory Interface
I-Cache D-Cache
Tri-state-
Nios II bus (or
Processor busses)
System
JTAG
sysid PLL Clock SSRAM
UART Timer
SOPC Builder
Logic
// Signal Declarations
..
.
All other
Simulation Quartus II
ModelSim project and SOPC
Builder
Automatically generated output files
test memory and vectors
connect Fabric
System Inter-
Off Chip
Tri-State
Bridge
Nios II Peripheral
Processor
FPGA
Note:
Avoid placing reset or
exception address at
0x0 due to self-check
performed by High
Performance memory
controller on first 32
bytes of memory at
boot-up time use
offset of 0x20 instead
Tightly
Coupled Tri-state-
Nios II bus (or
On-Chip
Processor Memory busses)
System JTAG
High Res Output
PLL sysid Clock UART Input PIO Flash SRAM
Timer PIOs
Timer
GNU Tools
2009 Altera CorporationConfidential Nios II C2H Compiler
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
69
Nios II IDE (Integrated Development Environment)*
File Viewer
Window
(for C code,
C++, and
List of assembly*)
Open
Projects
Outline View
(view and/or
open funcs,
enums, classes,
unions, structs,
typedefs, etc.)
Terminal
window
Application Project
- contains application
source code
Set properties for the System Library Project (Including, partitioning the memory map)
drag file/s
Key Files
system.h
Contains all symbolic
C-language definitions
for the peripherals in
your hardware system,
plus more
System ID peripheral
error messages
Basic Debug
Run Controls
Stack View
Active Debug
Sessions
Double-click to
add breakpoints
Memory View
Variables
Registers
Signals
Step Return
Step Over
Step Into
Disconnect
Terminate
Suspend
Resume
Restart
Middleware Support
Protocol stacks, file systems, graphics libraries, etc.
Compilers
http://www.altera.com/products/ip/processors/nios2/tools/ide/ni2-ide.html
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
96
Board Bring-Up Tools
Provides Interactive
Tcl command shell
To Launch, type:
system-console --cli
Recommendation:
Run scripts from here, not System
Console because you can CTRL-C
them easily if they should hang
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
99
Provides Host Target Communications
Access to FPGA design at runtime
Via Nios II Processor, JTAG Bridge, or PLI (with Modelsim)
Supports an Avalon-MM or ST Master from a host PC
Board bring-up utilities for debug, diagnostics, and configuration
Based on Host-Target communications architecture
Physical transport mechanism independent\
system-console script=turnon_LEDS.tcl
Initialization files
for simulation
ModelSim Tcl Scripts
Eg. setup_sim.do
ModelSim project
(.mpf file)
Nios II Processor
Compact
User Device
Data Out (32) On Chip On Chip Custom
ROM) RAM Instruction
UART
IRQ
User User
IRQ #(6) Defined Defined
Peripheral Interface
User Included
Clock Reset User Device
Peripheral
Not Included
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
107
Simulation Testbench
Time Saver!
Eg:
VSIM> run 100 ns
List
Window
Objects
Pane Wave Window
Main Active
Window Process
Pane
Plus more
Accelerates simulation
Text is transmitted to
JTAG_UART peripheral during
simulation
Creates and saves txt file
containing UART tx stream
Creates window to input text at
simulation run time
Basics
Trade-Off
Hardware Resource Usage Increases Uses Fairness
Arbitration
Generated (discussed later)
automatically by
SOPC Builder
Arbiter
Shared Bus
I/O
Slaves Slave 1 1 Slave 2 Slave 3 Slave 4
System
Interconnect
Fabric
Avalon-MM Master
Avalon-MM Slave
Transfer Properties
Wait States
Latency
Bursting
Flow Control
SIF
A B C D E
clk
readn
chipselect
readdata readdata
SIF
0 Hold Cycles
A B C D
clk
writedata writedata
writen
chipselect
SIF
1 Hold Cycle
A B C D E F G
clk
writen
chipselect
You are now going learn how to connect your own design
directly to the system through the System Interconnect Fabric
Note: As many peripherals contain registers, you could also have
chosen to use a PIO rather than connect directly to the bus
periph Board
Nios II Component
CPU periph
periph
SIF
periph
Custom
On-Chip
User
HDL User
Peripheral
Concentrate Effort on
Peripheral Functionality!
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
141
Example Registered Avalon-MM Slave
writedata
chipselect
readdata
address
write_n
reset_n
clk
export
module my_peripheral ( clk, wr_data, cs, wr_n, addr, clr_n, rd_data, pwm_out );
input clk, cs, wr_n, addr, clr_n;
input [31:0] wr_data;
output [31:0] rd_data; Conduit
output [7:0] pwm_out;
. (exported outside of
. Peripherals Ports
SOPC Builder system)
. (mapped to system Interconnect)
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
143
Component Editor
Three Uses:
1. Create top level ports
to connect S.I.F. to a
peripheral living
outside SOPC System
(on or off-chip)
Uses Quartus II
software to
analyze design
Exported Signals:
Must be of type conduit
and have associated clock
Clock Inputs
Must be defined as an interface
type and feed all clocked interfaces
Avalon Slaves
Must also have associated clock
Can adjust timing parameters
Avalon-MM Master
Avalon-MM Slave
input clk;
input [31:0] wr_data;
input cs;
input wr_n;
.
.
.
Pass Parameters
.
to Peripheral via Wizard:
Pass Parameters
.
to Peripheral via Wizard:
Tcl file can be edited in future (as can HDL code) when
component must be changed
Delete Tcl file to remove Custom Component from pick-list
C2H
CPU Accelerator
Arbiter Arbiter
Application Examples
Data Stream Processing (eg. Network Applications)
Application Specific Processing (eg. MP3 Audio Decode)
Software Inner Loop Optimization
Add a custom
instruction from
built-in library
a_swap = ALT_CI_BSWAP(a);
return 0;
}
Two Examples:
custom 0, r6, r7, r8
custom 3, c1, r2, c4 r = Nios II processor
register
c = Custom instruction
internal register
Significantly Faster!
Typical Flow
Profile Code
Identify Critical Inner Loop
Create Custom Instruction Logic
Replace One or All Instructions in Inner Loop
Import Custom Instruction Logic into Design
Call Custom Instruction from C or Assembly
Increased latency
32 (26 in version 6.0)
C:\altera\<ver>\nios2eds\examples\verilog\custom_instruction_template\
C:\ altera\<ver>\nios2eds\examples\VHDL\custom_instruction_template\
module custom_instruction(
dataa, // Operand A (always required)
datab, // Operand B (optional)
result // result (always required)
);
// INPUTS
input [31:0] dataa;
input [31:0] datab;
// OUTPUTS
output [31:0] result;
// Custom instruction logic (note: no external
// interfaces are allowed in combinatorial logic)
.
.
.
endmodule
0x408
Result
DataB
0x404
DataA
0x400
L0 Custom
L1 Peripheral L0
xor/shift
xor/shift
xor/shift
reg
0x500000
Address
0x400000
SRAM
0x300000 User
Software
0x200000
0x100000
0x000000
2009 Altera CorporationConfidential
Altera, Stratix, Arria, Cyclone, MAX, HardCopy, Nios, Quartus, and MegaCore are trademarks of Altera Corporation
185
Hardware Configuration Process
8 MB Flash
Flash Configuration Data
Safe FPGA
Two FPGA images Image
Safe Image
0x700000 FPGA
User FPGA
User Image Image
0x600000
Address
MAX
MAX EPM7128 Configures FPGA from Flash
Upon power up or press of Reset Config
MAX Device Loads User Image into FPGA
If This Fails MAX Device Loads Safe Image
Failure includes no user image present
Upon press of Safe Config
MAX Device Loads Safe Image into FPGA
Address
Copier to Program Code
if Reset Address is in Flash and
Program Memory is in RAM SRAM
8 MB Flash
Boot Copier
my_sw.flash
my_sw.elf
New Eclipse
Buttons and
filter text
Additional args
e.g. --instance=1
Image/Memory/
Offset Selection
(allows customization)
Validate SYSID
0x
Daughter Cards
Microtronix: VGA / PS2
SLS: USB 2.0
El Camino GmbH: RF A/D D/A
EasyFPGA: USB 2.0
t A dd
Jus it y!
ec t ric
El Its all in the box!
Refer to www.altera.com: