Department of Electrical Engineering: Lab No # 2: Introduction To Verilog (CLO4, P3)
Department of Electrical Engineering: Lab No # 2: Introduction To Verilog (CLO4, P3)
Group: 1 st(Rehan+Umair)
Umair 359625
Objectives:
Lab Instructions
This lab activity comprises three parts, namely Pre-lab, Lab tasks, and Post-Lab Viva session.
The lab report will be uploaded on LMS three days before scheduled lab date. The students will get
hard copy of lab report, complete the Pre-lab task before coming to the lab and deposit it with
teacher/lab engineer for necessary evaluation. Alternately each group to upload completed lab
report on LMS for grading.
The students failing to submit Pre-Lab will not be allowed to perform Lab work.
The students will start lab task and demonstrate design steps separately for step-wise
evaluation( course instructor/lab engineer will sign each step after ascertaining functional
verification)
Remember that a neat logic diagram with pins numbered coupled with nicely patched circuit will
simplify trouble-shooting process.
After the lab, students are expected to unwire the circuit and deposit back components before
leaving.
The students will complete lab task and submit complete report to Lab Engineer before leaving
lab. Verilog tutorial part is non-printable and for reference only.
There are related questions at the end of this activity. Give complete answers.
1) VHDL
2) Verilog HDL
1) Gate Level Modeling {using the basic gates and, or, Not, etc }
2) Dataflow Modeling {defining the flow of data among different components}
3) Behavioral Modeling {defining the overall behavior of system}
4) Switch Level Modeling {in which the transistor level of hardware is dealt with}
Write the Verilog Code using Gate Level modeling for the following circuit. List the code for design as well as
stimulus below:
module Task1(SUM,CARRY,A,B);
input A,B;
output SUM,CARRY;
not a1(w1,A);
and b1(w2,w1,B);
not a2(w3,B);
and b2(w4,A,w3);
or c1(SUM,w2,w4);
and b3(CARRY,A,B);
endmodule
module Test1;
Task1 t1(Out1,Out2,Inp1,Inp2);
initial
begin
#110;
end
endmodule
Wave form;
Modify the test bench to print the results of the simulation using the Verilog $monitor statement. The output
should look like this
input A,B;
Output;
Circuit form;
After determining the function performed by the circuit given in Lab Task 1, write the Verilog description of the
circuit at dataflow level. Comment on the two different modeling levels you used to model the same circuit.
(Paste snapshots of the codes and stimulus’s below)
Dataflow modeling utilizes Boolean equations, and uses a number of operators that can apply on
inputs to produce outputs operators like +, - , & , !, ~ , etc. Boolean equations are used in place of
logical gates’ modules. Some of the dataflow operators are shown below in modules.
Continuous Assignment:
EE-221: Digital Logic Design Page 7
The keyword assign declares a continuous assignment that binds the Boolean expression on the
right-hand side (RHS) of the statement to the variable on the left-hand side (LHS). Verilog
arithmetic and logical operations can be used in assign .The syntax of assign is as follows:
assign <net_name> = <expression>;
assign out = in1 & in2;
Write your code and result below;
Wave form;
input A,B;
output SUM,CARRY;
wire w1,w2,w3,w4;
endmodule
Task3 t1(Out1,Out2,Inp1,Inp2);
initial
begin
#80;
end
endmodule