Computer Engineering Department: Computer Architecture Activity Manual
Computer Engineering Department: Computer Architecture Activity Manual
1 PC unit
1 Keyboard and Mouse
1 USB cable
1 Adaptor
6.6 Procedure/s
1. Given below is the truth table of the half-adder circuit.
a b S C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
3. Explanations
Line 4 : Re-declaration of output S using the reserve word reg.This is needed for the first
process for output S.
Line 5 : The reserve word always @ is used to define the process inside your Verilog
program, it is of the same concept as you are using process inside a VHDL program.
What are inside the parenthesis (a, b) are the input ports that you’ll be using inside your
process.
Line 7 : The expression case (a) switches the value of input a to the expression.
Line 8 : If the value of a matches with the test value 1’b0(which is actually equivalent to
a value of logic 0), the statement after the colon (:) is executed, which in this scenario
another case is to be performed.
The expression case (b) switches the value of input b to the expression.
Line 9 : If the value of b matches with the test value 1’b0(which is actually equivalent to
a value of logic 0), the statement after the colon (:) is executed, causing the value of logic
0 be stored to output S.
Line 10: If the value of b does not match with the test value 1’b0, the statement after
default is executed, an implied meaning that the value of b here is logic 1. The statement
after default is executed, causing the value of logic 1 be stored to output S.
Line 11 : The reserve word endcase is used to end the inner case statement; case(b)of
Line 8.
Line 12 : The default here is executed when the value of a does not match with the test
value 1’b0, an implied meaning that the value of a here is logic 1. The expression case
(b) switches the value of input b to the expression.
Line 13 : If the value of b matches with the test value 1’b0(which is actually equivalent
to a value of logic 0), the statement after the colon (:) is executed, causing the value of
logic 1 be stored to output S.
Line 15 :The reserve word endcase is used to end the inner case statement; case(b) of
Line 12.
Line 16 : The reserve word endcase is used to end the outer case statement; case(a) of
Line 7.
4. Save, compile and download your program in the FPGA board. Verify results.
6. Save, compile and download your program in the FPGA board. It should give the same
output to that of the first version.
10. Design a Verilog program implementing behavioral descriptions of the full subtractor
circuit using nested case, if-case, case-if statements presented in the procedure. Write
your codes in Table 2 of the Data and Results section of this activity.
Table 1
FULL ADDER-NESTED CASE
begin
case (A)
1'b0 :
case (B)
1'b0:
case (Cin)
1'b0 : S=1'b0;
default: S=1'b1;
endcase
default: case (Cin)
1'b0 : S=1'b1;
default: S=1'b0;
endcase
endcase
default: case (B)
1'b0:
case (Cin)
1'b0: S=1'b1;
default: S=1'b0;
endcase
default: case (Cin)
1'b0 : S=1'b0;
default: S=1'b1;
endcase
endcase
endcase
end
begin
case (A)
1'b0 :
case (B)
1'b0:
case (Cin)
1'b0 : C=1'b0;
default: C=1'b0;
endcase
default: case (Cin)
1'b0 : C=1'b0;
default: C=1'b1;
endcase
endcase
default: case (B)
1'b0:
case (Cin)
1'b0: C=1'b0;
default: C=1'b1;
endcase
default: case (Cin)
1'b0 : C=1'b1;
default: C=1'b1;
endcase
endcase
endcase
end
endmodule
reg S;
case (A)
1'b0: if (B == 1'b0 && Cin == 1'b0)
S= 1'b0;
else if (B == 1'b0 && Cin == 1'b1)
reg C;
always @ (A, B, Cin)
begin
case (A)
1'b0: if (B == 1'b0 && Cin == 1'b0)
C = 1'b0;
else if (B == 1'b0 && Cin == 1'b1)
C = 1'b0;
else if (B == 1'b1 && Cin == 1'b0)
C = 1'b0;
else
C = 1'b1;
default : if (B == 1'b0 && Cin == 1'b0)
C =1'b0 ;
else if (B == 1'b0 && Cin == 1'b1)
C =1'b1;
else if (B == 1'b1 && Cin == 1'b0)
C =1'b1;
else
C= 1'b1;
endcase
end
endmodule
reg D;
FULL SUBTRACTOR-CASE IF
module FA6F (A, B, Bin, D, Bout);
input A, B, Bin;
output D, Bout;
reg D;
reg B1;
always @ (A1,A2,A3)
begin
case (A1)
1'b0:
B1 = 1'b0;
default:
case (A2)
1'b0:
case (A3)
1'B0: B1 = 1'b0;
default: B1 = 1'b0;
endcase
default: case (A3)
1'B0: B1 = 1'b1;
default: B1= 1'b1;
endcase
endcase
endcase
end
reg B2;
always @ (A1,A2,A3)
begin
case (A1)
1'b0:
B2 = 1'b0;
default:
case (A2)
1'b0:
B2 = 1'b1;
default:
case (A3)
1'b0:
B2 = 1'b0;
default :
reg B3;
always @ (A1,A2,A3)
begin
case (A1)
1'b0:
case (A2)
1'b0:
B3 = 1'b0;
default:case (A3)
1'b0:
B3 = 1'b0;
default :B3 = 1'b1;
endcase
endcase
default:
case (A2)
1'b0:
case (A3)
1'b0: B3 = 1'b0;
default : B3 = 1'b1;
endcase
default:
B3=1'b0;
endcase
endcase
end
reg B4;
always @ (A1,A2,A3)
begin
case (A1)
1'b0 :
case (A2)
1'b0:
B4 = 1'b0;
default:
reg B5;
always @ (A1)
begin
case (A1)
1'b0: B5 = 1'b0;
default: B5 = 1'b0;
endcase
end
reg B6;
always @ (A3)
begin
case (A3)
1'b0: B6 = 1'b0;
default: B6 = 1'b1;
endcase
end
endmodule
6.7.3 Conclusion/s
The main objective of this activity is for the students to enhance their skills in
Verilog programming, creating case statements to be specific. During the
experiment, the students were asked to create several Verilog programs with case
statements. There are three types of case statements which are nested, if-case, and
case-if. The students succeeded in producing the output waveforms which are
correlated to the theoretical results. And thus, this activity was a success.
6.7.5
6.7.6 Rubrics/Rating
Results
(1-5)
Interpretation
Total Score
Mean Score = (Total Score/5)
Percentage Score = (Total
Score/5)*100
Other Comments/Observations: