Professional Documents
Culture Documents
2021
SEQUENCE DETECTOR
Aim: To write a Verilog HDL to model a mealy fsm to detect the sequence 0101.
Hardware Requirements:
i) Desktop PC
Software Requirements:
i) Xilinx ISE 14.7
ii)ISim Simulator
Theory:
A sequence detector is a sequential state machine. In a Moore machine, output depends only
on the present state and not dependent on the input (x). Hence in the diagram, the output is
written with the states. In a mealy machine, output depends both on the present state and on
the input (x).
Program:
module seqdetetct(
input clk,
input reset,
input x,
reg y
);
parameter s0 = 2'b00;
parameter s1 = 2'b01;
parameter s2 = 2'b10;
parameter s3 = 2'b11;
begin
if(reset)
begin
p_s<=s0;
yout<=1'b0;
end
else
begin
p_s<=n_s;
yout<=y;
end
end
always@(p_s,x)
begin
case(p_s)
s0:if(x)
begin
n_s<=s0;
y<=1'b0;
end
else
begin
n_s<=s1;
y<=1'b0;
end
s1:if(x)
begin
n_s<=s2;
y<=1'b0;
end
else
begin
n_s<=s1;
y<=1'b0;
end
s2:if(x)
begin
n_s<=s0;
y<=1'b0;
end
else
begin
n_s<=s3;
y<=1'b0;
end
s3:if(x)
begin
n_s<=s2;
y<=1'b1;
end
else
begin
n_s<=s1;
y<=1'b0;
end
endcase
end
endmodule
Output:
* Design Summary *
==================================================================
=======
------------------------------
# BELS :3
# INV :1
# LUT3 :2
# FlipFlops/Latches :3
# FDC :3
# Clock Buffers :1
# BUFGP :1
# IO Buffers :4
# IBUF :2
# OBUF :2
---------------------------
IO Utilization:
Number of IOs: 5
---------------------------
---------------------------
==================================================================
=======
Timing Report
Clock Information:
------------------
-----------------------------------+------------------------+-------+
-----------------------------------+------------------------+-------+
clk | BUFGP |3 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -3
Timing Details:
---------------
==================================================================
=======
-------------------------------------------------------------------------
Gate Net
---------------------------------------- ------------
----------------------------------------
==================================================================
=======
-------------------------------------------------------------------------
Source: x (PAD)
Gate Net
---------------------------------------- ------------
----------------------------------------
==================================================================
=======
-------------------------------------------------------------------------
Destination: y (PAD)
Gate Net
---------------------------------------- ------------
----------------------------------------
-------------------------------------------------------------------------
Source: x (PAD)
Destination: y (PAD)
Data Path: x to y
Gate Net
---------------------------------------- ------------
----------------------------------------
==================================================================
=======
--------------------------
---------------+---------+---------+---------+---------+
| Src:Rise| Src:Fall| Src:Rise| Src:Fall|
---------------+---------+---------+---------+---------+
clk | 1.473| | | |
---------------+---------+---------+---------+---------+
==================================================================
=======
-->
module vending(
input clk,
input reset,
input x,
reg y
);
parameter s0 = 2'b00;
parameter s1 = 2'b01;
parameter s2 = 2'b10;
parameter s3 = 2'b11;
begin
if(reset)
begin
p_s<=s0;
yout=1'b0;
end
else
begin
p_s<=n_s;
yout=y;
end
end
always@(p_s,x)
begin
case(p_s)
s0:if(x)
begin
n_s<=s2;
y=1'b0;
end
else if(x==0)
begin
n_s<=s1;
y=1'b0;
end
else
begin
n_s<=s0;
y=1'b0;
end
s1:if(x)
begin
n_s<=s3;
y=1'b1;
end
else if(x==0)
begin
n_s<=s2;
y=1'b0;
end
else
begin
n_s<=s1;
y=1'b0;
end
s2:if(x)
begin
n_s<=s3;
y=1'b1;
end
else if(x==0)
begin
n_s<=s3;
y=1'b1;
end
else
begin
n_s<=s2;
y=1'b0;
end
s3:n_s<=s0;
endcase
end
endmodule
Output:
* Design Summary *
==================================================================
=======
IO Utilization:
Number of IOs: 5
Number of bonded IOBs: 5 out of 200 2%
IOB Flip Flops/Latches: 2
---------------------------
Partition Resource Summary:
---------------------------
---------------------------
==================================================================
=======
Timing Report
Timing Summary:
---------------
Speed Grade: -3
Result: Thus, a newspaper vending machine for the design specification wad designed and its
functionality was verified.
Ex. No. 10 Date:14.07.2021
IMPLEMENTATION OF MEMORY ELEMENTS – ROM / RAM
Aim: To write a Verilog HDL to design a 4x8 bit ROM and a 4x8 bit RAM.
Hardware Requirements: Desktop PC
Software Requirements:
i) Xilinx ISE 14.7
ii)ISim Simulator
Theory:
ROM (Read Only Memory):
Figure 1 shows the block diagram of a 4X8-Bit ROM. This module has 2 bits address and 8
bits data. Read is the control signal used to retrieve the content of ROM.
module rom(
input cs,
);
reg [7:0]data[0:3];
always@(negedge cs)
begin
data[0]<=8'b01010101;
data[1]<=8'b00000000;
data[2]<=8'b11111111;
data[3]<=8'b10010010;
end
endmodule
Output:
=================================================================
========
------------------------------
# BELS :3
# INV :1
# LUT2 :2
# FlipFlops/Latches :8
# FD_1 :8
# Clock Buffers :1
# BUFGP :1
# IO Buffers : 10
# IBUF :2
# OBUF :8
---------------------------
IO Utilization:
Number of IOs: 11
---------------------------
---------------------------
---------------------------
=================================================================
========
Timing Report
Clock Information:
------------------
-----------------------------------+------------------------+-------+
-----------------------------------+------------------------+-------+
cs | BUFGP |8 |
-----------------------------------+------------------------+-------+
----------------------------------------
Timing Summary:
---------------
Speed Grade: -3
Timing Details:
---------------
=================================================================
========
-------------------------------------------------------------------------
Gate Net
---------------------------------------- ------------
----------------------------------------
-------------------------------------------------------------------------
Gate Net
---------------------------------------- ------------
----------------------------------------
=================================================================
========
--------------------------
=================================================================
========
Total REAL time to Xst completion: 5.00 secs
-->
input cs,
input rw,
);
always@(negedge cs)
begin
if(rw)
data[addr]<=in;
else if(rw==0)
out<=data[addr];
else
out<=8'bz;
end
endmodule
Output:
IO Utilization:
Number of IOs: 20
Number of bonded IOBs: 20 out of 200 10%
---------------------------
Partition Resource Summary:
---------------------------
---------------------------
==================================================================
=======
Timing Report
Clock Information:
------------------
-----------------------------------+------------------------+-------+
Clock Signal | Clock buffer(FF name) | Load |
-----------------------------------+------------------------+-------+
cs | BUFGP | 16 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -3
Timing Details:
---------------
All values displayed in nanoseconds (ns)
==================================================================
=======
Timing constraint: Default period analysis for Clock 'cs'
Clock period: 1.877ns (frequency: 532.808MHz)
Total number of paths / destination ports: 16 / 8
-------------------------------------------------------------------------
Delay: 1.877ns (Levels of Logic = 1)
Source: Mram_data1 (RAM)
Destination: out_0 (FF)
Source Clock: cs falling
Destination Clock: cs falling
==================================================================
=======
Timing constraint: Default OFFSET IN BEFORE for Clock 'cs'
Total number of paths / destination ports: 56 / 40
-------------------------------------------------------------------------
Offset: 3.318ns (Levels of Logic = 3)
Source: addr<0> (PAD)
Destination: out_0 (FF)
Destination Clock: cs falling
==================================================================
=======
-->
Procedure:
i) Open Xilinx ISE 14.7 Project Navigator
ii) Create a New Project in the desired location with top level source type as HDL
iii) Device Properties window opens
Select Family - Spartan6
Device : XC6SLX9
Package : CSG324
Simulator : ISim (VHDL / Verilog)
Preferred Language : Verilog
iv) Create New Source File
v) Select Verilog module with a preferred file name.
vi) Click Next
vii) Click Finish
Result: Thus, the memory elements ROM and RAM were design as per the given
specification.