VHDL Synthesis
VHDL Synthesis
TEST BENCHES
VHDL – COMBINATIONAL
entity halfsub is
Port ( a,b : in STD_LOGIC; diff,barr : out STD_LOGIC);
end halfsub;
architecture ahalf of halfsub is
component ex_or2
port (a,b: in std_logic; c: out std_logic);
end component;
component and12
port (a,b : in std_logic; c: out std_logic);
end component; CONTI…
component not2
port (a: in std_logic; b: out std_logic);
end component;
signal s: std_logic;
begin
g1 : ex_or2 port map(a,b,diff);
g2 : not2 port map (a,s);
g3 : and12 port map (s,b,barr);
end ahalf;
CONTI…
ex_or2 - COMPONENT
entity ex_or2 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : out STD_LOGIC);
end ex_or2;
assign y = a & b;
endmodule
TEST BENCH – AND GATE
module andgate_tb(); t_a = 1'b0;
wire t_y; t_b = 1'b1;
reg t_a,t_b; #5
t_a = 1'b1;
andgate my_gate ( .a(t_a), t_b = 1'b0;
.b(t_b), .y(t_y)); #5
t_a = 1'b1;
t_b = 1'b1;
initial
#100 $finish;
begin
end
$monitor(t_a,t_b,t_y);
t_a = 1'b0;
t_b = 1'b0; endmodule
#5
FULL ADDER - PRGM WITH WIRE
module fulladder(a, and (x,a,b);
b,c, sum, carry); and (y,b,c);
input a; and (z,c,a);
input b,c; or (carry,a,b,c);
output sum; endmodule
output carry;
wire x,y,z;
xor (sum,a,b,c);
TEST BENCH FOR FULL ADDER -
PRGM WITH WIRE
module fulladder_tb(); c1 = 1'b1;
wire sum1,carry1; #20
reg a1,b1,c1; a1 = 1'b1;
fulladder my_gate ( .a(a1), .b(b1), .c(c1), b1 = 1'b0;
.sum(sum1), .carry(carry1)); c1 = 1'b0;
initial #20
begin a1 = 1'b1;
$monitor(a1,b1,c1,sum1,carry1); b1 = 1'b0;
a1 = 1'b0; c1 = 1'b1;
b1 = 1'b0; #20
c1 = 1'b0; a1 = 1'b1;
#20 b1 = 1'b1;
a1 = 1'b0; c1 = 1'b0;
b1 = 1'b0; #20
c1 = 1'b1; a1 = 1'b1;
#20 b1 = 1'b1;
a1 = 1'b0; c1 = 1'b1;
b1 = 1'b1; #100 $finish;
c1 = 1'b0; end
VERILOG – SEQUENTIAL
module counter(clk, count);
input clk;
output[3:0] count;
reg[3:0] count;
wire clk;
initial
count = 4'b0;
always @( negedge clk )
count[0] <= ~count[0];
always @( negedge count[0] )
count[1] <= ~count[1];
always @( negedge count[1] )
count[2] <= ~count[2];
always @( negedge count[2] )
count[3] <= ~count[3];
endmodule
VERILOG – SEQUENTIAL – TEST BENCH
module counter_tb();
reg clk;
wire[3:0] count;
counter my_counter ( .clk(clk), .count( count ) );
initial
Begin
clk = 0;
#200 $finish;
end
always
begin
#2 clk = ~clk;
end
always @( posedge clk)
$display("Count = %b", count );
endmodule
VHDL
SYNTHESIS
VHDL
LANGUAGE
BASICS
VHDL – DESIGN UNITS
Five kinds of design units.
• Entity declaration.
• Architecture body.
• Configuration declaration.
• Package declaration.
• Package body.
DATA OBJECTS
• Variable.
• Signal.
• File.
DATA TYPES
• Enumeration type.
• Integer type.
• Physical type.
• Floating point type.
• Array type.
• Record type.
• Access type.
• File type.
• Sub type.
DESIGN DESCRIPTION
• A design is described using one or more
concurrent statements in an architecture
body.
• WHAT IS SYNTHESIS?
STYLE
STYLE B
B
CIRCUIT
(MODELS)
STYLE
STYLEDD
STYLE C
STYLE C
SAME BAHAVIOR, DIFFERENT STYLES
• Cell Usage :
• # BELS :2
• # INV :1
• # LUT3 :1
• # IO Buffers :5
• # IBUF :4
• # OBUFT :1
RTL SCHEMATIC
A VARIABLE AS WIRE
entity mux2x1 is begin
Port ( a : in STD_LOGIC; tra := a and sel;
b : in STD_LOGIC; trb := b and (not sel);
sel : in STD_LOGIC; tor := tra or trb;
ena : in STD_LOGIC;
zq : out STD_LOGIC); if ena = '1' then
end mux2x1; zq <= tra;
else
architecture var_wires of zq <= 'Z';
mux2x1 is end if;
begin end process;
process (a,b,sel,ena) end var_wires;
variable
DESIGN STATISTICS FROM
SYNTHESIS REPORT
• Design Statistics
• # IOs :5
• Cell Usage :
• # BELS :2
• # INV :1
• # LUT2 :1
• # IO Buffers :4
• # IBUF :3
• # OBUFT :1
RTL – SCHEMATIC
REFER TEXT BOOK FOR THE REMAINING
TOPICS
• Modeling combinational logic.
• Modeling sequential logic.
• Modeling a flipflop.
• Flipflop with asynchronous preset and clear.
• Flipflop with synchronous preset and clear.
• Modeling a latch.
VERILOG
SYNTHESIS
LOGIC SYNTHESIS
• What is logic synthesis?
Logic synthesis is the process of converting a high-level
description of design into an optimized gate-level
representation.
Logic synthesis uses a standard cell library which have
simple cells, such as basic logic gates like and, or, and nor, or
macro cells, such as adder, muxes, memory, and flip-flops.
Standard cells put together are called technology library.
Normally the technology library is known by the transistor
size (0.18u, 90nm).
TYPICAL DESIGN FLOW
CONTRUCTS NOT SUPPORTED IN SYNTHESIS
CONSTRUCTS SUPPORTS IN SYNTHESIS
CONTRUCTS SUPPORTS IN SYNTHESIS
COMBINATIONAL CIRCUIT MODELING
USING ASSIGN
• // 2. using an if statement
• always @ (sl or a or b or c)
• if (sel == 2’b11)
• d = a;
• else if (sel ==2’b10)
• d = b;
• else
• d = c;
PARALLEL PRIORITY DECODERS USING
SYNTHESIS DIRECTIVE
• // using a synthesis directive
• always @ (sl or a or b or c)
• case (sel) // parallel_case
• 2’b11: d = a;
• 2’b10: d = b;
• default:d = c;
• endcase
D TYPE FLIPFLOP
• // 1. positive edge triggered D flip flop
• always @ (posedge clock)
• q <= d;
• // 2. negative edge triggered D flip flop
• always @ (negedge clock)
• q <= d;
RESETTABLE D TYPE FLIPFLOPS
• // 1. synchronously resettable D flip flop
• always @ (posedge clock)
• if (reset)
• q <= 1’b0;
• else
• q <= d;
• // 2. asynchronously resettable D flip flop
• // (active high async reset)
• always @ (posedge clock or posedge reset)
• if (reset)
• q <= 1’b0;
• else
• q <= d;
• // 3. asynchronously resettable D flip flop
• // (active low reset)
• always @ (posedge clock or negedge reset)
• if (~reset)
• q <= 1’b0;
• else
• q <= d;
DATA ENABLED AND CLOCK GATED FLIPFLOPS