Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

design a circuit, and model using HDL, that 1) adds two three bit unsigned binar

ID: 3533548 • Letter: D

Question

design a circuit, and model using HDL, that 1) adds two three bit unsigned binary
numbers, 2) includes a flag to determine when a overflow occurs, and 3) includes a flag
indicating whether the resulting sum is an even or odd number. The overflow output should be
connected to a red LED, and the even/odd output connected to a yellow LED. If an overflow is
detected the red LED should turn on. When an even sum occurs the yellow LED should be off
and turn on when a odd sum occurs. The LEDs operate with 2.5 volts; 5 volts will burn them out.
Note you will not model the LED portion of your circuit in HDL, but you will connect the LEDs
and associated circuitry to the schematic diagram of your HDL model.
You should create a test bench and test your design by completing the sums below.
000 + 000
010 + 001
011 + 011
111 + 001
Your inputs and outputs should be defined as follows:
A[2:0], B[2:0] Represent your binary inputs, 0 defines least significant bit
Sum[2,0] Represents the output sum
O Represents the overflow flag, no overflow = 0
P Represents the even/odd flag, even = 0
*NOTE: I need the HDL file and a timing diagram used. Please follow instructions carefully.

Explanation / Answer

module adder (sum,o,p,a,b) ;
input [2:0] a,b;
output [2:0] reg sum;
output reg p,v;
always @(a,b) begin
{o,sum}<=a+b; /* if ov is '1' then overflow occur otherwise not */
if(sum%2==0) /*is no even*/
p<=1'b1;
else
p<=1'b0
end
end module
/*TEST BENCH */
module tb;
wire [2:0] wsum,w0;
wire p,
reg [2:0] wa,wb;
adder a1 (wsum,wo,wp,wa,wb) ;

intial
begin
/* a=000 & b=111 then sum =111 o=0 , p=0 */ comment
wa=3'b0;
wb=3b'7;
#1 $display("wsum=%b,wo=%b,wp=%b",wsum,wo,wp);
/* a=111 & b=111 then sum =110 o=1 , p=1 */ comment
wa=3'b7;
wb=3b'7;
#2 $display("wsum=%b,wo=%b,wp=%b",wsum,wo,wp);
/* a=001 & b=111 then sum =000 o=1 , p=1 */ comment
wa=3'b1;
wb=3b'7;
#3 $display("wsum=%b,wo=%b,wp=%b",wsum,wo,wp);

end

end module
NOte : /* comment */