Verilog 2012
Verilog 2012
Verilog 2012
REF: Verilog Training Manual, CIC, July, 2008 Reuse Methodology Manual For System-ON-A-Chip Design, Third Edition 2002 Logic Synthesis with Design Complier, CIC , July, 2008
Speaker: Y. X. Chen
Advanced Reliable Systems (ARES) Lab.
Nov. 2012
1
11/21
: Synthesizable Verilog & Coding
Synthesizable coding style in Verilog Syntax check with nLint
Outline
Basic of Logic Synthesis Concept Basic Concept of Verilog HDL Synthesizable Verilog LAB 1-1: Design Rule Check with nLint Tips for Verilog Design LAB 1-2: RTL Simulation
RTL Level
Verilog/ VHDL
NC-Verilog/ ModelSim Debussy (Verdi)/ VCS Physical Compiler/ Magma Blast Fusion Design/ Power Compiler DFT Compiler/ TetraMAX NC-Verilog/ ModelSim Debussy (Verdi)/ VCS SOC Encounter/ Astro GDS II DRC/ LVS (Calibre)
PVS: Calibre xRC/ NanoSim (Time/ Power Mill)
Syntest
Conformal/ Formality
Tape Out
Advanced Reliable Systems (ARES) Lab. 5
What is Synthesis
Synthesis = translation + optimization + mapping
if(high_bits == 2b10)begin residue = state_table[i]; end else begin residue = 16h0000; end
Target Technology
6
Better
Cycle Time
Also, the code coverage of your test benches should be verified (i.e. VN) Good coding style will reduce most hazards while synthesis Better optimization process results in better circuit performance Easy debugging after synthesis
Constraints
The area and timing of your circuit are mainly determined by your circuit architecture and coding style There is always a trade-off between the circuit timing and area In fact, a super tight timing constraint may be worked while synthesis, but failed in the Place & Route (P&R) procedure
Advanced Reliable Systems (ARES) Lab. 7
Verilog Model
Key features of Verilog
Supports various level of abstraction
Switch level model or transistor level model Gate level model Data flow model or register transfer model Behavioral model
10
11
Verilog Module
/* This is sample code. The function is ALU. */ module ALU(a,b,sel,out); input [7:0] a,b; //Data in output[7:0]out; //Data out input [2:0]sel; //Control select reg [7:0]out; wire always@(...)begin end endmodule
module module_name(port_names); Port declaration Data type declaration Task & function declaration Module functionality or structure Timing Specification endmodule
12
Verilog Syntax
Verilog consists of a series token
Comment: //, /* */ operators: unary, binary, ternary
A=~B; A=B&C; C=SEL?A:B;
14
Connection Manners
16
Synthesizable Verilog
17
18
19
Asynchronous reset
always@(posedge clock or negedge reset) if (!rst) begin end end
Advanced Reliable Systems (ARES) Lab. 20
Synthesizable Verilog
Not all kinds of Verilog constructs can be synthesized Only a subset of Verilog constructs can be synthesized and the code containing only this subset is synthesizable
21
precedence
highest
lowest
23
Sequential Blocks
always @ (posedge clk )begin if (a) begin z<=1b1; end else begin z<=1b0; end end
25
Non-Blocking Assignment
always @ (posedge clk )begin b<=a; c<=b; end Just like shift register D Q b D Q c
clk
clk
26
always @ (d) begin x=1b0; z=1b0; case (d) 2'b00: begin z=1'b1; x=1b1; end 2'b01: begin z=1'b0; end default : begin z=1'b0; end endcase end always @ (posedge clk )begin if (a) begin z<=1b1; end else begin z<=1b0; end end
27
28
if else statements
always @ ( sel or a or b or c or d) begin if (sel==2'b00) out=a; else if (sel==2'b01) out=b; else if (sel==2'b10) out=c; else out=d; end sel d c b a 0 1
out
0 1
0 1
out
30
31
Start nLint
Unix% nLint gui &
32
33
34
Compile
35
36
37
Lab Time
38
11/28
: Synthesizable Verilog & Coding
Tips for Verilog Design RTL simulation Waveform viewer nWave / Debussy
39
Outline
Basic of Logic Synthesis Concept Basic Concept of Verilog HDL Synthesizable Verilog LAB 1-1: Design Rule Check with nLint Tips for Verilog Design LAB 1-2: RTL Simulation
40
41
Design partition
Follow the specifications recommendations for partition Break the design into major function blocks
42
Always think of the poor guy who has to read your RTL code
Correlate top to bottom in the RTL description with left to right in block diagram Comments and headers
Hierarchy design
Advanced Reliable Systems (ARES) Lab. 43
44
45
46
47
48
out=((a+(b+c))+(d+e));
c b a d e
out out
Advanced Reliable Systems (ARES) Lab. 49
Resource Sharing
Operations can be shared if they lie in the same always blocks
50
parameter size=8; wire [3:0] a,b,c,d,e; assign a=size+2; assign b=a+1; assign c=d+e;
51
module fixed_multiplier(a,b,c); input [8:0] a, b; output [8:0] c; reg [15:0] tmp; reg [8:0] c; assign tmp = a*b; assign c = tmp(15,8); endmodule
52
Timescale
`timescale: which declares the time unit and precision.
`timescale <time_unit> / <time_precision> e.g. : `timescale 1s/1ps, to advance 1 sec, the timewheel scans its queues 1012 times versus a `timescale 1s/1ms, where it only scans the queues 103 times.
The time_precision must be at least as precise as the time_unit. Keep precision as close in scale to the time units as is practical. If not specified, the simulator may assign a default timescale unit. The smallest precision of all the timescale directive determines the simulation time unit of the simulation.
53
54
Non-Synthesizable Style
Either non-synthesizable or incorrect after synthesis initial block is forbidden (non-synthesizable) Multiple assignments (multiple driving sources) Mixed blocking and non-blocking assignment
55
Summary
No initial in the RTL code Avoid unnecessary latches Avoid combinational feedback For sequential blocks, use non-blocking statement For combinational blocks, use blocking statements
56
57
Tools
Simulators
Verilog-XL, NC-Verilog, Altera Quartus, ModelSim and etc.
Synthesizers
Design vision, Ambit, and etc.
58
Verilog Simulator
59
Method 3:
Using additional description `include module_file
Advanced Reliable Systems (ARES) Lab. 60
61
Testbench
Compare this with your design
module testfixture; Declare signals Instantiate modules Applying stimulus Monitor signals endmodule
62
FSDB File
Waveform file format Add commands in testbench
// testbench.v module (); initial begin $fsdbDumpfile(abcd.fsdb); $fsdbDumpvars; End endmodule
63
Example of Testbench
//t_alu.v /* This is testbench of sample code. The function is ALU. */ module test_ALU; reg [7:0] A,B; reg[2:0]SEL; wire[7:0] OUT; ALU U0(.a(A),.b(B),.sel(SEL),.out(OUT)); always #5 B=~B; initial begin A=0;B=0;SEL=0; #10 A=0;SEL=1; #10 SEL=0; .. #10 SEL=1; #10 $finish; end initial begin $fsdbDumpfile(ALU.fsdb); $fsdbDumpvars; end endmodule
//alu.v /* This is sample code. The function is ALU. */ module ALU(a,b,sel,out); input [7:0] a,b; //Data in output[7:0]out; //Data out input [2:0]sel; //Control select reg [7:0]out; wire always@(...)begin end endmodule
Advanced Reliable Systems (ARES) Lab.
64
65
Get Signals
Select Signal -> Get Signal
66
Observe Waveform
67
Change Radix
68
Save Waveform
69
LAB Time
70