You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
module uart_top(
|
|
|
|
|
input wire sys_clk ,
|
|
|
|
|
input wire sys_rst_n ,
|
|
|
|
|
input wire rx ,
|
|
|
|
|
input wire [3: 0] key_in ,
|
|
|
|
|
|
|
|
|
|
output wire tx
|
|
|
|
|
);
|
|
|
|
|
wire [7: 0] data_byte ;
|
|
|
|
|
wire [7: 0] data_out ;
|
|
|
|
|
wire [3: 0] key_out ;
|
|
|
|
|
wire tx_vld ;
|
|
|
|
|
wire rx_vld ;
|
|
|
|
|
reg rcv_start ;
|
|
|
|
|
|
|
|
|
|
// uart_rx uart_rx_inst(
|
|
|
|
|
// .sys_clk (sys_clk) ,
|
|
|
|
|
// .sys_rst_n (sys_rst_n) ,
|
|
|
|
|
// .rx_din (rx) ,//数据串行输入
|
|
|
|
|
// .rcv_start (rcv_start) ,
|
|
|
|
|
|
|
|
|
|
// .rx_dout (data_byte) ,//数据并行输出
|
|
|
|
|
// .rx_vld (rx_vld) //输出信号有效
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
key_filter key_filter_inst(//20ms
|
|
|
|
|
.sys_clk (sys_clk),
|
|
|
|
|
.sys_rst_n (sys_rst_n),
|
|
|
|
|
.key_in (key_in),
|
|
|
|
|
.key_out (key_out)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assign rx_vld = |key_out;//0001 0010 0100 1000
|
|
|
|
|
assign data_out = {4'b0000, key_out};//一字节,0x01=0000_0010
|
|
|
|
|
uart_tx uart_tx_inst(
|
|
|
|
|
.sys_clk (sys_clk) ,
|
|
|
|
|
.sys_rst_n (sys_rst_n) ,
|
|
|
|
|
.tx_din (data_out) ,//并行输入,接受模块传入
|
|
|
|
|
.rx_vld (rx_vld) ,//接受模块,串转并有效信
|
|
|
|
|
.tx_vld (tx_vld) ,
|
|
|
|
|
|
|
|
|
|
.tx_dout (tx)//串行输出
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
endmodule
|