RTL Simulation and Synthesis With Plds Lab Manual-Sem-I
RTL Simulation and Synthesis With Plds Lab Manual-Sem-I
RTL Simulation and Synthesis With Plds Lab Manual-Sem-I
LABORATORY MANUAL
M. Tech – I Year – I Sem. (VLSI & Embedded Systems)
2022-2023
To strengthen the department into a centre of academic excellence with focus on advanced
technologies & relevant research by delivering the best quality technical education to the
students, so as to meet the current and future challenges along with emphasis on moral and
ethical values.
Mission
To create and enrich academic environment with essential resources, so as to train and mould
students in active learning & critical thinking with innovative ideas, so as to solve real-world
problems in the field of Electrical & Electronics Engineering.
To motivate and strengthen the faculty to practice effective teaching & learning process and
involve in advanced research & development work.
To enhance industry interaction and initiate best consultancy services.
Quality Policy
To develop, maintain and update global standards of excellence in all our areas of academic &
research activities and facilities so as to impart a state of the art & value based technical
education to the students commensurate with the rapidly changing industry needs.
To continuously adopt and implement concurrent & commensurate faculty development
programmes towards achieving the institution’s goals and objectives.
MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY
(Autonomous Institution – UGC, Govt. of India)
(Affiliated to JNTU, Hyderabad, Approved by AICTE - Accredited by NBA & NAAC – ‘A’ Grade - ISO 9001:2015 Certified)
Maisammaguda, Dhulapally (Post Via. Kompally), Secunderabad – 500100, Telangana State, India.
PSO 1.
To acquire competency in areas of VLSI and Embedded Systems, Design, Testing, Verification IC
Fabrication and prototype development with focus on applications.
PSO 2.
To integrate multiple sub-systems to develop System on Chip, optimize its performance and
excel in industry sectors related to VLSI/ Embedded domain and to develop a start-up system.
RTL SIMULATION AND SYNTHESIS WITH PLDS
List of Experiments:
Course Outcomes:
Exp.1- Verilog implementation of 8:1 Mux/Demux, Full Adder, 8-bit Magnitude comparator,
Encoder/decoder, Priority encoder, D-FF, 4-bit Shift registers (SISO, SIPO, PISO, bidirectional),
3-bit Synchronous Counters, Binary to Gray converter, Parity generator.
AIM:
To develop the source code for multiplexer and demultiplexer by using VHDL/VERILOG and obtain
the simulation, synthesis, place and route and implement in FPGA.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
MULTIPLEXER:
LOGIC DIAGRAM:
TRUTH TABLE:
1
D0 2 9
8
4
1 Y S1 S0 Y
5
1
D2 2 9
8
0 0 D0
1
D3 2 9
8
0 1 D1
2
1 0 D2
1
S1 S0 1 1 D3
Dataflow Modeling:
Behavioral Modeling:
r=(d[2]&so&s1bar);
s=(d[3]&so&s1);
endmodule
Structural Modeling:
a1(p,d[0],~s0,~s1);
a2(q,d[1],~s0, s1);
a3(r,d[2], s0, ~s1);
a4(s,d[3], s0, s1);
or
o1(yp,q,r,s);
endmodule
DEMULTIPLEXER:
LOGIC DIAGRAM: `
TRUTH TABLE:
S1 S0
INPUT OUTPUT
1
D S0 S1 Y0 Y1 Y2 Y3
1 0 0 1 0 0 0
2
Din 2
3
1
Y0
4
5 1 0 1 0 1 0 0
2
3
4
1
Y1
1 1 0 0 0 1 0
5
2
3
1
1 1 1 0 0 0 1
4 Y2
5
2
3
1
4 Y3
5
Enable
Dataflow Modeling:
module demuxdataflow(s0,s1,d,y,e);
input s0,s1,d,e;
output [3:0] y;
wire s0bar,s1bar;
assign #2s0bar=~s0;
assign #2 s1bar=~s1;
assign #3 y[0]=(d&s0bar&s1bar&e);
assign #3 y[1]=(d&s0bar&s1&e);
assign #3 y[2]=(d&s0&s1bar&e);
assign #3 y[3]=(d&s0&s1&e);
endmodule
Behavioral Modeling:
module demux_behv(s0, s1,d, y,e);
input s0;
input s1;
input d,e;
output [3:0] y;
reg [3:0] y;
reg s0bar,s1bar;
always@(d or s0 or s1)
begin
s0bar=~s0;
s1bar=~s1;
y[0]=(d&s0bar&s1bar&e);
y[1]=(d&s0bar&s1&e);
y[2]=(d&s0&s1bar&e);
y[3]=(d&s0&s1&e);
end
endmodule
Structural Modeling:
module demux_struct(s0, s1, d,e,y);
input s0;
input s1;
input d,e;
output [3:0] y;
and
a1(y[0],d,~s0,~s1,e);
a2(y[1],d,~s0, s1,e);
a3(y[2, s0, ~s1,e);
a4(y[3], s0, s1,e);
endmodule
FULL ADDER:
A B C SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Dataflow Modeling:
Behavioral Modeling:
Structural Modeling:
module fa_struct(a, b, c, sum, carry);
input a;
input b;
input c;
output sum;
output carry;
wire t1,t2,t3,s1
xor
x1(t1a,b),
x2(sum,s1,c);
and
a1(t1,a,b),
a2(t2,b,c),
a3(t3,a,c);
or
o1(carry,t1,t2,t3);
endmodule
4 BIT COMPARATOR:
LOGIC DIAGRAM:
Behavioral Modeling:
ENCODER:
D0 D1 D2 D3 D4 D5 D6 D7 X Y Z
1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0 1
0 0 0 0 0 0 1 0 1 1 0
0 0 0 0 0 0 0 1 1 1 1
Dataflow Modeling:
Behavioral Modeling:
Structural Modeling:
input [7:0] d;
output a,b,c;
or
o1(a,d[4],d[5],d[6],d[7]),
o2(b,d[2],d[3],d[6],d[7]),
o3(c,d[1],d[3],d[5],d[7]);
endmodule
DECODERS:
0 0 1 0 1 1 1
0 1 1 1 0 1 1
1 0 1 1 1 0 1
1 1 1 1 1 1 0
Dataflow Modeling:
Behavioral Modeling:
z[0] = (abar&bbar&en);
z[1] = (abar&b&en);
z[2] = (a&bbar&en);
z[3] = (a&b&en);
end
endmodule
Structural Modeling:
D FLIPFLOP:
1
D
2
3 1
2
3
Q
Q(t) D Q(t+1)
1
CP
0 0 0
1
1 3
3 2 Q
3
2
0 1 1
1 0 0
1 1 1
Behavioral Modeling:
DESIGN OF SHIFTERS
LOGIC DIAGRAM :
Behavioral Modeling:
LOGIC DIAGRAM :
Behavioral Modeling:
LOGIC DIAGRAM :
Behavioral Modeling:
LOGIC DIAGRAM :
Behavioral Modeling:
LOGIC DIAGRAM:
Thus the Output’s of of 8:1 Mux/Demux, Full Adder, 8-bit Magnitude comparator,
Encoder/decoder, Priority encoder, D-FF, 4-bit Shift registers, 3-bit Synchronous Counters, Binary to
Gray converter, Parity generator are verified by synthesizing and simulating the VERILOG code.
AIM:
To develop the source code for moore and melay FSM by using VERILOG and obtain the
simulation, synthesis, place and route and implement into FPGA.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
MOORE FSM:
LOGIC DIAGRAM:
Behavioral Modeling:
module moorefsm(a,clk,z);
input a;
input clk;
output z;
reg z;
parameter st0=0,st1=1,st2=2,st3=3;
reg[0:1]moore_state;
initial
begin
moore_state=st0;
end
always @ (posedge(clk))
case(moore_state)
st0:
begin
z=1;
if(a)
moore_state=st2;
end
st1:
begin
z=0;
if(a)
moore_state=st3;
end
st2:
begin
z=0;
if(~a)
moore_state=st1;
else
moore_state=st3;
end
st3:
begin
z=1;
if(a)
moore_state=st0;
end
endcase
endmodule
Simulation output:
Synthesis report:
=========================================================================
* Final Report *
=========================================================================
---------------------------
=========================================================================
TIMING REPORT
NOTE: THESE TIMING NUMBERS ARE ONLY A SYNTHESIS ESTIMATE. FOR ACCURATE TIMING
INFORMATION PLEASE REFER TO THE TRACE REPORT GENERATED AFTER PLACE-and-ROUTE.
Clock Information:
-----------------------------------+------------------------+-------+
-----------------------------------+------------------------+-------+
clk | BUFGP |5 |
-----------------------------------+------------------------+-------+
Timing Summary:
Speed Grade: -5
MEALY FSM:
TRUTH TABLE:
Behavioral Modeling:
parameter st0=0,st1=1,st2=2,st3=3;
reg[0:1]mealy_state;
initial
begin
mealy_state=st0;
end
always @ (posedge(clk))
case(mealy_state)
st0:
begin
if(a) begin
z=1;
mealy_state=st3; end
else
z=0;
end
st1:
begin
if(a) begin
z=0;
mealy_state=st0; end
else
z=1;
end
st2:
begin
if(a) begin
z=1;
mealy_state=st1; end
else
z=0;
end
st3:
begin
z=0;
if(a) begin
mealy_state=st1; end
else
mealy_state=st2;
end
endcase
endmodule
Simulation output:
Synthesis report:
=========================================================================
* Final Report *
=========================================================================
---------------------------
=========================================================================
TIMING REPORT
Clock Information:
-----------------------------------+------------------------+-------+
_n0009(_n00091:O) | NONE(*)(nst_3) |4 |
clk | BUFGP |4 |
-----------------------------------+------------------------+-------+
and XST is not able to identify which are the primary clock signals.
Please use the CLOCK_SIGNAL constraint to specify the clock signal(s) generated by combinatorial logic.
INFO:Xst:2169 - HDL ADVISOR - Some clock signals were not automatically buffered by XST with
BUFG/BUFR resources. Please use the buffer_type constraint in order to insert these buffers to the clock
signals to help prevent skew problems.
Timing Summary:
---------------
Speed Grade: -5
RESULT:
Thus the output of Synchronous FSM – Mealy and Moore machines are verified by synthesizing
and simulating the VERILOG code.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
LOGIC DIAGRAM:
Behavioral Modeling:
st0:
if(count==4)
begin
y1=1'b1;y2=1'b0;y3=1'b0;y4=1'b0;
count=0;
pst=st1;
end
else
begin
g1=2'b11;g2=2'b00;g3=2'b00;g4=2'b10;
r1=1'b0;r2=1'b1;r3=1'b1;r4=1'b1;
y1=1'b0;y2=1'b0;y3=1'b0;y4=1'b0;
pst=st0;
count=count+1;
end
st1:
if(count==4)
begin
y1=1'b0;y2=1'b1;y3=1'b0;y4=1'b0;
count=0;
pst=st2;
end
else
begin
g1=2'b10;g2=2'b11;g3=2'b00;g4=2'b00;
r1=1'b1;r2=1'b0;r3=1'b1;r4=1'b1;
y1=1'b0;y2=1'b0;y3=1'b0;y4=1'b0;
pst=st1;
count=count+1;
end
st2:
if(count==4)
begin
y1=1'b0;y2=1'b0;y3=1'b1;y4=1'b0;
count=0;
pst=st3;
end
else
begin
g1=2'b00;g2=2'b10;g3=2'b11;g4=2'b00;
r1=1'b0;r2=1'b1;r3=1'b0;r4=1'b1;
y1=1'b0;y2=1'b0;y3=1'b0;y4=1'b0;
pst=st2;
count=count+1;
end
st3:
if(count==4)
begin
y1=1'b0;y2=1'b0;y3=1'b0;y4=1'b1;
count=0;
pst=st1;
end
else
begin
g1=2'b00;g2=2'b00;g3=2'b10;g4=2'b11;
r1=1'b0;r2=1'b1;r3=1'b1;r4=1'b0;
y1=1'b0;y2=1'b0;y3=1'b0;y4=1'b0;
pst=st3;
count=count+1;
end
endcase
end
endmodule
Simulation output:
Synthesis report:
=========================================================================
* Final Report *
=========================================================================
---------------------------
=========================================================================
TIMING REPORT
Clock Information:
------------------
-----------------------------------+------------------------+-------+
-----------------------------------+------------------------+-------+
clk | BUFGP | 50 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -5
RESULT:
Thus the output of Traffic Light controller are verified by synthesizing and simulating the
VERILOG code.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
LOGIC DIAGRAM:
integer counter = 0;
wire IDLE ;
begin
begin
@(negedge clk)
REQ<=0;
end
begin
@(negedge clk)
REQ<=1;
FRAME <= 0 ;
end
begin
@(negedge clk)
FRAME <=1 ;
end
end
begin
begin
@(negedge clk)
IRDY <= 0;
end
else if (~ pipeline5)
begin
@(negedge clk)
IRDY <=1;
end
end
begin
begin
@(negedge clk)
I_AM_OWNER<=1;
end
else if (~ pipeline5)
begin
@(negedge clk)
I_AM_OWNER<=0;
end
end
begin
end
endmodule
PCI-arbiter/ SimpleInitiator.v
begin
@(negedge clk)
I_AM_OWNER<=0;
end
end
always @(posedge clk)
begin
pipeline1 <= FRAME ;
pipeline2 <= pipeline1;
pipeline3 <= pipeline2;
pipeline4 <= pipeline3;
pipeline5 <= pipeline4;
end
endmodule
module SpecializedMux(I_AM_OWNERS,IRDYS,FRAMES,GLOBAL_IRDY,GLOBAL_FRAME);
input [7:0] I_AM_OWNERS,IRDYS,FRAMES;
output wire GLOBAL_IRDY,GLOBAL_FRAME;
assign {GLOBAL_IRDY,GLOBAL_FRAME} =
(I_AM_OWNERS[0]) ? {IRDYS[0],FRAMES[0]} :
(I_AM_OWNERS[1]) ? {IRDYS[1],FRAMES[1]} :
(I_AM_OWNERS[2]) ? {IRDYS[2],FRAMES[2]} :
(I_AM_OWNERS[3]) ? {IRDYS[3],FRAMES[3]} :
(I_AM_OWNERS[4]) ? {IRDYS[4],FRAMES[4]} :
(I_AM_OWNERS[5]) ? {IRDYS[5],FRAMES[5]} :
(I_AM_OWNERS[6]) ? {IRDYS[6],FRAMES[6]} :
(I_AM_OWNERS[7]) ? {IRDYS[7],FRAMES[7]} : {1'b1,1'b1};
endmodule
module arbiter (clk,req,gnt,frame,irdy,trdy);
input wire clk ,irdy,frame,trdy;
input wire [7:0] req;
output reg [7:0] gnt;
reg [7:0] fifo[7:0];
integer pointer;
reg lastframe;
reg trflag;
reg [7:0]lastreq;
initial
begin
lastframe=1'b1;
trflag = 1'b0 ;
gnt = 8'hff ;
pointer= 0;
lastreq = 8'hff ;
end
always@(posedge clk)
begin
if(lastframe && ~frame)
begin
trflag=1'b1;lastframe =frame;
end
end
if(trflag==1)
begin
@(negedge clk)
gnt=fifo[0]; pointer = pointer - 1;
fifo[0]=fifo[1];fifo[1]=fifo[2];fifo[2]=fifo[3];fifo[3]=fifo[4];fifo[4]=fifo[5];fifo[5]=fifo[6
];fifo[6]=fifo[7];trflag=1'b0;
end
if (lastreq != req)
begin
@(negedge clk)
req=fifo[pointer];pointer = pointer + 1;
end
endmodule
module arbiterTB;
reg clk;
wire [7:0] GNT;
wire [7:0] FRAMES , IRDYS, I_AM_OWNERS;
wire GLOBAL_IRDY , GLOBAL_FRAME;
wire [7:0] REQ;
reg [7:0] STARTS = 8'h00;
always
begin
#5
clk <= ~ clk;
end
initial
begin
clk <= 0;
#20
STARTS[0] <= 1;
#20
STARTS[1] <= 1;
#20
STARTS[2] <= 1;
#20
STARTS[3] <= 1;
#200
STARTS[3] <= 0;
#20
STARTS[5] <= 1;
STARTS[7] <= 1;
STARTS[1] <= 0;
STARTS[0] <= 0;
end
SpecializedMux myMux(I_AM_OWNERS,IRDYS,FRAMES,GLOBAL_IRDY,GLOBAL_FRAME);
arbiter A(clk,REQ,GNT,GLOBAL_FRAME,GLOBAL_IRDY, 1'b1);
SimpleInitiator simple0 (STARTS[0],clk,REQ[0],GNT[0],FRAMES[0],IRDYS[0],I_AM_OWNERS[0] ,
GLOBAL_IRDY);
SimpleInitiator simple1 (STARTS[1],clk,REQ[1],GNT[1],FRAMES[1],IRDYS[1],I_AM_OWNERS[1] ,
GLOBAL_IRDY);
SimpleInitiator simple2 (STARTS[2],clk,REQ[2],GNT[2],FRAMES[2],IRDYS[2],I_AM_OWNERS[2] ,
GLOBAL_IRDY);
SimpleInitiator simple3 (STARTS[3],clk,REQ[3],GNT[3],FRAMES[3],IRDYS[3],I_AM_OWNERS[3] ,
GLOBAL_IRDY);
SimpleInitiator simple4 (STARTS[4],clk,REQ[4],GNT[4],FRAMES[4],IRDYS[4],I_AM_OWNERS[4] ,
GLOBAL_IRDY);
SimpleInitiator simple5 (STARTS[5],clk,REQ[5],GNT[5],FRAMES[5],IRDYS[5],I_AM_OWNERS[5] ,
GLOBAL_IRDY);
SimpleInitiator simple6 (STARTS[6],clk,REQ[6],GNT[6],FRAMES[6],IRDYS[6],I_AM_OWNERS[6] ,
GLOBAL_IRDY);
SimpleInitiator simple7 (STARTS[7],clk,REQ[7],GNT[7],FRAMES[7],IRDYS[7],I_AM_OWNERS[7] ,
GLOBAL_IRDY);
endmodule
module arbiterTB;
wire [7:0] GNT;
wire [7:0] FRAMES , IRDYS, I_AM_OWNERS;
wire GLOBAL_IRDY , GLOBAL_FRAME;
wire [7:0]REQ;
reg [7:0] STARTS = 8'h00;
always
begin
#5
clk <= ~ clk;
end
initial
begin
clk <= 0 ;
# 20
STARTS[0] <= 1 ;
#20
STARTS[1] <=1;
#20
STARTS[2] <=1;
#20
STARTS[3] <=1;
# 200
STARTS[3] <=0;
#20
STARTS[5] <=1;
STARTS[7] <=1;
STARTS[1] <=0;
STARTS[0] <=0;
end
SpecializedMux myMux(I_AM_OWNERS,IRDYS,FRAMES,GLOBAL_IRDY,GLOBAL_FRAME);
arbiter A(clk,REQ,GNT,GLOBAL_FRAME,GLOBAL_IRDY, 1'b1);
SimpleInitiator simple0
(STARTS[0],clk,REQ[0],GNT[0],FRAMES[0],IRDYS[0],I_AM_OWNERS[0] , GLOBAL_IRDY);
SimpleInitiator simple1
(STARTS[1],clk,REQ[1],GNT[1],FRAMES[1],IRDYS[1],I_AM_OWNERS[1] , GLOBAL_IRDY);
SimpleInitiator simple2
(STARTS[2],clk,REQ[2],GNT[2],FRAMES[2],IRDYS[2],I_AM_OWNERS[2] , GLOBAL_IRDY);
SimpleInitiator simple3
(STARTS[3],clk,REQ[3],GNT[3],FRAMES[3],IRDYS[3],I_AM_OWNERS[3] , GLOBAL_IRDY);
SimpleInitiator simple4
(STARTS[4],clk,REQ[4],GNT[4],FRAMES[4],IRDYS[4],I_AM_OWNERS[4] , GLOBAL_IRDY);
SimpleInitiator simple5
(STARTS[5],clk,REQ[5],GNT[5],FRAMES[5],IRDYS[5],I_AM_OWNERS[5] , GLOBAL_IRDY);
SimpleInitiator simple6
(STARTS[6],clk,REQ[6],GNT[6],FRAMES[6],IRDYS[6],I_AM_OWNERS[6] , GLOBAL_IRDY);
SimpleInitiator simple7
(STARTS[7],clk,REQ[7],GNT[7],FRAMES[7],IRDYS[7],I_AM_OWNERS[7] , GLOBAL_IRDY);
endmodule
RESULT:
Thus the output of PCI Bus & arbiter are verified by synthesizing and simulating the VERILOG
code.
To develop the source code for UART/USART by using VEILOG and obtain the simulation, place
and route and implementation into FPGA.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
UART MODULE:
endmodule
UART Transmitter.
1. module UART_Transmitter (Serial_out, Data_Bus, Byte_ready,
Load_XMT_datareg, T_byte, Clock, reset);
2. parameter word_size = 8; //size of data word
3. parameter one_count = 3; //number of states
4. parameter state_count = one_count; //number of bits in
state register
5. parameter size_bit_count = 3; //size of bit
counter
6. parameter idle = 3’b001;
7. parameter waiting = 3’b010;
8. parameter sending = 3’b100;
9. parameter all_ones = 9’b1_1111_1111; //word + extra bit
10. output serial_out //serial output to
data channel
11. input [word_size – 1:0] Data_Bus; //data bus containing
data word
12. input Byte_ready; //used by host to
signal ready
13. input Load_XMT_datareg; //used to load the data
register
14. input T_byte; //used to signal the start of
transmission
15. input Clock; //bit clock of the transmitter
16. input reset_; //resets internal registers
17. reg [word_size – 1:0] XMT_datareg; //transmit data
register
18. reg [word_size:0] XMT_shftreg; //transmit shift
register
19. reg Load_XMT_shfteg; //flag to load
20. reg [state_count – 1:0] state, next_state; //state machine
controller
21. reg [size_bit_count:0] bit_count; //counts the bits that are
transmitted
1. module UART8_Receiver
2. (RCV_datareg, read_not_ready_out, Error1 ,Error2, Serial_in,
read_no_ready_in, Sample_clk, reset_); //Sample_clk is 8x Bit_clk
3. parameter word_size = 8;
4. parameter half_word = word_size/2;
5. parameter Num_count_bits = 4; //to hold count of word_size
6. parameter Num_state_bits = 2; //number of bits in states
7. parameter idle = 2’b00;
8. parameter starting = 2’b01;
9. parameter receiving = 2’b10;
10. output [word_size – 1:0] RCV_datareg;
11. output read_not_ready_out, Error1, Error2;
12. input Serial_in, Sample_clk, reset_, read_not_ready_in;
13. reg RCV_datareg;
14. reg [word_size – 1:0] RCV_shftreg;
15. reg [Num_counter_bits – 1:0] Sample_counter;
16. reg [Num_counter_bits:0] Bit_counter;
17. reg [Num_state_bits – 1:0] state, next_state;
18. reg inc_Bit_counter, clr_Bit_counter;
19. reg inc_Sample_counter, clr_Sample_counter;
20. reg shift, load, read_not_ready_out;
21. reg Error1, Error2;
22. always @ (state or Serial_in or read_not_ready_in or
Sample_counter or Bit_counter) begin
23. read_not_ready_out = 0;
24. clr_Sample_counter = 0;
25. clr_Bit_counter = 0;
26. inc_Sample_counter = 0;
27. inc_Bit_counter = 0;
28. shift = 0;
29. Error1 = 0;
30. Error2 = 0;
31. load = 0;
32. next_state = state;
33. case (state)
34. idle: if (Serial_in = = 0) next_state = starting;
35. starting: if (Serial_in = = 1) begin
36. next_state = idle;
37. clr_Sample_counter = 1 ;
38. end else
39. if (Sample_counter = = half_word - 1) begin
40. next_state = receiving;
41. clr_Sample_counter = 1 ;
42. end else inc_Sample_counter = 1 ;
endmodule
Output Waveform:
RESULT:
Thus the output of UART/ USART are verified by synthesizing and simulating the VERILOG
code.
Exp.6-DESIGN OF MEMORIES
AIM:
To develop the source code for memories by using VEILOG and obtain the simulation, place and
route and implementation into FPGA.
1. XILINX 9.2i
2. FPGA-SPARTAN-3
ALGORITM:
Step3: Check the syntax and debug the errors if found, obtain the synthesis report.
Step5: Write all possible combinations of input using the test bench.
BLOCK DIAGRAM:
ROM
Behavioral Modeling:
reg[3:0]data;
reg[3:0]mem[0:7];
initial
begin
mem[0]=4'b0000;
mem[1]=4'b0001;
mem[2]=4'b0010;
mem[3]=4'b0100;
mem[4]=4'b1000;
mem[5]=4'b0011;
mem[6]=4'b0111;
mem[7]=4'b1111;
end
always@(addrs)
begin
data=mem[addrs];
end
endmodule
Simulation output:
Synthesis report:
=========================================================================
* Final Report *
=========================================================================
---------------------------
=========================================================================
TIMING REPORT
Clock Information:
------------------
Timing Summary:
---------------
Speed Grade: -5
RAM
Behavioral Modeling:
input clk,wr_en;
reg[7:0]data_out;
reg[2:0] mem[7:0];
if(clk)
begin
if(wr_en)
mem[addrs]=data_in;
else
data_out=mem[addrs];
end
endmodule
Simulation output:
Synthesis report:
=========================================================================
* Final Report *
=========================================================================
---------------------------
=========================================================================
TIMING REPORT
Clock Information:
------------------
-----------------------------------+------------------------+-------+
-----------------------------------+------------------------+-------+
clk | BUFGP |1 |
-----------------------------------+------------------------+-------+
Timing Summary:
---------------
Speed Grade: -5
RESULT:
Thus the outputs of memory structures are verified by synthesizing and simulating the
VERILOG code.