VLSI
VLSI
VLSI
Step 1 :
Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start
Programs Xilinx ISE (8.1i).
SOURCE
WINDOW
WORK
SPACE
TRANSCRIPT
PROCESS
WINDOW
Step 2
Select Device. Use the pull-down arrow to select the Value for each Property Name. Click
in the field to access the pull-down list.
Step 3:
VHDL
MODULE
Step 4:
Step 5
Check Syntax
Run the Check syntax Process window synthesizecheck syntax >, and remove
errors if present.
Step 6
Select the desired parameters for simulating your design. In this case combinational
circuit and Simulation time.
Step 7:
FOR
SIMULATION
Click on test bench file. Test bench file will open in main window. Assign all the
signals and save File. From the source of process window. Click on Simulate
Behavioral Model in Process window.
Verify your design in wave window by seeing behaviour of output signal with respect
to input signal. Close the ISE simulator window
SIMULATED
OUTPUT
Step 8:
SYNTHESIS
SYNTHESIS
COMPLETED
SUCCESSFULLY
Step 9:
PIN
ASSIGNMENT
10
Step 10:
Implementing a Design
Once synthesis is complete, you can place and route your design to fit into a Xilinx
device, and you can also get some post place-and-route timing information about the
design. The implementation stage consists of taking the synthesized netlist through
translation, mapping, and place and route.
To check your design as it is implemented, reports are available for each stage in the
implementation process. Use the Xilinx Constraints Editor to add timing and location
constraints for the implementation of your design. This procedure runs you through the
basic flow for implementation.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
IMPLEMENTATION
DONE
Step 11:
Step 12
11
BOUNDARY
SCAN MODE
12
Step 13:
Step 14:
Before downloading make sure that Protoboard is connected to PC's parallel port with
the cable provided and power to the Protoboard is ON.
Apply input through DIP Switches, output is displayed on LEDs
Configuration through PROM: Generating PROM file:
FPGA can also be configured in Master Serial Mode through PROM. For this you need
to program the PROM through a .mcs file.
13
Right click on Generate PROM,ACE or JTAG file -> and Say RUN or Double click
on Generate PROM,ACE or JTAG file
Specify the desired parameters of the PROM on board and say ADD then FINISH
14
Similar to Step 12.Initialize chain through iMPACT. PROM and FPGA devices on
board are seen .Assign the generated mcs file and bit file as desired.
Right click the PROM symbol and say PROGRAM.
15
Now, whenever the board is powered on in master serial mode, FPGA is configured
through PROM automatically.
16
Expt . No: 1
Full Adder
Date :
Aim:
Realize the full adder using Verilog.
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
A combinational circuit that performs the addition of three bits is called a half-adder. This circuit
needs three binary inputs and produces two binary outputs. One of the input variables designates the
augend and other designates the addend. Mostly, the third input represents the carry from the previous
lower significant position. The output variables produce the sum and the carry.
The simplified Boolean functions of the two outputs can be obtained as below:
Sum S = x + y + z
Carry C = xy + xz + yz
Where x, y & z are the two input variables.
Procedure:
1.
2.
3.
4.
The full-adder circuit is designed and the Boolean function is found out.
The Verilog Module Source for the circuit is written.
It is implemented in Model Sim and Simulated.
Signals are provided and Output Waveforms are viewed.
Program:
//Gate-level description of Full Adder using two Half Adder
//Description of Half Adder
module halfadder(s,co,x,y);
input x,y;
output s,co;
//Instatiate primitive gates
xor (s,x,y);
and (co,x,y);
endmodule
//Description of Full Adder
module fulladder(s,co,x,y,ci);
input x,y,ci;
17
output s,co;
wire s1,d1,d2; //Outputs of first XOR and AND gates
//Instantiate Half Adder
halfadder ha_1(s1,d1,x,y);
halfadder ha_2(s,d2,s1,ci);
or or_gate(co,d2,d1);
endmodule
//Stimulus for testing Full Adder
module simulation;
reg x,y,ci;
wire s,co;
//Instantiate Full Adder
fulladder fa_test(s,co,x,y,ci);
initial
begin
x=1'b0; y=1'b0; ci=1'b0;
#100 x=1'b0; y=1'b0; ci=1'b1;
#100 x=1'b0; y=1'b1; ci=1'b0;
#100 x=1'b0; y=1'b1; ci=1'b1;
#100 x=1'b1; y=1'b0; ci=1'b0;
#100 x=1'b1; y=1'b0; ci=1'b1;
#100 x=1'b1; y=1'b1; ci=1'b0;
#100 x=1'b1; y=1'b1; ci=1'b1;
end
endmodule
Diagram:
18
Waveform:
Waveform:
Result:
Thus the logic circuit for the Full adder is designed in Verilog HDL and the output is
verified.
19
Expt . No: 2
Date :
Aim:
To Design Ripple Carry Adder using Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
The n-bit adder built from n one bit full adders is known as ripple carry adder because of the
carry is computed. The addition is not complete until n-1th adder has computed its Sn-1 output; that results
depends upon ci input, n and so on down the line, so the critical delay path goes from the 0-bit inputs up
through cis to the n-1 bit.(We can find the critical path through the n-bit adder without knowing the exact
logic in the full adder because the delay through the n-bit adder without knowing the exact logic in the full
adder because the delay through the n-bit carry chain is so much longer than the delay from a and b to s).
The ripple-carry adder is area efficient and easy to design but it is when n is large.It can also be called as
cascaded full adder.
The simplified Boolean functions of the two outputs can be obtained as below:
Sum si = ai xor bi xor ci
Carry ci+1 = aibi +bi ci +ai ci
Where x, y & z are the two input variables.
Procedure:
1The full-adder circuit is designed and the Boolean function is found out.
2.The Verilog Module Source for the circuit is written.
3.It is implemented in Model Sim and Simulated.
4.Signals are provided and Output Waveforms are viewed.
20
Circuit diagram:
module ripplecarryadder(s,cout,a,b,cin);
output[7:0]s;
output cout;
input[7:0]a,b;
input cin;
wire c1,c2,c3,c4,c5,c6,c7;
fulladd fa0(s[0],c1,a[0],b[0],cin);
fulladd fa1(s[1],c2,a[1],b[1],c1);
fulladd fa2(s[2],c3,a[2],b[2],c2);
fulladd fa3(s[3],c4,a[3],b[3],c3);
fulladd fa4(s[4],c5,a[4],b[4],c4);
fulladd fa5(s[5],c6,a[5],b[5],c5);
fulladd fa6(s[6],c7,a[6],b[6],c6);
fulladd fa7(s[7],cout,a[7],b[7],c7);
endmodule
module fulladd(s,cout,a,b,cin);
output s,cout;
input a,b,cin;
wire s1,c1,c2;
xor(s1,a,b);
xor(s,s1,cin);
and(c1,a,b);
and(c2,s1,cin);
xor(cout,c2,c1);
endmodule
21
RESULT:
Thus the logic circuit for the Ripple carry adder is designed in Verilog HDL and the output is
verified.
22
Expt . No: 3
Date :
Aim:
To design Carry Save Adder using Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
Carry save adders are suitable when three or more operands are to be added, as in
some multiplication schemes. In this adder a separate sum and carry bit is generated for
partial results , except when the last operand is added. For example, when three numbers are
added, the first two are added using a carry save adder. The partial result is two numbers
corresponding to the sum and the carry .The last operand is added using a second carry save
adder stage. The results become the sum and carry numbers. Thus a carry save adder reduces
the number of operands by one for each adder stage. Finally the sum and carry are added
using an adder with carry propagation- for example carry look ahead adder.
Procedure;
1.
2.
3.
4.
fulladder a3(s2,c5,a[2],b[2],e);
fulladder a4(s1,c4,a[3],b[3],e);
fulladder a5(d[1],c3,c7,s3,e);
fulladder a6(d[2],c2,c6,c3,s2);
fulladder a7(d[3],c1,c5,s1,c2);
fulladder a8(d[4],c0,c4,c1,e);
endmodule
module fulladder(s,c, x,y,z);
output s,c;
input x,y,z;
xor (s,x,y,z);
assign c = ((x & y )|(y & z)|( z & x)) ;
endmodule
Logic Diagram:
24
RESULT:
Thus the logic circuit for the carry save adder is designed in Verilog HDL and the output is
verified.
25
Expt . No: 4
Date :
Aim:
To design a Carry Select Adder using Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
Carry-select adders use multiple narrow adders to create fast wide adders. A
carry-select adder provides two separate adders for the upper words, one for each
possibility. A MUX is then used to select the valid result. Consider an 8-bit adder that
is split into two 4-bit groups. The lower-order bits and are fed into the 4_bit adder l
to produce the sum bits and a carry-out bit .the higher order bits and are used as
input to one 4_bit adder and and
are used as input of the another 4_bit
adder. Adder U0 calculates the sum with a carry-in of C3=0.while U1 does the same
only it has a carry-in value of C3=1.both sets of results are used as inputs to an array
of 2:1 MUXes .the carry bit from the adder L is used as the MUX select signal. If =0
then the results U0 are sent to the output, while a value of =1 selects the results of
U1 for
. The carry-out bit is also selected by the MUX array.
Procedure:
1. The carry-select adder circuit is designed and the Boolean function is found out.
2. The Verilog Module Source for the circuit is written.
3. It is implemented in Model Sim and Simulated.
4. Signals are provided and Output Waveforms are viewed.
fulladder f1(s[0],c0,x[0],y[0],z);
fulladder f2(s[1],c1,x[1],y[1],c0);
fulladder f3(s[2],c2,x[2],y[2],c1);
fulladder f4(s[3],c3,x[3],y[3],c2);
fulladder f5(s4,c4,x[4],y[4],c3);
fulladder f6(s5,c5,x[5],y[5],c4);
fulladder f7(s6,c6,x[6],y[6],c5);
fulladder f8(s7,c7,x[7],y[7],c6);
fulladder f9(s8,c8,x[8],y[8],~c3);
fulladder f10(s9,c9,x[9],y[9],c8);
fulladder f11(s10,c10,x[10],y[10],c9);
fulladder f12(s11,c11,x[11],y[11],c10);
muxer mu1(m[1],s4,s8,c3);
muxer mu2(m[2],s5,s9,c3);
muxer mu3(m[3],s6,s10,c3);
muxer mu4(m[4],s7,s11,c3);
muxer mu5(m[5],c7,c11,c3);
endmodule
module fulladder (s,c,x,y,z);
output s,c;
input x,y,z;
xor (s,x,y,z);
assign c = ((x & y) | (y & z) | (z & x));
endmodule
module muxer (m,s1,s2,c);
output m;
input s1,s2,c;
wire f,g,h;
not (f,c);
and (g,s1,c);
and (h,s2,f);
or (m,g,h);
endmodule
27
Logic Diagram:
y11 x11 y10 x10 y9 x9 y8 x8
c11
y7 x7
C3=1
4-bit ADDER U1
s11
s10
s9
s8
m5
MUX
MUX
MUX
4-bit ADDER U0
s7
m4
m3
m2
MUX
m1
y5 x5 y4 x4
C3=0
c7
y3
MUX
y6 x6
s6
x3
s5
y2 x2
C3
s4
y1 x1
4-bit ADDER
s3
28
s2
s1
s0
y0 x0
Z=
1
RESULT:
Thus the logic circuit for the carry select adder is designed in Verilog HDL and the output is verified.
29
Expt . No: 5
Date :
Aim:
To design a BCD adder circuit using Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
A BCD adder is the circuit that adds two BCD digits in parallel and produces a sum digit also in
BCD. The input digit does not exceed 9,the output sum cannot greater than 9+9+1=19, the 1 in the sum
being an input carry. Suppose we apply two decimal digits, together with the input carry, are first added in
the top 4-bit binary adder to produce the binary sum. When the output carry is equal to zero, nothing is
added in the binary sum . When it is equal to one, binary 0110 is added to binary sum through the bottom
4-bit binary adder. Output generated from bottom binary adder can be ignored.
The output carry can be expressed in Boolean function
k = c4 + s3s2 + s3s1
Procedure:
1.
2.
3.
4.
The BCD adder circuit is designed and the Boolean function is found out.
The VHDL program source code for the circuit is written.
It is implemented in Model Sim and Simulated.
Signals are provided and Output Waveforms are viewed.
b3 a3 c3
b2 a2
c2
b1 a1
c1
b0 a0 c
c4
FA4
4
k
FA3
4
s3
d=0
e3
FA2
s2
FA8
s7
31
FA1
s1
e2
e1
FA7
FA6
s6
s5
s0
d=0
e=0
FA5
s4
Waveform:
32
RESULT:
Thus the logic circuit for the BCD adder is designed in Verilog HDL and the output is verified.
33
Expt . No: 6
Design of Multiplexers
Date :
Aim:
Design a 4 to 1 multiplexer circuit in Verilog.
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
A digital multiplexer is a combinational circuit that selects binary information from one of many
input lines and directs it to a single output line. Multiplexing means transmitting a large number of
information units over a smaller number of channels or lines. The selection of a
particular input line is controlled by a set of selection lines. Normally, there are 2 n input lines and n
selection lines whose bit combinations determine which input is selected. A multiplexer is also called a
data selector, since it selects one of many inputs and steers the binary information to the output lines.
Multiplexer ICs may have an enable input to control the operation of the unit. When the enable input is in
a given binary state (the disable state), the outputs are disabled, and when it is in the other state (the enable
state), the circuit functions as normal multiplexer. The enable input (sometimes called strobe) can be used
to expand two or more multiplexer ICs to digital multiplexers with a larger number of inputs.
The size of the multiplexer is specified by the number 2n of its input lines and the single output line. In
general, a 2n to 1 line multiplexer is constructed from an n to 2n decoder by adding to it 2n input
lines, one to each AND gate. The outputs of the AND gates are applied to a single OR gate to provide the
1 line output.
Procedure:
1.
2.
3.
4.
The multiplexer circuit is designed and the Boolean function is found out.
The Verilog Module Source for the circuit is written.
It is implemented in Model Sim and Simulated.
Signals are provided and Output Waveforms are viewed.
Truth table:
INPUT
s[1]
0
0
1
1
OUTPUT
s[0]
0
1
0
1
y
D[0]
D[1]
D[2]
D[3]
34
Logic Diagram:
4 to 1 Multiplexer:
Waveform:
36
Waveform of multiplexers
RESULT:
Thus the multiplexer is designed in Verilog HDL and the output is verified.
37
Expt . No: 7
Design of Multipliers
Date :
Aim:
To design an array multiplier circuit for 4 inputs and 8 outputs using VHDL.
Apparatus required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
Binary multiplication can be accomplished by several approaches. The approach presented
here is realized entirely with combinational circuits. Such a circuit is called an array multiplier.
The term array is used to describe the multiplier because the multiplier is organized as an array
structure. Each row, called a partial product, is formed by a bit-by-bit multiplication of each operand.
For example, a partial product is formed when each bit of operand a is multiplied by b0,
resulting in a3b0, a2b0,a1b0, a0b0. The binary multiplication table is identical to the AND truth table.
Each product bit {o(x)}, is formed by adding partial product columns. The product equations,
including the carry-in {c(x)}, from column c(x-1), are (the plus sign indicates addition not OR).
Each product term, p(x), is formed by AND gates and collection of product terms needed for
the multiplier. By adding appropriate p term outputs, the multiplier output equations are realized, as
shown in figure.
4X 4 Array Multiplier:
a3b3
a3
a2
a1
b3
b2
b1
a3b0 a2b0 a1b0
a3b1 a2b1 a1b1 a0b1
a3b2 a2b2 a1b2 a0b2
a2b3 a1b3 a0b3
o7
a0b0 = p0
a1b0 = p1
a0b1 = p2
a2b0 = p3
o6
o5
o4
o3
o2
a0
b0
a0b0
o1
a1b2 = p8
a0b3 = p9
a3b1 = p10
a2b2 = p11
38
a1b1 = p4
a0b2 = p5
a3b0 = p6
a2b1 = p7
a1b3 = p12
a3b2 = p13
a2b3 = p14
a3b3 = p15
Truth Table:
AXB
Program:
module mmmm(m,a,b);
input [3:0]a;
input [3:0]b;
output [7:0]m;
wire [15:0]p;
wire [12:1]s;
wire [12:1]c;
and(p[0],a[0],b[0]);
and(p[1],a[1],b[0]);
and(p[2],a[0],b[1]);
and(p[3],a[2],b[0]);
and(p[4],a[1],b[1]);
and(p[5],a[0],b[2]);
and(p[6],a[3],b[0]);
and(p[7],a[2],b[1]);
and(p[8],a[1],b[2]);
and(p[9],a[0],b[3]);
and(p[10],a[3],b[1]);
and(p[11],a[2],b[2]);
and(p[12],a[1],b[3]);
and(p[13],a[3],b[2]);
and(p[14],a[2],b[3]);
and(p[15],a[3],b[3]);
39
half ha1(s[1],c[1],p[1],p[2]);
half ha2(s[2],c[2],p[4],p[3]);
half ha3(s[3],c[3],p[7],p[6]);
full fa4(s[4],c[4],p[11],p[10],c[3]);
full fa5(s[5],c[5],p[14],p[13],c[4]);
full fa6(s[6],c[6],p[5],s[2],c[1]);
full fa7(s[7],c[7],p[8],s[3],c[2]);
full fa8(s[8],c[8],p[12],s[4],c[7]);
full fa9(s[9],c[9],p[9],s[7],c[6]);
half ha10(s[10],c[10],s[8],c[9]);
full fa11(s[11],c[11],s[5],c[8],c[10]);
full fa12(s[12],c[12],p[15],s[5],c[11]);
buf(m[0],p[0]);
buf(m[1],s[1]);
buf(m[2],s[6]);
buf(m[3],s[9]);
buf(m[4],s[10]);
buf(m[5],s[11]);
buf(m[6],s[12]);
buf(m[7],c[12]);
endmodule
module half(s,co,x,y);
input x,y;
output s,co;
//Instatiate primitive gates
xor (s,x,y);
and (co,x,y);
endmodule
//Description of Full Adder
module full(s,co,x,y,ci);
input x,y,ci;
output s,co;
wire s1,d1,d2; //Outputs of first XOR and AND gates
//Instantiate Half Adder
half ha_1(s1,d1,x,y);
half ha_2(s,d2,s1,ci);
or or_gate(co,d2,d1);
endmodule
40
Logic Diagram:
P14 P13
P15
P11,P10
FA
P7 P6
FA
P12
P4 P3
P2 P1
HA
HA
HA
FA
FA
P0
P8
FA
P9
FA
O7
O6
FA
O5
FA
O4
HA
O3
O2
O1
O0
Wave Form:
RESULT:
Thus an array multiplier circuit for 4 inputs and 8 outputs using VHDL is designed and the output
is verified.
41
Expt . No: 8
Design of Multipliers
Date :
Aim:
To design the Braun multiplier in verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
The entire partial product A.bk are computed in parallel, and then collected through a cascaded
array of carry save order. At the bottom of the array, an adder is used to convert the carry save from the
required form of output.
Completion time is fixed by the depth of the array, and by the carry propagation characteristics
of the adder. In multiplier is suited only to positive operands.
4 X 4 Braun Multiplier:
a3b3
a3
a2
a1
b3
b2
b1
a3b0 a2b0 a1b0
a3b1 a2b1 a1b1 a0b1
a3b2 a2b2 a1b2 a0b2
a2b3 a1b3 a0b3
o7
a0b0 = p0
a1b0 = p1
a0b1 = p2
a2b0 = p3
a1b1 = p4
a0b2 = p5
a3b0 = p6
a2b1 = p7
o6
o5
o4
o3
o2
a0
b0
a0b0
o1
a1b2 = p8
a0b3 = p9
a3b1 = p10
a2b2 = p11
a1b3 = p12
a3b2 = p13
a2b3 = p14
a3b3 = p15
42
Truth Table:
A
0
0
1
1
B
0
1
0
1
AXB
0
0
0
1
Logic Diagram:
P14 P13
P15
P11,P10
FA
P7 P6
FA
P12
P4 P3
P2 P1
HA
HA
HA
FA
FA
P0
P8
FA
P9
FA
O7
O6
FA
O5
FA
O4
HA
O3
O2
Wave Form:
43
O1
O0
RESULT:
Thus an Braun multiplier in verilog HDL is designed and the output is verified.
44
Expt . No: 9
Design of Counters
Date :
Aim:
To realize an asynchronous ripple counter in Verilog
Apparatus required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
In a ripple counter, the flip-flop output transition serves as a source for triggering other
flip-flops. In other words, the Clock Pulse inputs of all flip-flops (except the first) are triggered not by the
incoming pulses, but rather by the transition that occurs in other flip-flops. A binary ripple counter
consists of a series connection of complementing flip-flops (JK or T type), with the output of each flipflop connected to the Clock Pulse input of the next higher-order flip-flop. The flip-flop holding the LSB
receives the incoming count pulses. All J and K inputs are equal to 1. The small circle in the Clock Pulse
/Count Pulse indicates that the flip-flop complements during a negative-going transition or when the
output to which it is connected goes from 1 to 0. The flip-flops change one at a time in rapid succession,
and the signal propagates through the counter in a ripple fashion. A binary counter with reverse count is
called a binary down-counter. In binary down-counter, the binary count is decremented by 1 with every
input count pulse.
Procedure:
1.
2.
3.
4.
//Description of Flip-Flop
module FF(Q,CLK,RESET);
output Q;
input CLK,RESET;
reg Q;
always @(negedge CLK or negedge RESET)
if(~RESET)
Q=1'b0;
else
Q=(~Q);
endmodule
//Stimulus for testing Ripple Counter
module simulation;
reg COUNT;
reg RESET;
wire A0,A1,A2,A3;
//Instantiate Ripple Counter
ripplecounter rc_t(A0,A1,A2,A3,COUNT,RESET);
always
#5 COUNT=~COUNT;
initial
begin
COUNT=1'b0;
RESET=1'b0;
#10 RESET=1'b1;
end
endmodule
LOGIC DIAGRAM:
46
TRUTH TABLE:
COUNT
A0
A1
A2
A3
10
11
12
13
14
15
47
LOGIC DIAGRAM:
48
TRUTH TABLE:
COUNT
A0
A1
A2
A3
10
49
50
LOGIC DIAGRAM:
TRUTH TABLE:
COUNT
A0
A1
A2
A3
10
11
12
51
52
RESULT:
Thus the ripple counter is designed in Verilog HDL and the output is verified.
53
Expt . No: 10
Design of Counters
Date :
AIM:
To realize a ring counter in Verilog and VHDL.
Apparatus required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
A ring counter is a circular shift register with only one flip-flop being set at ay particular time; all
others are cleared. The single bit is shifted from one flip-flop tot the other to produced the
sequence of timing signals.
Procedure:
1.
2.
3.
4.
54
Logic Diagram:
Truth Table:
Waveforms
55
RESULT:
Thus the ring counter is designed in Verilog HDL and the output is verified.
56
Expt . No: 11
Date :
Aim:
Realize the parity generator in Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator;
Theory:
Random numbers for polynomial equations are generated by using the shift register circuit. The
random number generator is nothing but the Linear Feedback Shift Register(LFSR). The shift registers are
very helpful and versatile modules that facilitate the design of many sequential circuits whose design may
otherwise appear very complex. In its simplest form, a shift register consists of a series of flip-flops
having identical interconnection between two adjacent flip-flops. Two such registers are shift right
registers and the shift left registers. In the shift right register, the bits stored in the flip-flops shift to the
right when shift pulse is active. Like that, for a shift left register, the bits stored in the flip-flops shift left
when shift pulse is active. In the shift registers, specific patterns are shifted through the register. There are
applications where instead of specific patterns, random patterns are more important. Shioft registers can
also built to generate such patterns , which are pseudorandom in nature. Called Linear Feedback Shift
Registers (LFSRs), these are very useful for encoding and decoding the error control codes. LFSRs used
as a generators of pseudorandom sequences have proved externally useful in the area of testing of VLSI
chips.
Circuit diagram:
57
Verilog code
module (y,clk);
output y;
input clk;
wire [1:0]q;
wire a;
dff df1(q[0],a,clk);
dff df2(q[1],q[0],clk;
dff df3(y,q[1],clk);
xor(a,y,q[1]);
endmodule
module dff(q,d,clk);
output q;
input clk;
input d,clk;
reg q=1b0;
always@(posedge clk)
q=#5d;
endmodule
Waveform of prbs:
58
Testbenchwaveform of prbs :
RESULT:
Thus the parity generator is designed in Verilog HDL and the output is verified.
59
Expt . No: 12
Date :
Design of Accumulator
Aim:
Realize the accumulator in Verilog HDL
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator
Theory:
An accumulator differs from a counter in the nature of the operands of the add and
subtract operation:
In a counter, the destination and first operand is a signal or variable and the other
operand is a constant equal to 1: A <= A + 1.
In an accumulator, the destination and first operand is a signal or variable, and the
second operand is either:
A signal or variable: A <= A + B
A constant not equal to 1: A <= A + Constant
An inferred accumulator can be up, down or updown. For an updown accumulator, the
accumulated data may differ between the up and down mode:
...
if updown = '1' then
a <= a + b;
else
a <= a - c;
Procedure:
1.
2.
3.
4.
Program:
module accum (C, CLR, D, Q);
input C, CLR;
input [3:0] D;
output [3:0] Q;
reg [3:0] tmp;
always @(posedge C or posedge CLR)
begin
if (CLR)
tmp = 4'b0000;
60
else
tmp = tmp + D;
end
assign Q = tmp;
endmodule
Circuit diagram:
61
Testbenchwaveform of accumulator:
RESULT:
Thus the logic circuit for the Accumulator is designed in Verilog HDL and the output is
verified.
62
Expt . No: 13
Date :
Design of Decoder
Aim:
Realize the 3 to 8 Decoder in Verilog HDL.
Apparatus Required:
Synthesis tool: Xilinx ISE.
Simulation tool: ModelSim Simulator.
Theory:
A decoder is a combinational circuit that converts binary information from n input lines to a
maximum of 2n unique output lines. It performs the reverse operation of the encoder. If the n-bit decoded
information has unused or dont-care combinations, the decoder output will have fewer than 2n outputs.
The decoders are represented as n-to-m line decoders, where m 2n. Their purpose is to generate the 2n
(or fewer) minterms of n input variables. The name decoder is also used in conjunction with some code
converters such as BCD-to-seven-segment decoders. Most, if not all, IC decoders include one or more
enable inputs to control the circuit operation. A decoder with an enable input can function as a demultiplexer.
Procedure:
1.
2.
3.
4.
The decoder circuit is designed and the Boolean function is found out.
The Verilog Module Source for the circuit is written.
It is implemented in Model Sim and Simulated.
Signals are provided and Output Waveforms are viewed.
module my_decodr(d,x);
output [0:7] d;
input [0:2] x;
wire [0:2] temp;
not n1(temp[0],x[0]);
not n2(temp[1],x[1]);
not n3(temp[2],x[2]);
and a0(d[0],temp[0],temp[1],temp[2]);
and a1(d[1],temp[0],temp[1],x[2]);
and a2(d[2],temp[0],x[1],temp[2]);
and a3(d[3],temp[0],x[1],x[2]);
and a4(d[4],x[0],temp[1],temp[2]);
and a5(d[5],x[0],temp[1],x[2]);
and a6(d[6],x[0],x[1],temp[2]);
and a7(d[7],x[0],x[1],x[2]);
endmodule
63
Logic diagram:
Truth Table:
INPUTS
OUTPUTS
DIN
D0
D1
D2
D3
64
Waveform:
RESULT:
Thus the logic circuit for the 3 to 8 decoder is designed in Verilog HDL and the output is verified.
65