Project2 LAB Manual
Project2 LAB Manual
&
COMPUTER ENGINEERING
PROJECT 2
Good Luck
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
TABLE OF CONTENTS
REGULATIONS 3
EXPERIMENT #2 4
2.1 OBJECTIVE 4
2.8 REFERENCES 11
Page|2
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
REGULATIONS
Students are not permitted to perform an experiment without doing the preliminary work before coming to
the laboratory.
It is not allowed to do the preliminary work at the laboratory during the experiment.
Students, who do not turn in the complete preliminary work printout at the beginning of the laboratory session,
cannot attend the lab. No “make-up” is given in that case.
No food or drink in the lab.
Only the following excuses are valid for taking lab make-up:
1. Health Make-up: Having a health report from METU Medical Center.
2. Exam Make-up: Having an exam coinciding with the time of the laboratory session. The student needs
to notify the instructor in advance if this is the case.
Experiments will be done in teams of two.
Cheating or plagiarism is not tolerated. Plagiarism is a form of cheating as is using someone else’s written
word with minor changes and no acknowledgement. If you are caught cheating or plagiarising, you will at the
very least receive a zero for the whole experiment. Disciplinary action may be taken.
Students who miss the lab two times without a valid excuse get zero as the laboratory portion of the course
grade.
Those who fail to get a satisfactory score from the laboratory portion may fail the class. This score is
expected to be 70% but may be adjusted up or down with the initiative of the course instructor.
Page|3
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
EXPERIMENT #2
2.1 OBJECTIVE
In this project, you are required to design and implement a Datapath for a 4-bit Smart Climate Control
®
System. Altera toolset and Modelsim will be used to code, simulate, and implement the design.
Students should prepare and submit a report before the LAB demo including all the codes, diagrams, and
simulation waveforms that they will demonstrate for experiment mentioned below.
In this Experiment the Datapath design will be demonstrated with your partner to the LAB instructor as
usual. The report must include all the module designs and simulations. Also, you'll need to test the overall
Datapath design (the complete setup) in Modelsim® using inputs similar to what the Finite State Machine
(FSM) will provide in the upcoming project. However, for this particular project, follow the instructions
provided in the manual for feeding inputs.
Page|4
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
2.2.2 Objectives
After completing this lab, you will be able to:
input D,clk;
output reg Q;
initial
begin
Q=1'b0;
end
endmodule
Page|5
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
In digital systems, flip flops serve as fundamental components in constructing registers, which are arrangements
of flip flops employed to store multiple bits of data. For instance, to store 16-bit data, a computer requires a set
of 16 flip flops. Registers may adopt either serial or parallel input and output configurations, depending on
specific system requirements. The succession of data bits stored by registers is termed as a "Byte" or "Word,"
where a Byte consists of 8 bits and a Word comprises 16 bits (or 2 Bytes). When flip flops are interconnected
in sequence, they form a Register. The transfer of information within registers, known as 'Shift Registers,'
involves sequential circuits that store and shift data towards the output during each clock cycle. While various
types of registers exist, our project focuses on the parallel-in parallel-out shift register.
input [size-1:0]D;
input clk;
d_ff U1(D[0],clk,Q[0]);
d_ff U2(D[1],clk,Q[1]);
d_ff U3(D[2],clk,Q[2]);
d_ff U4(D[3],clk,Q[3]);
endmodule
For the given data path in figure 4, you need to construct this type of hierarchical design for proper functionality
for the project.
Page|6
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
2.2.4 CCU
The Central Control Unit (CCU) serves as a crucial digital logic circuit commonly integrated into
microcontrollers, microprocessors, and DSPs. Its role encompasses executing arithmetic, logical, and
comparison operations on input signals. The construction of the CCU relies on the inclusion of combinational
circuits like adders, multiplexers, comparators, and decoders, tailored to facilitate its functionalities.
Figure 3: CCU
In this project, the Central Control Unit (CCU) will incorporate specific inputs and outputs, accompanied by
flags for input comparison. For instance, if input equality is detected, the FLAG_E will indicate an output of
'1'. Similar comparisons will be conducted for other inputs. Detailed operational instructions for the CCU
under various OP_CODE scenarios are provided in Table 2.
Page|7
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
Each component of the Datapath must undergo individual design and simulation before integration into the
overarching structure. Interconnections among these components should be established within the top-level
design SCCS_DATAPATH, employing a hierarchical design methodology.
This approach should adhere to a parametric model, enabling flexibility in adjusting the controller's bit size.
Consequently, a parameterized Verilog code should be written to define the Datapath. The assignment of signals
such as CLK and others should align with the directives outlined in section 2.4.
Page|8
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
wrt_addr signal provides an address to activate the required register as stated in Table 1.
Table 1: 2-to-4 Decoder Operation.
wrt_addr Registers
A B REG_3 REG_2 REG_1 REG_0
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
wrt_en works together with the wrt_addr to select either a new value or hold the previous value.
Toggle_T/H also works with the wrt_en and wrt_addr to set either the Temperature setting or the
Humidity Setting.
load_data signal selects either the new Temperature/Humidity User/Sensor values from the 4_to_1
MUX or the ALU output result for feedback.
Input_sel is used to select the User_Temperature, Sensor_Temperature, User_Humidity,
Sensor_Humidity. (Note: we use a 4-bit data path so these values should lie between 0-15)
rd_addr1 and rd_addr2 signals provide the register addresses that are required to perform the CCU
operations between two registers using the ccu_opcode provided. The CCU must be designed with the
following operations stated in Table 2. You can use the behavioural approach to design the CCU.
Table 2: ALU Opcodes and Instructions.
*** Please note that these signals must be used in Datapath testbench to test all possible conditions required to
perform operations for SCCS.
Page|9
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
Page|10
E E E 2 4 8 | C N G 2 3 2
L o g i c D e s i g n
P R O J E C T 2
2.6.3 TESTBENCH
Write a test bench code for your Datapath to test the various modes as described in the section 2.4. Add your
test bench code and simulation results accompanied by explanatory comments detailing your methodology.
2.7.4 EVALUATION
During your project demo, you will be evaluated on your understanding of:
o Combinational and sequential concepts,
o DATAPATH design details,
o Verilog-based design entry, and
o Simulation flows.
Prepare various test bench waveforms in advance to show your datapath is working properly. Remember,
you will have very limited time with the Teaching Assistant to demonstrate your working design, AND you
fully understand your design. He/she will perform the debugging for you. Start your project early so you
can resolve any problems ahead of time during office hours and come to the final demo fully prepared!
2.8 REFERENCES
th
Digital Design with An Introduction to the Verilog HDL, 5 Edition, M. Morris Mano & Michael D.
Ciletti, Pearson
Page|11