Verilog Tutorial 1
Verilog Tutorial 1
Variables
In Verilog, what are nets used for?
Ans: _______________________________
What are registers used for in Verilog?
Ans: _______________________________
What is the generic name for both nets and registers?
Ans: _______________________________
What is a single bit net called?
Ans: _______________________________
What is a multiple bit register called?
Ans: _______________________________
Logic Values
Give the four basic Verilog signal values and their meanings
Ans: _______________________________
Register Assignment
List four Verilog constructs within which a register can be assigned.
Ans: _______________________________
List two Verilog constructs by which a register can never be assigned.
Ans: _______________________________
Strings
What is the data type for a string?
Ans: _______________________________
A string must be stored in reg (or array). Describe a register with identifier buffer
for storing in a string of 32 8-bit characters.
Ans: _______________________________
2
Constants
Declaration of parameters
A sequential circuit has three states A, B, and C with state codes 00, 01, and
10, respectively. Write a parameter statement assigning these codes to their
respective states.
Ans: _______________________________
Ans: _______________________________
Operators
Give the function that each of the operators listed performs:
Arithmetic (binary)
+
A:
A:
*
A:
/
A:
%
A:
Arithmetic (unary)
+
A:
A:
Bitwise
~
A:
&
A:
|
A:
^
A:
~^ or ^~
A:
Reduction
&
A:
~&
A:
|
A:
~|
A:
^
A:
~^ or ^~ A:
Logical
!
&&
||
A:
A:
A:
3
==
!=
===
!==
Relational
<
>=
>
<=
A:
A:
A:
A:
A:
A:
A:
A:
Shift
>>
<<
A:
A:
Conditional
?:
A:
Concatenation and Replications
{,}
A:
{int{ }}A:
Arithmetic unary
op x where op is +, Bit width = width(x)
Bitwise negation
op x where op is ~
Bit width = width(x)
Logical, relational and reduction
x op y where op is = =, !=, = = =, != =, &&, ||, >, >=, <, <= or op y where op is !, &, |,
^, ~&, ~|, ~^
Bit width = 1
What is the bit width of (X && (A + B)) for wire X; wire[7:0] A, B;?
Ans: _______________________________
Shift
x op y where op is <<, >>
Bit width = width(x)
Conditional
x?y:z
Bit width = max(width(y), width(z))
What is the bit width of assign result = X ? A:B; for wire X; reg[9:0] A; reg[18:10]
B;
Ans: _______________________________
Concatenation
{x, , y}
Bit width = width(x) + + width(y)
What is the bit width of {A, B, C} for wire A; reg[7:0] B; reg [15:0] C;?
Ans: _______________________________
Replication
{x{y, , z}}
Bit width = x * (width(y) + + width(z))