Professional Documents
Culture Documents
Digital Circuits (2) - CH - 4 - Problems #2
Digital Circuits (2) - CH - 4 - Problems #2
Faculty of Engineering
Electrical Engineering Dep.
2nd Year Communication
Chapter 4
Problems #2
2
4.48: Develop and modify the eight-bit ALU specified in Problem 4.44 so that it has three-
state output controlled by an enable input, En . Write a test bench and simulate the circuit.
3
4.51: Develop and simulate a behavioral model of the ABCD-to-seven-
segment decoder described in Problem 4.9.
module Seven_Segment_Dec (
output reg [6:0] Y,
input [3:0]BCD );
always@(*) module t_Seven_Segment_Dec;
case ( BCD) wire [6:0] Y;
//abcdefg Common Cathod reg [0:3]BCD;
0: Y=7'b1111110; //f Seven_Segment_Dec M(Y ,BCD);
1: Y=7'b0110000; initial
2: Y=7'b1101101; begin
3: Y=7'b1111001; BCD=0;
4: Y=7'b0110011; repeat (10) #100 BCD=BCD+1;
5: Y=7'b1011011; end
6: Y=7'b1011111; endmodule
7: Y=7'b1110000;
8: Y=7'b1111111;
9: Y=7'b1111011;
endcase
endmodule
4
4.52: Using a continuous assignment, develop and simulate a dataflow model of
(a) The four-bit incrementer described in Problem 4.11(a).
(b) The four-bit decrementer described in Problem 4.11(b).
(a): incrementer
module Sim_Incrementer_4_Bit;
module Incrementer_4_Bit ( wire [3:0]Sum;
output [3:0]Sum, output Carry, wire Carry;
input [3:0]A ); reg [3:0] A;
assign {Carry, Sum} = A+1; Incrementer_4_Bit M(Sum, Carry, A);
initial
endmodule
begin
A=4'b0000;
#100 A=4'b0001;
#100 A=4'b0010;
end
endmodule
5
4.52: Using a continuous assignment, develop and simulate a dataflow model of
(a) The four-bit incrementer described in Problem 4.11(a).
(b) The four-bit decrementer described in Problem 4.11(b).
(b): decrementer
module Sim_Incrementer_4_Bit;
module Incrementer_4_Bit ( wire [3:0]Sum;
output [3:0]Sum, output Carry, wire Carry;
input [3:0]A ); reg [3:0] A;
assign {Carry, Sum} = A-1; Incrementer_4_Bit M(Sum, Carry, A);
initial
endmodule
begin
A=4'b0000;
#100 A=4'b0001;
#100 A=4'b0010;
end
endmodule
6
4.53: Develop and simulate a structural model of the decimal adder shown in Fig. 4.14
module Decimal_adder(
output [3:0] Sum, output Output_carry,
input [3:0] A,B, input Carry_in);
wire [3:0] Z, Addend_i;
wire and_1, and_2, K;
assign {K, Z}=A + B + Carry_in;
assign and_1 = Z[3] & Z[2];
assign and_2 = Z[3] & Z[1];
assign Output_carry=and_2 | and_1 | K;
assign Addend_i ={1'b0, Output_carry, Output_carry,1'b0};
assign Sum = Addend_i + Z;
endmodule