【发布时间】:2021-05-01 15:40:06
【问题描述】:
我正在尝试使用 Verilog 在测试台中模拟 uart 接收器。我强制所有输入位,时钟和复位,我强制RsRx,接收器的串行输入,以获得输出rx_data,但rx_data总是
波特发生器运行良好,但接收器却不行。我认为问题出在测试台上,因为接收器的代码是由 ARM 提供的。 谁能帮帮我?
module TEST_Uart() ;
reg HCLK=0 ;
reg HRESETn=0 ;
wire b_tick ;
wire rx_done ;
reg RsRx=1 ;
wire [7:0]rx_data ;
initial
forever #1 HCLK = ~HCLK;
initial
begin
@(posedge HCLK);
HRESETn=1 ;
end
BAUDGEN uBAUDGEN(
.clk(HCLK),
.resetn(HRESETn),
.baudtick(b_tick)
);
//UART receiver
UART_RX uUART_RX(
.clk(HCLK),
.resetn(HRESETn),
.b_tick(b_tick),
.rx(RsRx),
.rx_done(rx_done),
.dout(rx_data[7:0])
);
task UART_WRITE_BYTE;
input [7:0] i_Data;
integer ii;
begin
// Send Start Bit
RsRx <= 1'b0;
// Send Data Byte
for (ii=0; ii<8; ii=ii+1)
begin
RsRx <= i_Data[ii];
end
// Send Stop Bit
RsRx <= 1'b1;
end
endtask // UART_WRITE_BYTE
initial
begin
// Send a command to the UART (exercise Rx)
@(posedge HCLK);
UART_WRITE_BYTE(8'h3F);
@(posedge HCLK);
// Check that the correct command was received
if (rx_data == 8'h3F)
$display("Test Passed - Correct Byte Received");
else
$display("Test Failed - Incorrect Byte Received");
end
endendmodule
【问题讨论】: