Beruflich Dokumente
Kultur Dokumente
using
VerilogHDL
Presented by
Algorithmic analysis
Behavioral
representation
Architectural Design
Logic design
Gate level
representation Logic verification
16 May 2008 2
An Example: Typical Architecture of IC
CONTROLLER
LOGIC
Main Logic
Logic
Unit
REG3
16 May 2008 3
A Laboratory Flow for ASIC Design (Cell Based)
HDL
Verilog-XL (Cadence)
Logic Simulation
SimVision (Cadence)
Physical Design
Silicon Ensemble (Cadence)
Physical
Hercules (Avant) Verification
16 May 2008 4
Hardware Description Language
HDL
VHDL VerilogHDL
16 May 2008 5
VerilogHDL: History
16 May 2008 6
Identifiers & Logic Values in Verilog
16 May 2008 7
Verilog Data Types
¾ Integer
16 May 2008 8
Hierarchical Design using modular concept
top_module
16 May 2008 9
Black Box Design for VLSI Architecture of a
CHIP
Module Definition
I/O PORTS
16 May 2008 10
Modular Design using Verilog HDL
module module_name (port_names);
-----------
port_types input [port_size] input_port_names;
----------- output [port_size] output_port_names;
wire declaration wire [wire_size] wire_names;
reg declaration reg [reg_size] reg_names;
-----------
Black Box
description
endmodule
16 May 2008 11
Module Instatiation
Module top_module_name(Port_names);
input [port_size] input_port_names;
output [port_size] output_port_names;
wire [wire_size] wire_names;
------------
module_name1 instatiation_name1(port_conections);
module_name2 instatiation_name2(port_conections);
-----------
endmodule
By Position/Ordering By Names
16 May 2008 12
PORT CONNECTIONS: An Example
a1
top_mod
in0 a3
moda
a2 w1
c1
16 May 2008 13
Port Connections in Verilog HDL
(By Position/Ordering)
in0 a1 top_mod
module moda(a1,a2,a3); a3
input a1,a2; a2
moda w1
c1
output a3; in1 modc c3 out
----- c2
b1 w2
endmodule in3 b2 modbb3
module modb(b1,b2,b3)
input b1,b2;
output b3 module top_mod(in0,in1,in2,out);
----- input in0,in1,in2;
Endmodule
output out;
module modc(c1,c2,c3) wire w1,w2;
input c1,c2; moda mi0(in0,in1,w1);
output c3
----- modb mi1(in1,in2,w2);
endmodule modc mi2(w1,w2,out);
16 May 2008
endmodule 14
Port Connections in Verilog HDL (By Name)
in0 a1 top_mod
module moda(a1,a2,a3); a3
input a1,a2; a2
moda w1
c1
output a3; in1 modc c3 out
----- c2
b1 w2
endmodule in3 b2 modbb3
module modb(b1,b2,b3)
input b1,b2;
output b3 module top_mod(in0,in1,in2,out);
----- input in0,in1,in2;
endmodule
output out;
module modc(c1,c2,c3) wire w1,w2;
input b1,b2; moda mi0(.a1(in0), .a2(in1), .a3(w1));
output c3 modb mi1(.b1(in1), .b2(in2), .b3(w2));
-----
endmodule
modc mi2(.c1(w1), .c2(w2), .c3(out));
endmodule
16 May 2008 15
Modular Design using Verilog HDL
Behavioral description
endmodule
16 May 2008 16
Switch Level Design
S D S D
G G
pmos nmos
16 May 2008 17
Switch Level Design (cont..)
endmodule
gnd
16 May 2008 18
Switch Level Design (cont..)
16 May 2008 19
Gate Level/Structural Design
Multiplexer using primitives module mux (f, a, b, sel);
output f ;
a f1
nsel g1 input a, b, sel;
g4 f
g3 wire nsel, f1, f2;
b
g2
sel f2
and g1(f1, a, nsel),
and g2(f2, b, sel);
or g3(f, f1, f2);
not g4(nsel, sel);
endmodule
16 May 2008 20
An Example: 4-bit Adder design
4-bit adder
FA FA FA FA
16 May 2008 21
Structural representation – example
module FA (co, s, a, b, c);
//4-bit adder input a, b, c;
output s, co;
module add4bit (s, c4, ci, a, b); sum s1 (s, a, b, c);
input [3:0] a, b; carry c1 (co, a, b, c);
endmodule
input ci;
output [3:0] s; module carry (co, a, b, c);
output c4; input a, b, c;
output co;
wire [2:0] co;
wire x, y, z;
FA a0 (co[0], s[0], a[0], b[0], ci); and g1 (x, a, b);
FA a1 (co[1], s[1], a[1], b[1], co[0]); and g2 (y, a, c);
and g3 (z, b, c);
FA a2 (co[2], s[2], a[2], b[2], co[1]); or g4 (co, x, y, z);
FA a3 (c4, s[3], a[3], b[3], co[2]); endmodule
endmodule module sum ( s, a, b, c);
input a, b, c;
output s;
xor x1(s,a,b,c)
16 May 2008 22
endmodule
Dataflow Design
Conditional statements
Or
Logic Expressions
16 May 2008 23
Dataflow Design (cont..)
assign f <= sel ? b :a; assign f <= a& (~sel) | b& sel;
endmodule endmodule
16 May 2008 24
Behavioral Design
16 May 2008 25
Behavioral Verilog HDL codes
Multiplexer: As an Example
module module_name (port_names); module mux (f, a, b, sel);
endmodule endmodule
16 May 2008 26
Flipflop Design: An Example
module DFF (d, q, qbar, clk, reset);
input d,clk,reset;
output q,qbar;
reg q,qbar;
always @(posedge clk or posedge reset)
begin
if (sel)
begin
q = 1’b0;
qbar = 1’b1;
end
else
begin
q = d;
qbar = ~d;
end
end
endmodule
16 May 2008 27
Behavioral Statements
16 May 2008 28
Blocks Statements
initial
begin
#5 d = a+b;
#10 e = a-c;
#15 f = b+c;
end
16 May 2008 30
Examples
• Non-blocking:
always @(A2 or B2 or C2 or M2) Statement executed at
time t causing M2 to be
begin assigned at t+3
M2<=#3(A2 & B2);
Y2<=#1(M1 | C1); Statement executed at
time t causing Y2 to be
end assigned at time t+1.
Uses old values.
16 May 2008 31
Example: Physical Implementation
16 May 2008 32
Example: Physical Implementation
a b c
b
DFF
a
DFF DFF
c
DFF
blocking Non-blocking
16 May 2008 33
Design using Functions & Tasks
Function Task
module m_name (port_declaration) module m_name (port_declaration)
…… ……
Begin Begin
…… ……
ret_val= func_name (arguments); task_name (arguments);
end end
16 May 2008 34
FSM Design using VerilogHDL
module parity (clk, reset, i, o);
input clk, reset, i;
Reset
output o;
reg st, next_st, o;
parameter st_even = 0, st_odd = 1;
Even/0
always @(posedge clk or posedge reset)
begin i=1 i=1
if (reset == 1)
st <= st_even; Odd/1
else
st <= next_st;
end
/* state transitions */
/* output computation */
endmodule
16 May 2008 35
State Transitions & Output computations
//State Transitions
always @(i or st)
begin
if (i == 1) begin Reset
if (st == st_even)
next_st = st_odd;
else
next_st = st_even; Even/0
end
else
next_st = st; i=1 i=1
end
16 May 2008 36
Simulation using Test Bench
16 May 2008 37
An Example: multiplexer
//mux21.v
module mux21 (in0, in1, sel, out);
input in0,in1,sel;
output out;
assign out = (~sel & in0)| (sel & in1);
endmodule
//tb_mux21.v
module tb_mux21 (in0, in1, sel, out);
reg IN0,IN1,SEL;
wire OUT;
mux21 muxtop(IN0, IN1, SEL, OUT);
initial //Test Vector Generator
begin
IN0=1’b1; IN1=1’b0;SEL=1’b1;
#2 IN0=1’b1; #3 IN1=1’b0; #5 SEL=1’b1;
end
initial //Check Response
$display(‘%b,%b,%b,%b’, IN0, IN1,SEL,OUT);
endmodule
16 May 2008 38
Test Bench with High level Language
Test Vector
Generator
Result
checker
16 May 2008 39
Conclusion
¾ Write RTL codes i.e. Synthesizable codes for
design
¾ Avoid Non Synthesizable codes
i.e. initial, #, while
¾ Write Mixed codes in Test Bench
¾ Write codes which can be translated into hardware
¾ Write structural codes for design on your effort
• Finally, remember that you are a better
designer than the tool!
16 May 2008 40
Reference
By Sameer Panitkar
16 May 2008 41
Thank You
16 May 2008 42