end of the include guard at the bottom of your Verilog source file as shown on line 43. .

28 case ( sel ) % iverilog -g2012 -o hello-world hello-world.v . define sensitivity lists, always_ff and always_comb more directly capture designer intent and allow names. .

if statements including nested if statements. . .

40 . overflow and then a sequence of subtractions that essentially undo the overflow. . 27 .

statement to also be unknown. .

5 logic [7:0] C; For example, by convention we should only use non-blocking assignments syntax shown in this example.

.

.

ECE 5745 Complex Digital ASIC Design, Spring 2016 Tutorial 4: Verilog Hardware Description Language 48 : ( sel == 2'b01 ) ? ~& reduce via NAND while still ensuring there is a clear mapping from the model to the target hardware. . .

.

The first major extension was Verilog−XL, which added a few features and implemented the infamous "XL algorithm" which was a very efficient method for doing gate−level simulation. 1 //====================================== on lines 16–19, ports should be listed one per line with a two space initial indentation. . . 44 end Notice 28 else Where is your GitHub ID, not your NetID.

is very different from the if statements described completed the Linux and Git tutorials. . != not equal . < less than In this case, we can guarantee that for any value for the second operand .

Note that carefully considering the bitwidths of the input and output variables is important.

Line 14 declares a new variable of type state_t.

17 D = 12'd1058; $display( "12'd1058 = %x", D ); 37 second operand it cannot be greater than the first operand. . ECE 5745 Complex Digital ASIC Design, Spring 2016 Tutorial 4: Verilog Hardware Description Language School of Electrical and Computer Engineering Figure 13 illustrates using casez statements.

4 // This is a simple example of a module

.

A

In other words, we wildcard matching). . We should explicitly use the signed system task whenever we need to ensure signed compar- . You can run iverilog as follows to compile .

. always ask ourselves, “What will happen if one of the inputs is an X?” Lines 35–39 illustrate what .

. .

. 15 a = ( A == B ); $display( "(15 == 9) = %x", a ); 48 2'bx0 : a = 8'h0e; As shown on lines 15 and 20, the opening and X optimism can cause subtle simulation/syn-

3.1 Hello World .

. 49 2'bxx : a = 8'h0f; . .

. Lines 13–16 illustrate how to write single-bit literals to express constant values.

. . Note that some bits in the result are X and some can

it is good design practice to usually draw some kind of diagram of the hardware we wish to model . . ECE 5745 Complex Digital ASIC Design, Spring 2016 Tutorial 4: Verilog Hardware Description Language . actually provides many different ways to create enum types including anonymous types, types where

All module

.

stead of two bits.

Create

28 // Bitwise logical operators for doing AND, OR, XOR, and NOT with X . known must be known (i.e., all Xs will either be a For this course, we 28 a = ( A > B ); $display( "(4'b1100 > 4'b10xx) = %x", a );

. 17 . when creating larger bit vectors. case statement for a sel variable with three in- 47 c = ( sel == 2'b00 ) ? 18 c = ( b < a ) ? There are similar issues as with the if statement in 7 logic [11:0] E; // 12-bit logic variable

.

26 a = ( A == B ); $display( "(4'b1100 == 4'b10xx) = %x", a ); .

code. Lines 22–39 model the internal behavior of the module.

ECE 5745 Complex Digital ASIC Design, Spring 2016 Tutorial 4: Verilog Hardware Description Language This helps in understanding some of the basics of verilogFSM in Verilog Part 1-Verilog and HDL-Lecture SlidesFSM in Verilog Part 2-Verilog and HDL-Lecture SlidesVerilog Coding Guidelines-Verilog HDL and FPGAs-Lecture Slides . naming conventions to eliminate any possibility of a namespace collision. Note that to declare a four-bit logic value, we use [3:0] not [4:0].

result to the console. . .

34 4'b?100 : b = 8'd3;

Tutorial on Verilog HDL 2. 34 $display( "( STATE_A == STATE_B ) = %x", result ); example later in this tutorial. . . . Cornell University .

15 (

5.3 Structural Sorter Implementation . .

We will use the _t suffix to distinguish type names from variable names.

. . 37 $display( "point_b.y = %x", point_b.y ); 40 .