Digital System Design: Verilog HDL Basic Concepts
Digital System Design: Verilog HDL Basic Concepts
Verilog HDL
Basic Concepts
Maziar Goudarzi
Today program
Lexical Conventions
Data Types
System Tasks and Compiler Directives
Operators
Unary
a = ~b;
Binary
a = b && c;
Ternary
a = b ? c : d; // the only ternary operator
Number Specification
Sized numbers
Unsized numbers
Unknown and high-impedance values
Negative numbers
count[5]
chk_point[100]
port_id[3]
Note the difference between vectors and arrays
2005 Verilog HDL 23
Memories
RAM, ROM, and register-files used many times in digital
systems
Memory = array of registers in Verilog
Word = an element of the array
Can be one or more bits
Examples:
reg membit[0:1023];
reg [7:0] membyte[0:1023];
membyte[511]
Note the difference (as in arrays):
reg membit[0:127];
reg [0:127] register;
2005 Verilog HDL 24
Parameters
Similar to const in C
But can be overridden for each module at compile-time
Syntax:
parameter <const_id>=<value>;
Gives flexibility
Allows to customize the module
Example:
parameter port_id=5;
parameter cache_line_width=256;
parameter bus_width=8;
wire [bus_width-1:0] bus;
2005 Verilog HDL 25
Strings
Strings are stored in reg variables.
8-bits required per character
The string is stored from the least-significant part to the
most-significant part of the reg variable
Example:
reg [8*18:1] string_value;
initial
string_value = Hello World!;
Escaped characters
\n: newline \t: tab
%%: % \\: \
\: \ooo: character number in octal
2005 Verilog HDL 26
Basic Concepts
System Tasks and
Compiler Directives
System Tasks
$display($time);
Output: 230
Output:
0 value of signals clock=0, reset=1
5 value of signals clock=1, reset=1
10 value of signals clock=0, reset=0
Course web-page
http://ce.sharif.edu/courses/84-85/1/ce223/
Exercise 2
Chapter 3 exercises
Due date: Next Sunday (Aban 8th)