finish
commit
35539efd44
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,160 @@
|
||||
module ascii_trans
|
||||
#(
|
||||
parameter CLK_FRE = 'd50_000_000 , //串口通信时钟频率
|
||||
BAUD_RATE = 'd115200 //串口通信波特率
|
||||
)
|
||||
(
|
||||
input wire sys_clk ,
|
||||
input wire sys_rst_n ,
|
||||
input wire tx_device ,
|
||||
input wire cfg_done ,
|
||||
|
||||
output reg [39:0] seg_data ,
|
||||
output reg [39:0] wifi_data //接收到的wifi数据(十六进制形式表示)
|
||||
);
|
||||
|
||||
wire flag ;
|
||||
wire [7:0] data ;
|
||||
reg [7:0] unit ;
|
||||
reg [7:0] ten ;
|
||||
reg [7:0] hun ;
|
||||
reg [7:0] tho ;
|
||||
reg [7:0] t_tho ;
|
||||
reg [2:0] cnt_flag ;
|
||||
reg flag_d ;
|
||||
(*noprune*)reg [9:0] cnt ;
|
||||
|
||||
// assign seg_data = ((flag_d == 1'b1)&&(cnt_flag == 3'd0)&&({t_tho,tho,hun,ten,unit} != seg_data)) ? {t_tho,tho,hun,ten,unit} : seg_data ;
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
cnt <= 10'd0 ;
|
||||
else if(flag == 1'b1)
|
||||
cnt <= cnt + 1'b1 ;
|
||||
else
|
||||
cnt <= cnt ;
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
seg_data <= 40'hff_ffff_ffff ;
|
||||
else if((flag_d == 1'b1)&&(cnt_flag == 3'd0)&&({t_tho,tho,hun,ten,unit} != seg_data))
|
||||
seg_data <= {t_tho,tho,hun,ten,unit} ;
|
||||
else
|
||||
seg_data <= seg_data ;
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
flag_d <= 1'b0 ;
|
||||
else
|
||||
flag_d <= flag ;
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
cnt_flag <= 3'd0 ;
|
||||
else if((cnt_flag == 3'd4)&&(flag == 1'b1)&&(cfg_done == 1'b1))
|
||||
cnt_flag <= 3'd0 ;
|
||||
else if((flag == 1'b1)&&(cfg_done == 1'b1))
|
||||
cnt_flag <= cnt_flag + 1'b1 ;
|
||||
else if(cfg_done == 1'b0)
|
||||
cnt_flag <= 3'd0 ;
|
||||
else
|
||||
cnt_flag <= cnt_flag ;
|
||||
|
||||
always@(*)
|
||||
case(wifi_data[7:0])
|
||||
8'h30 : unit = 8'd0 ;
|
||||
8'h31 : unit = 8'd1 ;
|
||||
8'h32 : unit = 8'd2 ;
|
||||
8'h33 : unit = 8'd3 ;
|
||||
8'h34 : unit = 8'd4 ;
|
||||
8'h35 : unit = 8'd5 ;
|
||||
8'h36 : unit = 8'd6 ;
|
||||
8'h37 : unit = 8'd7 ;
|
||||
8'h38 : unit = 8'd8 ;
|
||||
8'h39 : unit = 8'd9 ;
|
||||
default : unit = 8'd0 ;
|
||||
endcase
|
||||
|
||||
always@(*)
|
||||
case(wifi_data[15:8])
|
||||
8'h30 : ten = 8'd0 ;
|
||||
8'h31 : ten = 8'd1 ;
|
||||
8'h32 : ten = 8'd2 ;
|
||||
8'h33 : ten = 8'd3 ;
|
||||
8'h34 : ten = 8'd4 ;
|
||||
8'h35 : ten = 8'd5 ;
|
||||
8'h36 : ten = 8'd6 ;
|
||||
8'h37 : ten = 8'd7 ;
|
||||
8'h38 : ten = 8'd8 ;
|
||||
8'h39 : ten = 8'd9 ;
|
||||
default : ten = 8'd0 ;
|
||||
endcase
|
||||
|
||||
always@(*)
|
||||
case(wifi_data[23:16])
|
||||
8'h30 : hun = 8'd0 ;
|
||||
8'h31 : hun = 8'd1 ;
|
||||
8'h32 : hun = 8'd2 ;
|
||||
8'h33 : hun = 8'd3 ;
|
||||
8'h34 : hun = 8'd4 ;
|
||||
8'h35 : hun = 8'd5 ;
|
||||
8'h36 : hun = 8'd6 ;
|
||||
8'h37 : hun = 8'd7 ;
|
||||
8'h38 : hun = 8'd8 ;
|
||||
8'h39 : hun = 8'd9 ;
|
||||
default : hun = 8'd0 ;
|
||||
endcase
|
||||
|
||||
always@(*)
|
||||
case(wifi_data[31:24])
|
||||
8'h30 : tho = 8'd0 ;
|
||||
8'h31 : tho = 8'd1 ;
|
||||
8'h32 : tho = 8'd2 ;
|
||||
8'h33 : tho = 8'd3 ;
|
||||
8'h34 : tho = 8'd4 ;
|
||||
8'h35 : tho = 8'd5 ;
|
||||
8'h36 : tho = 8'd6 ;
|
||||
8'h37 : tho = 8'd7 ;
|
||||
8'h38 : tho = 8'd8 ;
|
||||
8'h39 : tho = 8'd9 ;
|
||||
default : tho = 8'd0 ;
|
||||
endcase
|
||||
|
||||
always@(*)
|
||||
case(wifi_data[39:32])
|
||||
8'h30 : t_tho = 8'd0 ;
|
||||
8'h31 : t_tho = 8'd1 ;
|
||||
8'h32 : t_tho = 8'd2 ;
|
||||
8'h33 : t_tho = 8'd3 ;
|
||||
8'h34 : t_tho = 8'd4 ;
|
||||
8'h35 : t_tho = 8'd5 ;
|
||||
8'h36 : t_tho = 8'd6 ;
|
||||
8'h37 : t_tho = 8'd7 ;
|
||||
8'h38 : t_tho = 8'd8 ;
|
||||
8'h39 : t_tho = 8'd9 ;
|
||||
default : t_tho = 8'd0 ;
|
||||
endcase
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
wifi_data <= 40'd0 ;
|
||||
else if((flag == 1'b1)&&(cfg_done == 1'b1))
|
||||
wifi_data <= {wifi_data[31:0],data} ;
|
||||
else
|
||||
wifi_data <= wifi_data ;
|
||||
|
||||
uart_rx
|
||||
#(
|
||||
.CLK_FRE (CLK_FRE ),
|
||||
.BAUD_RATE (BAUD_RATE )
|
||||
)
|
||||
uart_rx_inst
|
||||
(
|
||||
.sys_clk (sys_clk ),
|
||||
.sys_rst_n (sys_rst_n ),
|
||||
.rx (tx_device ),
|
||||
.po_data (data ),
|
||||
.po_flag (flag )
|
||||
);
|
||||
|
||||
endmodule
|
@ -0,0 +1,18 @@
|
||||
module led_ctrl
|
||||
(
|
||||
input wire sys_clk ,
|
||||
input wire sys_rst_n ,
|
||||
input wire flag ,
|
||||
|
||||
output reg led_out
|
||||
);
|
||||
|
||||
always@(posedge sys_clk or negedge sys_rst_n)
|
||||
if(sys_rst_n == 1'b0)
|
||||
led_out <= 1'b0 ;
|
||||
else if(flag == 1'b1)
|
||||
led_out <= 1'b1 ;
|
||||
else
|
||||
led_out <= led_out ;
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue