Uart Report 2
Uart Report 2
DV Batch 2
Project Report
Figure: UART
2. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the
data frame
Advantages of UART:
• Only use 2 wire.
• No clocking signal is necessary.
• Has a parity bit to allow for error checking.
• Simplicity.
• Widespread Compatibility.
• Versatility.
• Asynchronous Communication.
• Cost-Effective.
Disadvantages of UART:
• The size of the data frame is limited to a maximum of 9 bits.
• Doesn’t support multiple slave or multiple master systems.
• The baud rates of each UART must be within 10% of each other.
• Limited Distance.
• No Built-in Error Checking.
• Limited Speeds.
• Synchronization Challenges.
• Half-Duplex Communication.
BLOCK DIAGRAM:
Design:
1)Top Module
2) UART_transmitter
3)UART_Receiver:
module uart_top
#(
parameter clk_freq = 1000000,
parameter baud_rate = 9600
)
(
input clk,rst,
input rx,
input [7:0] dintx,
input newd,
output tx,
output [7:0] doutrx,
output donetx,
output donerx
);
//instance of uart transmitter
endmodule
//////////////////////////////////////////////////////////////////
module uarttx
#(
parameter real clk_freq = 1e6,
parameter baud_rate = 9600
)
(
input clk,rst,
input newd,
input [7:0] tx_data,
output reg tx,
output reg donetx
);
localparam clkcount = (clk_freq/baud_rate);
integer count = 0;
integer counts = 0;
reg uclk = 0;
///////////uart_clock_gen
always@(posedge clk)
begin
if(count < clkcount/2)
count <= count + 1;
else begin
count <= 0;
uclk <= ~uclk;
end
end
reg [7:0] din;
////////////////////Reset decoder
always@(posedge uclk)
begin
if(rst)
begin
state <= idle;
end
else
begin
case(state)
idle:
begin
counts <= 0;
tx <= 1'b1;
donetx <= 1'b0;
if(newd)
begin
state <= transfer;
din <= tx_data;
tx <= 1'b0;
end
else
state <= idle;
end
transfer: begin
if(counts <= 7) begin
counts <= counts + 1;
tx <= din[counts];
state <= transfer;
end
else
begin
counts <= 0;
tx <= 1'b1;
state <= idle;
donetx <= 1'b1;
end
end
endmodule
////////////////////////////////////////////////////////////////////
module uartrx
#(
parameter clk_freq = 1000000, //MHz
parameter baud_rate = 9600
)
(
input clk,
input rst,
input rx,
output reg done,
output reg [7:0] rxdata
);
///////////uart_clock_gen
always@(posedge clk)
begin
if(count < clkcount/2)
count <= count + 1;
else
begin
count <= 0;
uclk <= ~uclk;
end
end
always@(posedge uclk)
begin
if(rst)
begin
rxdata <= 8'h00;
counts <= 0;
done <= 1'b0;
end
else
begin
case(state
idle :
begin
rxdata <= 8'h00;
counts <= 0;
done <= 1'b0;
if(rx == 1'b0)
state <= start;
else
state <= idle;
end
start:
begin
if(counts <= 7)
begin
counts <= counts + 1;
rxdata <= {rx, rxdata[7:1]};
end
else
begin
counts <= 0;
done <= 1'b1;
state <= idle;
end
end
default : state <= idle;
endcase
end
end
endmodule
Interface
TRANSACTION CLASS
GENERATOR CLASS
DRIVER CLASS
MONITORE CLASS
SCOREBOARD CLASS
ENVIRONMENT CLASS
Module Top
RESULTS:
WAVE :
WAVE: showing that tx operation happening correctly
UVM ENVIRONMENT:
INTERFACE CLASS:
TRANSACTION CLASS
GENERATOR CLASS
DRIVER CLASS
MONITOR CLASS
AGENT CLASS
SCOREBOARD CLASS
ENVIRONMENT CLASS
TEST CLASS
TEST TOP