Professional Documents
Culture Documents
Workshop Goals
Gain familiarity with FPGA devices Gain familiarity with HDL design methods Implement basic designs in hardware
Aug 9, 2001
Agenda
FPGA Overview Verilog Overview Combinational Circuits 8:30 - 9:15 9:15 - 10:00 10:15 - 11:00
Lab Projects I
Sequential Circuits
11:00 - 12:00
1:15 - 2:00
Lab Projects II
Lab Projects III
Aug 9, 2001
2:00 - 3:00
3:15 - 4:00
FPGA System Design with Verilog 3
FPGA Overview
Aug 9, 2001
What is an FPGA?
Field Programmable Gate Array Blank slate for your digital hardware system
Aug 9, 2001
FPGA in Context
Microprocessor/microcontroller Executes a program Fixed hardware and interconnections Full-custom IC Design at the transistor level
Aug 9, 2001
FPGA in Context
Semicustom IC Standard cell (CBIC, ASIC) Masked gate array (MGA) Programmable logic device (PLD) PLD Complex PLD (CPLD) FPGA
Aug 9, 2001
FPGA Pictures
Board Packages Wafer Die photos FPGA Pentium II microprocessor
Aug 9, 2001
Internal Architecture
Array of Configurable Logic Blocks (CLBs) User-defined (SRAM-based) interconnect between CLBs Dedicated resources Power distribution Clock distribution Programmable I/O blocks (IOBs)
Aug 9, 2001
11
Aug 9, 2001
12
PLD Vendors
Total 1999 PLD Market = $2.6B
Other 9% Actel 7% Lattice 16% Xilinx 35%
Altera 33%
Source: Xilinx University Program Workshop Notes
Aug 9, 2001
13
Aug 9, 2001
14
Aug 9, 2001
15
Atmel FPSLIC (Field Programmable System-Level Integrated Circuit) 5K to 40K system FPGA gates 8-bit AVR RISC microprocessor core Microcontroller peripherals 36K program and data RAM
Aug 9, 2001
17
CPLD Nonvolatile (ROM- or EEPROM-based) Predictable delays (no routing) Register poor (relatively few FFs) Low-to-medium density For simple, fast logic with many inputs Specialized decoders, combinational circuits, counters
FPGA System Design with Verilog 18
Aug 9, 2001
FPGA Volatile (SRAM-based) Configuration must be stored externally (serial EEPROM) Permits field upgrades, reconfigurable computing Variable routing delays Register rich (relatively many FFs) For arbitrary digital systems, system-on-chip (SoC), medium-to-high density
FPGA System Design with Verilog 19
Aug 9, 2001
Verilog Overview
Aug 9, 2001
20
Verilog Gateway Design Automation (1983; proprietary) Acquired by Cadence 1989 IEEE standard in 1995 Similar to C
VHDL Origins in DoD VHSIC program (1980s) IEEE standard in 1987 Similar to ADA
Aug 9, 2001
21
Aug 9, 2001
22
What is HDL?
HDL = Hardware Description Language A text-based method for describing hardware to a synthesis tool
Aug 9, 2001
23
Aug 9, 2001
24
Text
HDL Sim Hardware Synthesis
Implement
Netlist
Implement
Aug 9, 2001
25
Aug 9, 2001
26
Aug 9, 2001
27
FPGA
ASIC
Aug 9, 2001
28
Aug 9, 2001
29
HDL is not a programming language (HDL is a description language) HDL is not highly abstract, e.g., implement the DSP algorithm y(n) = 0.75y(n-1) + 0.3x(n) (HDL is at the RTL level (register transfer))
FPGA System Design with Verilog 30
Aug 9, 2001
Synthesizable Subset
Verilog (and VHDL) began life as simulation and modeling tools Hardware synthesis developed during the 1990s Need to use a subset of Verilog and specific coding styles to allow synthesis tool to infer correct (and realizable) hardware
Synthesizable Subset
Use this to write testbenches for behavioral simulation Verilog
A Gradual Introduction
New concepts in boldface Verilog keywords in italic Refer to your handout...
Aug 9, 2001
35
Do Nothing Circuit
module Gadget; endmodule
Aug 9, 2001
36
Aug 9, 2001
37
Bitwise Operators
~ & | ^ NOT AND OR EXOR
Aug 9, 2001
39
Two Gates
module Gadget (a,b,c,d); // Port modes input a,b; output c; output d; // Registered identifiers reg c,d; // Functionality always @ (a or b) begin c <= ~(a & b); d <= a ^ b; end endmodule
Aug 9, 2001
41
Two-Input MUX
module Mux2 ( A, B, Sel, Y ); // // // // A input B input Selector Output
// Port modes input A,B,Sel; output Y; // Registered identifiers reg Y; // Functionality always @ (A or B or Sel) if (Sel==0) Y <= A; else Y <= B; endmodule Aug 9, 2001 FPGA System Design with Verilog 42
Relational Operators
== != < > <= >= && ||
Aug 9, 2001
Equal to Not equal Less than Greater than Less than or equal Greater than or equal AND OR
FPGA System Design with Verilog 43
More Operators
>> << + * / %
Aug 9, 2001
Shift right Shift left Add Subtract Multiply Not likely to synthesize! Divide Modulus
FPGA System Design with Verilog 44
MUX Again...
// Functionality always @ (A or B or Sel) if (Sel) Y <= B; else Y <= A;
Aug 9, 2001
45
Aug 9, 2001
46
4-Input MUX
module Mux4 ( Data, Sel, Y ); // Data input // Selector // Output
Aug 9, 2001
47
Custom MUX
module Mux16 ( Data, Sel, Y ); // Data input // Selector // Output
// Port modes input [15:0] Data; input [3:0] Sel; output Y; // Registered identifiers reg Y; // Functionality always @ (Data or Sel) casez (Sel) 4b0000: Y <= Data[0]; 4b0001: Y <= Data[1]; 4b01??: Y <= Data[2]; default: Y <= Data[3]; endcase Aug 9, 2001 endmodule FPGA System Design with Verilog 49
Aug 9, 2001
50
Miscellaneous Techniques
{a,b}
{Data[13:12],a,b,Data[11:0]}
{16{a}}
assign Y = (en) ? X : 1bz;
Aug 9, 2001 FPGA System Design with Verilog 51
Parameterized Design
module Compare4 ( A, // Data B, // Data AltB, // A is AeqB, // A is AgtB // A is ); input A input B less than B equal to B > than B
// Define bus width parameter BusWidth = 8; // Port modes input [BusWidth-1:0] A,B; ... ...
Aug 9, 2001 FPGA System Design with Verilog 53
Aug 9, 2001
54
Lab Projects I
Aug 9, 2001
55
Aug 9, 2001
56
Aug 9, 2001
57
A Gradual Introduction
New concepts in boldface Verilog keywords in italics Refer to your handout...
Aug 9, 2001
59
D Flip-Flop
module D_FF (D,Clock,Q); /* Port modes */ input D,Clock; output Q; // Registered identifiers reg Q; // Functionality always @ (posedge Clock) Q <= D; endmodule
Aug 9, 2001 FPGA System Design with Verilog 60
endmodule
Aug 9, 2001 FPGA System Design with Verilog 61
Aug 9, 2001
63
endmodule
Aug 9, 2001 FPGA System Design with Verilog 64
A Brief Sermon...
NOTE: Avoid the temptation to design arbitrary flip-flop behavior, e.g., ability to trigger on both edges of the clock, ability to trigger on multiple clock signals, etc. The hardware synthesis tool does not magically create new hardware from thin air! You have to write circuit descriptions that are realizable, that is, can be mapped onto existing (known) hardware elements such as standard D flip-flops. Bottom line: Use the constructs listed above exactly as shown... dont invent your own!!
Aug 9, 2001 FPGA System Design with Verilog 66
Data Register
module Reg16 (D,Clock,Q,Reset); /* Port modes */ input [15:0] D; input Clock,Reset; output [15:0] Q; // Registered identifiers reg [15:0] Q; // Functionality always @ (posedge Clock or posedge Reset) if (Reset == 1) Q <= 0; else Q <= D; endmodule
Aug 9, 2001 FPGA System Design with Verilog 67
endmodule
Aug 9, 2001 FPGA System Design with Verilog 68
Aug 9, 2001
69
Down Counter
module CountDown (Clock,Reset,Enable,Init,Q); // Port modes input Clock,Reset,Enable,Init; output [7:0] Q; // Registered identifiers reg [7:0] Q; // Functionality always @ (posedge Clock or posedge Reset) if (Reset == 1) Q <= 0; else if (Init) Q <= 8hFF; else if (Enable) Q <= Q 1;
endmodule
Aug 9, 2001 FPGA System Design with Verilog 70
Aug 9, 2001
71
Clock Divider
parameter MaxCount = 12; always @ (posedge Clock or posedge Reset) if (Reset) begin ClockDiv <= 0; SlowClock <= 0; end else if (ClockDiv == MaxCount) begin SlowClock <= 1; ClockDiv <= 0; end else begin SlowClock <= 0; ClockDiv <= ClockDiv+1; end
Aug 9, 2001 FPGA System Design with Verilog 72
Design Rules
Generally speaking, follow good design practice for digital systems, e.g., avoid gated clocks In particular, strive to write descriptions that make all flip-flop clocks connect to the master clock Use asynchronous reset on all flip-flops
Use a systematic naming convention for identifiers: i$Identifier Module input o$Identifier Module output r$Identifier Registered p$Identifier Parameter w$Identifier Wire
FPGA System Design with Verilog 74
Aug 9, 2001
Finite State Machines One-hot encoding casez (efficient next-state decoder) Data path / controller architecture Detailed design rules for FPGAs Timing and performance tuning Instantiation, multi-module systems Testbench design
FPGA System Design with Verilog 75
Aug 9, 2001
References
http://www.rosehulman.edu/~doering/fpga_workshop/refere nces.htm
Aug 9, 2001
76
Lab Projects II
Aug 9, 2001
77
Development Procedure
Introduction to the XS-40 board Review the step-by-step development procedure
Aug 9, 2001
78
A
(use Pin 44)
B SimpleSystem C
B = A, C = ~A
Aug 9, 2001
79
Aug 9, 2001
80