Project Draft Submission

download Project Draft Submission

of 12

Transcript of Project Draft Submission

  • 8/8/2019 Project Draft Submission

    1/12

    1

    Project Draft Submission

    Project Title: UART Serial Communication

    Team: Abhishek Shetty, Rajath Narasimha

    Constraints: 50MHz, 9600 Baud Rate

    Contents: RTL code, test bench, Outputs & Synthesis Reports

    ---------------------------------------------------------------------------------

    RTL Code:

    Source code: uart.v

    /* Module and Port declarations */module uart(

    input clk, // The master clock for this moduleinput rst, // Synchronous reset.input rx, // Incoming serial lineoutput tx, // Outgoing serial lineinput transmit, // Signal to transmit

    input [7:0] tx_byte, // Byte to transmitoutput received, // Indicated that a byte has been received.output [7:0] rx_byte, // Byte receivedoutput is_receiving, // Low when receive line is idle.output is_transmitting, // Low when transmit line is idle.output recv_error // Indicates error in receiving packet.

    );

    /* declaration of Baud Rate */parameter CLOCK_DIVIDE = 325; // clock rate (50Mhz) / (baud rate (9600) * 4)

    // States for the receiving state machine.// These are just constants, not parameters to override.

    parameter RX_IDLE = 0;parameter RX_CHECK_START = 1;parameter RX_READ_BITS = 2;parameter RX_CHECK_STOP = 3;parameter RX_DELAY_RESTART = 4;parameter RX_ERROR = 5;Parameter RX_RECEIVED = 6;// States for the transmitting state machine.// Constants - do not override.parameter TX_IDLE = 0;parameter TX_SENDING = 1;parameter TX_DELAY_RESTART = 2;

  • 8/8/2019 Project Draft Submission

    2/12

    2

    reg [10:0] clk_divider = CLOCK_DIVIDE;

    reg [2:0] recv_state = RX_IDLE;reg [5:0] rx_countdown;reg [3:0] rx_bits_remaining;reg [7:0] rx_data;

    reg tx_out = 1'b1;reg [1:0] tx_state = TX_IDLE;reg [5:0] tx_countdown;reg [3:0] tx_bits_remaining;reg [7:0] tx_data;

    reg byte_received = 0;reg [7:0] last_byte;

    assign received = recv_state == RX_RECEIVED;assign recv_error = recv_state == RX_ERROR;assign is_receiving = recv_state != RX_IDLE;

    assign rx_byte = rx_data;

    assign tx = tx_out;assign is_transmitting = tx_state != TX_IDLE;

    always @(posedge clk) beginif (rst) begin

    recv_state = RX_IDLE;tx_state = TX_IDLE;

    end

    // The clk_divider counter counts down from// the CLOCK_DIVIDE constant. Whenever it

    // reaches 0, 1/16 of the bit period has elapsed.// Countdown timers for the receiving and transmitting// state machines are decremented.clk_divider = clk_divider - 1;if (!clk_divider) begin

    clk_divider = CLOCK_DIVIDE;rx_countdown = rx_countdown - 1;tx_countdown = tx_countdown - 1;

    endcase (recv_state)

    RX_IDLE: begin// A low pulse on the receive line indicates the// start of data.if (!rx) begin

    // Wait half the period - should resume in the// middle of this first pulse.

    // rx_clk_divider = CLOCK_DIVIDE;rx_countdown = 8;recv_state = RX_CHECK_START;

    endendRX_CHECK_START: begin

    if (!rx_countdown) begin// Check the pulse is still thereif (!rx) begin

  • 8/8/2019 Project Draft Submission

    3/12

    3

    // Pulse still there - good// Wait the bit period to resume half-way// through the first bit.rx_countdown = 16;rx_bits_remaining = 8;recv_state = RX_READ_BITS;

    end else begin// Pulse lasted less than half the period -// not a valid transmission.recv_state = RX_ERROR;

    endend

    endRX_READ_BITS: begin

    if (!rx_countdown) begin// Should be half-way through a bit pulse here.// Read this bit in, wait for the next if we// have more to get.rx_data = {rx, rx_data[7:1]};rx_countdown = 16;

    rx_bits_remaining = rx_bits_remaining - 1;recv_state = rx_bits_remaining ? RX_READ_BITS :RX_CHECK_STOP;

    endendRX_CHECK_STOP: begin

    if (!rx_countdown) begin// Should resume half-way through the stop bit// This should be high - if not, reject the// transmission and signal an error.recv_state = rx ? RX_RECEIVED : RX_ERROR;

    endend

    RX_DELAY_RESTART: begin// Waits a set number of cycles before accepting// another transmission.recv_state = rx_countdown ? RX_DELAY_RESTART : RX_IDLE;

    endRX_ERROR: begin

    // There was an error receiving.// Raises the recv_error flag for one clock// cycle while in this state and then waits// 2 bit periods before accepting another// transmission.rx_countdown = 32;recv_state = RX_DELAY_RESTART;

    endRX_RECEIVED: begin

    // Successfully received a byte.// Raises the received flag for one clock// cycle while in this state.rx_countdown = 4;recv_state = RX_DELAY_RESTART;

    endendcase

    // Transmit state machinecase (tx_state)

  • 8/8/2019 Project Draft Submission

    4/12

  • 8/8/2019 Project Draft Submission

    5/12

    5

    reg rst;wire rx;reg transmit;

    wire tx;wire received;wire is_receiving;wire is_transmitting;wire recv_error;assign rx = tx;

    uart #(.CLOCK_DIVIDE(10)) dut ( // (dut means device under test)//outputs.tx (tx),.received (received),.is_receiving (is_receiving),.is_transmitting (is_transmitting),.recv_error (recv_error),.rx_byte (rx_byte[7:0]),

    //inputs.clk (clk),

    .rst (rst),.rx (rx),

    .transmit (transmit),

    .tx_byte (tx_byte[7:0]));

    // Setup clk to automatically strobe with a period of 20

    always #20000 clk = ~clk;

    initialbegin

    $display("\n -----------------------------------\n");

    $display(" UART MODULE \n");$display("\n----------------------------------------");$display("\n Normalizing the inputs to zero......\n");$display(" Tests Under Progress............\n");//First setup monitor all inputs and outputs

    $display("------------------------------------------\n");$monitor ("time=%d, rst=%b, rx=%b, tx_byte=%b, transmit=%b, tx=%b, is_receiving=%b,

    is_transmitting=%b, rx_byte=%b, recv_error=%b ", $time, rst, rx, tx_byte[7:0], transmit, tx,is_receiving, is_transmitting, rx_byte[7:0], recv_error );

    clk = 0 ;rst = 0 ;transmit = 0 ;@ ( posedge clk ); #1;#3 rst = 1'b1;@ ( posedge clk ); #1;rst = 1'b0;@ ( posedge clk ); #1;tx_byte = 8'b1001011;#100;@ ( posedge clk ); #100;transmit = 1; #1000;@ ( posedge clk ); #1;transmit = 0;#1;@ ( posedge clk ); #90600000;$display(" All Tests Completed Successfully.......\n\n");$finish;

  • 8/8/2019 Project Draft Submission

    6/12

    6

    endinitialbegin

    $dumpfile ( "uart.dump");$dumpvars (0,uart_tb);

    end

    endmodule

  • 8/8/2019 Project Draft Submission

    7/12

    7

    Synthesis Results:

    Area Report:

  • 8/8/2019 Project Draft Submission

    8/12

    8

    Resources Report :

  • 8/8/2019 Project Draft Submission

    9/12

    9

    QOR Report:

  • 8/8/2019 Project Draft Submission

    10/12

  • 8/8/2019 Project Draft Submission

    11/12

    11

  • 8/8/2019 Project Draft Submission

    12/12

    12

    Timing Report: