📄 baud.v
字号:
//============================================================================
//
// Title : UART BAUT RATE GENERATOR DESIGN
// Author : JP LIU
//
//=============================================================================
//
// File Name : baut.v
// Module Name : baut
//
//=============================================================================
//
// The "baud_clk" is the output clock feeding the receiver and transmitter
// modules of the UART.
//
// By design, the purpose of the "baud_clk" is to take in the "sys_clk" and
// generate a clock which is 16 x BaudRate, where BaudRate is the desired
// UART baud rate.
//
//=============================================================================
`include "uart_inc.h"
module baud
(
// INPUT PORT
sys_clk,
sys_rst_b,
baud_rate_div,
// OUTPUT PORT
baud_clk
);
//////////////////////////////////////////////
//
// INPUT AND OUTPUT DECLARATION //
//
//////////////////////////////////////////////
input sys_clk;
input sys_rst_b;
input [15:0] baud_rate_div;
output baud_clk;
/////////////////////////////////////////////
//
// WIRE AND REG DECLARATION //
//
/////////////////////////////////////////////
reg [15:0] clk_div;
reg baud_clk;
/////////////////////////////////////////////
// SEQUENCAL LOGIC //
/////////////////////////////////////////////
always @(posedge sys_clk or negedge sys_rst_b)
if (~sys_rst_b)
begin
clk_div <= 0;
baud_clk <= 0;
end
else if (clk_div == baud_rate_div)
begin
clk_div <= 0;
baud_clk <= ~baud_clk;
end
else
begin
clk_div <= clk_div + 1;
baud_clk <= baud_clk;
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -