Professional Documents
Culture Documents
11 Verilog 2001 PDF
11 Verilog 2001 PDF
11 Verilog 2001 PDF
by Stuart Sutherland
Sutherland HDL, Inc.
Verilog Training and Consulting Experts
/*
/* location
location of
of RTL
RTL models
models (current
(current directory)
directory) */
*/
library
library rtlLib
rtlLib "./*.v";
"./*.v";
Library Map File /*
/* Location
Location of
of synthesized
synthesized models
models */
*/
library
library gateLib
gateLib "./synth_out/*.v";
"./synth_out/*.v";
module
module multiplier
multiplier (a,
(a, b,
b, product);
product);
parameter
parameter a_width
a_width == 8,
8, b_width
b_width == 8;
8;
localparam
localparam product_width
product_width == a_width
a_width ++ b_width;
b_width;
input
input [a_width-1:0]
[a_width-1:0] a;
a;
input [b_width-1:0] b; localparams
localparams are
are constants,
constants,
input [b_width-1:0] b;
output which
which cannot
cannot be
be redefined
redefined
output [product_width-1:0]
[product_width-1:0] product;
product;
generate
generate
if
if ((a_width
((a_width << 8)
8) ||
|| (b_width
(b_width << 8))
8))
CLA_multiplier
CLA_multiplier #(a_width,
#(a_width, b_width)
b_width) u1 u1 (a,
(a, b,
b, product);
product);
else
else
WALLACE_multiplier
WALLACE_multiplier #(a_width,
#(a_width, b_width)
b_width) u1u1 (a,
(a, b,b, product);
product);
endgenerate
endgenerate
•• If
If the
the input
input bus
bus widths
widths are
are 8-bits
8-bits or
or less,
less, generate
generate
endmodule
endmodule
and
and instance
instance of
of aa carry-look-ahead
carry-look-ahead multiplier
multiplier
•• If
If the
the input
input bus
bus widths
widths are
are greater
greater than
than 8-bits,
8-bits,
generate
generate an
an instance
instance of
of aa wallace-tree
wallace-tree multiplier
multiplier
module
module ram
ram (...); Verilog
(...); Verilog 1995:
1995:
parameter
parameter RAM_SIZE
RAM_SIZE == 1024;
1024;
parameter
parameter ADDRESS
ADDRESS == 12;
12; Vector
Vector widths
widths can
can be
be calculated
calculated
input
input [ADDRESS-1:0]
[ADDRESS-1:0] address_bus;
address_bus; using
using simple
simple constant
constant expressions
expressions
module
module ram
ram (...);
(...);
parameter
parameter RAM_SIZE
RAM_SIZE == 1024;
1024;
input
input [clogb2(RAM_SIZE)-1:0]
[clogb2(RAM_SIZE)-1:0] address_bus;
address_bus;
...
...
function
function integer
integer clogb2;
clogb2; Verilog
Verilog 2000:
2000:
input depth;
input depth; Vector
Vector widths
widths can
can be
be calculated
calculated
integer
integer i;i;
begin using
using complex
complex constant
constant functions
functions
begin
clogb2
clogb2 == 1;
1;
for
for (i
(i == 0;
0; 2**i
2**i << depth;
depth; ii == ii ++ 1)
1)
clogb2
clogb2 == ii ++ 1;
1;
end
end
endfunction
endfunction
...
...
10 Mar 2000 © 2000, Sutherland HDL, Inc., www.sutherland-hdl.com 13
Sutherland
4: HD
L
Indexed Vector Part Selects
Verilog-2000 adds the capability to use variables
to select a group of bits from a vector
! The starting point of the part-select can vary
! The width of the part-select remains constant
reg
reg [63:0]
[63:0] word;
word;
reg
reg [3:0]
[3:0] byte_num;
byte_num; //a
//a value
value from
from 00 to
to 77
wire
wire [7:0]
[7:0] byteN
byteN == word[byte_num*8
word[byte_num*8 +:
+: 8];
8];
The
The starting
starting point
point of
of the
the The
The width
width of
of the
the
part-select
part-select is
is variable
variable part-select
part-select is
is constant
constant
+: indicates
+: indicates the
the part-select
part-select increases
increases from
from the
the starting
starting point
point
-: indicates
-: indicates the
the part-select
part-select decreases
decreases from
from the
the starting
starting point
point
//declare
//declare aa 3-dimensional
3-dimensional array
array of
of 8-bit
8-bit wire
wire nets
nets
wire
wire [7:0]
[7:0] array3
array3 [0:255][0:255][0:15];
[0:255][0:255][0:15];
//select
//select one
one word
word out
out of
of aa 3-dimensional
3-dimensional array
array
wire
wire [7:0]
[7:0] out3
out3 == array3[addr1][addr2][addr3];
array3[addr1][addr2][addr3];
//select
//select the
the high-order
high-order byte
byte of
of one
one word
word in
in aa
//2-dimensional
//2-dimensional array
array of
of 32-bit
32-bit reg
reg variables
variables
reg
reg [31:0]
[31:0] array2
array2 [0:255][0:15];
[0:255][0:15];
wire
wire [7:0]
[7:0] out2
out2 == array2[100][7][31:24];
array2[100][7][31:24];
module
module ram
ram (...);
(...);
parameter
parameter RAM_SIZE
RAM_SIZE == 1024;
1024;
input
input [(2**RAM_SIZE)-1:0]
[(2**RAM_SIZE)-1:0] address_bus;
address_bus;
...
...
Verilog-1995 Verilog-2000
always
always @(sel
@(sel or
or aa or
or bb or
or cc or
or d)
d) always
always @(sel,
@(sel, a,a, b,
b, c,
c, d)
d)
case
case (sel)
(sel) case
case (sel)
(sel)
2’b00:
2’b00: yy == a;
a; 2’b00:
2’b00: yy == a;
a;
2’b01:
2’b01: yy == b;
b; 2’b01:
2’b01: yy == b;
b;
2’b10:
2’b10: yy == c;
c; 2’b10:
2’b10: yy == c;
c;
2’b11:
2’b11: yy == d;
d; 2’b11:
2’b11: yy == d;
d;
endcase
endcase endcase
endcase
Verilog-2000 assign
assign nn == aa ** b;
b; //defaults
//defaults to
to wire,
wire, width
width of
of (a
(a ** b)
b)
Verilog-1995 Verilog-2000
module
module my_chip
my_chip (...);
(...); module
module my_chip
my_chip (...);
(...);
...
... ...
...
RAM
RAM #(8,1023)
#(8,1023) ram2
ram2 (...);
(...); RAM
RAM #(.SIZE(1023))
#(.SIZE(1023)) ram2
ram2 (...);
(...);
endmodule
endmodule endmodule
endmodule
Verilog-1995 Verilog-2000
module
module mux8
mux8 (y,
(y, a,
a, b,
b, en);
en); module
module mux8
mux8 (y,
(y, a,
a, b,
b, en);
en);
output
output [7:0]
[7:0] y;
y; output
output reg
reg [7:0]
[7:0] y;
y;
input
input [7:0]
[7:0] a,
a, b;
b; input
input wire
wire [7:0]
[7:0] a,
a, b;
b;
input
input en;
en; input
input wire
wire en;
en;
...
...
reg
reg [7:0]
[7:0] y;
y;
wire
wire [7:0]
[7:0] a,
a, b;
b;
wire
wire en;
en;
...
...
Verilog-1995 Verilog-2000
module
module mux8
mux8 (y,
(y, a,
a, b,
b, en);
en); module
module mux8
mux8 (output
(output reg
reg [7:0]
[7:0] y,
y,
output
output [7:0]
[7:0] y;
y; input
input wire
wire [7:0]
[7:0] a,
a,
input
input [7:0]
[7:0] a,
a, b;
b; input
input wire
wire [7:0]
[7:0] b,
b,
input
input en;
en; input
input wire
wire en);
en);
...
...
reg
reg [7:0]
[7:0] y;
y;
wire
wire [7:0]
[7:0] a,
a, b;
b;
wire
wire en;
en;
...
...
Verilog-1995 Verilog-2000
reg
reg clock;
clock; reg
reg clock
clock == 0;
0;
initial
initial
clk
clk == 0;
0;
Verilog-1995 case
case (1'b1)
(1'b1) /*
/* synopsys
synopsys parallel_case
parallel_case */
*/ //1-hot
//1-hot FSM
FSM
Verilog-2000 (*
(* parallel
parallel case
case *)
*) case
case (1'b1)
(1'b1) //1-hot
//1-hot FSM
FSM
Verilog-2000 is complete
! The proposed IEEE 1364-2000 Verilog standard is now
in the final balloting phase
Verilog-2000 contains
! Over 30 major enhancements
! Many clarifications and errata corrections
Verilog-2000 adds powerful capabilities
! Greater deep submicron accuracy
! More abstract system level modeling
! Scalable, re-usable modeling
Final approval is expected in the summer of 2000
10 Mar 2000 © 2000, Sutherland HDL, Inc., www.sutherland-hdl.com 47
Sutherland
HD
About The Author L
Stuart Sutherland
! President of Sutherland HDL, Inc., Portland, Oregon
! Provides expert Verilog design consulting and training
! More than 15 years design experience, and over 12
years working with Verilog
! Author of “The Verilog HDL Quick Reference Guide”,
“The Verilog PLI Quick Reference Guide” and “The
Verilog PLI Handbook”, a 750 page reference book
! Member of the IEEE 1364 Verilog standards
committee since 1993
! Co-chair of the PLI task force within the committee
10 Mar 2000 © 2000, Sutherland HDL, Inc., www.sutherland-hdl.com 48