HDL Lecture6
HDL Lecture6
HDL Lecture6
Languages
Technology independent
synthesis
Steps of synthesis
Technology dependent
synthesis
:=== or !==
**
Not synthesisable
operators `time scale and `reset all
directives
Resource sharing
Arithmetical optimization
Implementation selection
Operator reordering
if(sel==2’b00) y=a+b;
else if(sel==2’b01)
y=c+d;
else if(sel==2’b10)
y=e+f; a 00
c 01
else y=g+h; e 10
.... g 11
sel + y
b 00
d 01
f 10
h 11
A
+ B
B
+ Z1 +
C C
+ Z1
A
C
+
D
+ Z2
+ Z2
D
B
Booth multiplier
Possible implementations of
Carry-Ripple Adder
operators
others
Y=a*b+e+f+g a
b
+
e +
f + y
g
е
+
f +
g
+ y
a
b
DESIGN COMPILER
1. A full subtractor has three 1-bit inputs x, y and z (previous borrow) and two
1-bit outputs D (difference) and B (borrow)
2. The logic equations for D and B are as follows:
Select Signal Function
D = x’*y’*z + x’*y*z’ + x*y’*z’ + x*y*z
3’b000 out = a
B = x’*y + x’*z + y*z
3’b001 out = a + b
endmodule
initial
begin
$monitor ($time, "A=%d B=%d A_gt_B=%b A_lt_B=%b
A_eq_B=%b", A, B, A_gt_B, A_lt_B, A_eq_B);
end
initial
begin
#10 A = 3; B = 5;
#10 A = 0; B = 2;
#10 A = 9; B = 0;
#10 A = 7; B = 7;
end
endmodule
Using a case statement design an 8-function ALU that takes 4-bit inputs a and b and a 3-bit input
signal select, and gives a 5-bit output out. The ALU implements the following functions based on
a 3-bit input signal select. Ignore any overflow or underflow bits.
module alu (a, b, select, out);
Select Signal Function
input [3:0] a, b;
input [2:0] select; 3’b000 out = a
output [4:0] out;
reg [4:0] out; 3’b001 out = a + b
always @(select or a or b)
begin 3’b010 out = a – b
case (select)
3'b000 : out = a; 3’b011 out = a/b
3'b001 : out = a + b;
3'b010 : out = a - b; 3’b100 out = a % b
3'b011 : out = a/b; (remainder)
3'b100 : out = a % b;
3'b101 : out = a <<1; 3’b101 out = a << 1
3'b110 : out = a >>1;
3'b111 : out = (a > b); 3’b110 out = a >> 1
default : out = 5'bxxxxx;
endcase 3’b111 out = (a > b)
end (magnitude
endmodule compare)