





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Name
23 October 2001
Alias
Problem 1 (10 pts)
Problem 2 (30 pts)
Problem 3 (10 pts)
Problem 4 (10 pts)
Problem 5 (10 pts)
Problem 6 (10 pts)
Problem 7 (10 pts)
Problem 8 (10 pts)
Good Luck!
generate and propagate signals. Hint: This is straight from the notes. (10 pts)
module cla_3(sum,a,b); input [2:0] a, b; output [3:0] sum;
wire [2:0] g, p, carry;
assign carry[0] =
assign carry[1] =
assign carry[2] =
assign sum[3] =
cla_slice s0(sum[0],g[0],p[0],a[0],b[0],carry[0]); cla_slice s1(sum[1],g[1],p[1],a[1],b[1],carry[1]); cla_slice s2(sum[2],g[2],p[2],a[2],b[2],carry[2]);
endmodule
Hint: It has to do with the way i is declared. (10 pts)
module iloop(z,a); input [31:0] a; output z;
reg [4:0] i; reg s, z;
initial begin s = 0; for(i=0; i<32; i=i+1) s = s | a[i]; z = !s; end
endmodule
(a) What kind of adders are these?
(b) How do the speed of the two adders compare?
(c) Compare the amount of hardware that the adders will synthesize into. How is the second adder penny wise and £ foolish?
module add_1(sum,a,b,clk); input [31:0] a,b; input clk; output sum; reg [31:0] sum; integer i; reg carry;
always @( posedge clk ) begin carry = 0;
for(i=0; i<31; i=i+1) begin
sum[i] = ~a[i] & ~b[i] & carry | ~a[i] & b[i] & ~carry | a[i] & ~b[i] & ~carry | a[i] & b[i] & carry;
carry = a[i] & b[i] | b[i] & carry | a[i] & carry;
end end
endmodule
module add_2(sum,a,b,clk); input [31:0] a,b; input clk; output sum; reg [31:0] sum; integer i; reg carry;
always @( posedge clk ) begin i = i + 1; if( i == 32 ) begin carry = 0; i = 0; end
sum[i] = ~a[i] & ~b[i] & carry | ~a[i] & b[i] & ~carry | a[i] & ~b[i] & ~carry | a[i] & b[i] & carry;
carry = a[i] & b[i] | b[i] & carry | a[i] & carry; end
endmodule
overflowed, and fix the last assignment. (10 pts)
module sums();
reg [3:0] a, b, c; reg [5:0] d;
initial begin
a = 4’b0101; b = 4’b0001; c = a + b;
// Unsigned decimal: c = Overflow?
// Signed decimal: c = Overflow?
a = -6; b = 4’b0001; c = a + b;
// Unsigned decimal: c = Overflow?
// Signed decimal: c = Overflow?
a = -6; b = 4’b0001; c = a + b;
// Unsigned decimal: c = Overflow?
// Signed decimal: c = Overflow?
a = 4’b1101; b = 4’b1100; c = a + b;
// Unsigned decimal: c = Overflow?
// Signed decimal: c = Overflow?
// Suppose c and d are used for signed quantities. // Fix the assignment below. d = c;
end
endmodule
module to_str(x,s,a,b); input [1:0] s; input a, b; output x;
assign x = s == 2? a : b;
endmodule