Line 23... |
Line 23... |
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
|
// Copyright (C) 2015-2019, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
Line 65... |
Line 65... |
//
|
//
|
module txuartlite(i_clk, i_wr, i_data, o_uart_tx, o_busy);
|
module txuartlite(i_clk, i_wr, i_data, o_uart_tx, o_busy);
|
parameter [4:0] TIMING_BITS = 5'd24;
|
parameter [4:0] TIMING_BITS = 5'd24;
|
localparam TB = TIMING_BITS;
|
localparam TB = TIMING_BITS;
|
parameter [(TB-1):0] CLOCKS_PER_BAUD = 8; // 24'd868;
|
parameter [(TB-1):0] CLOCKS_PER_BAUD = 8; // 24'd868;
|
parameter [0:0] F_OPT_CLK2FFLOGIC = 1'b0;
|
|
input wire i_clk;
|
input wire i_clk;
|
input wire i_wr;
|
input wire i_wr;
|
input wire [7:0] i_data;
|
input wire [7:0] i_data;
|
// And the UART input line itself
|
// And the UART input line itself
|
output reg o_uart_tx;
|
output reg o_uart_tx;
|
Line 190... |
Line 189... |
// certain the STOP bit is complete.
|
// certain the STOP bit is complete.
|
initial zero_baud_counter = 1'b1;
|
initial zero_baud_counter = 1'b1;
|
initial baud_counter = 0;
|
initial baud_counter = 0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
begin
|
begin
|
zero_baud_counter <= (baud_counter == 24'h01);
|
zero_baud_counter <= (baud_counter == 1);
|
if (state == `TXUL_IDLE)
|
if (state == `TXUL_IDLE)
|
begin
|
begin
|
baud_counter <= 24'h0;
|
baud_counter <= 0;
|
zero_baud_counter <= 1'b1;
|
zero_baud_counter <= 1'b1;
|
if ((i_wr)&&(!r_busy))
|
if ((i_wr)&&(!r_busy))
|
begin
|
begin
|
baud_counter <= CLOCKS_PER_BAUD - 24'h01;
|
baud_counter <= CLOCKS_PER_BAUD - 1'b1;
|
zero_baud_counter <= 1'b0;
|
zero_baud_counter <= 1'b0;
|
end
|
end
|
end else if ((zero_baud_counter)&&(state == 4'h9))
|
end else if ((zero_baud_counter)&&(state == 4'h9))
|
begin
|
begin
|
baud_counter <= 0;
|
baud_counter <= 0;
|
zero_baud_counter <= 1'b1;
|
zero_baud_counter <= 1'b1;
|
end else if (!zero_baud_counter)
|
end else if (!zero_baud_counter)
|
baud_counter <= baud_counter - 24'h01;
|
baud_counter <= baud_counter - 1'b1;
|
else
|
else
|
baud_counter <= CLOCKS_PER_BAUD - 24'h01;
|
baud_counter <= CLOCKS_PER_BAUD - 1'b1;
|
end
|
end
|
|
|
//
|
//
|
//
|
//
|
// FORMAL METHODS
|
// FORMAL METHODS
|
Line 228... |
Line 227... |
|
|
// Setup
|
// Setup
|
|
|
reg f_past_valid, f_last_clk;
|
reg f_past_valid, f_last_clk;
|
|
|
generate if (F_OPT_CLK2FFLOGIC)
|
|
begin
|
|
|
|
always @($global_clock)
|
|
begin
|
|
restrict(i_clk == !f_last_clk);
|
|
f_last_clk <= i_clk;
|
|
if (!$rose(i_clk))
|
|
begin
|
|
`ASSUME($stable(i_wr));
|
|
`ASSUME($stable(i_data));
|
|
end
|
|
end
|
|
|
|
end endgenerate
|
|
|
|
initial f_past_valid = 1'b0;
|
initial f_past_valid = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
f_past_valid <= 1'b1;
|
f_past_valid <= 1'b1;
|
|
|
initial `ASSUME(!i_wr);
|
initial `ASSUME(!i_wr);
|