完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
modelsim里仿真出现的问题,网上的也看了一些,不太懂,找不到解决方法呀,求大神帮一下忙 uart的tx模块: module data_tx(clk_bps,reset,tx_en,data_from_fifo,flag_tx,data_to_rs232); input clk_bps,reset,tx_en;//tx_en±íʾ·¢ËÍʹÄÜÐźţ¬1±íʾÓÐЧ input [7:0]data_from_fifo; output reg flag_tx;//·¢ËͱêÖ¾£¬1±íʾ·¢ËÍÍê³É output wire data_to_rs232;//´®ÐÐÊý¾ÝÊä³ö reg data_tx; reg busy_tx;//1±íʾ·¢ËÍ״̬棬0±íʾ¿ÕÏÐ reg [7:0]data_tx_reg; reg [3:0]cnt_tx; reg n_state; reg c_state; always@(posedge clk_bps or negedge reset) begin if(!reset) cnt_tx<=4'd0; else if(cnt_tx==4'd10) cnt_tx<=4'd0; else cnt_tx<=cnt_tx+1'b1; end parameter idle=1; parameter tx_state=2; parameter tx_done=3; assign data_to_rs232=data_tx; always@(posedge clk_bps or negedge reset) begin if(!reset) c_state<=idle; else c_state<=n_state; end always@(posedge clk_bps or negedge reset) begin if(!reset) begin cnt_tx<=4'd0; busy_tx<=1'b0; flag_tx<=1'b0; end else case(c_state) idle: begin cnt_tx<=4'd0; busy_tx<=1'b0; flag_tx<=1'b0; data_tx<=1'b1; end tx_state: begin case(cnt_tx) 0: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=1'b0; end 1: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[0]; end 2: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[1]; end 3: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[2]; end 4: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[3]; end 5: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[4]; end 6: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[5]; end 7: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[6]; end 8: begin cnt_tx<=cnt_tx+1'b1; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=data_from_fifo[7]; end 9: begin cnt_tx<=4'd0; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=1'b1; end default: begin cnt_tx<=4'd0; busy_tx<=1'b1; flag_tx<=1'b0; data_tx<=1'b1; end endcase end tx_done: begin cnt_tx<=4'd0; busy_tx<=1'b1; flag_tx<=1'b1; data_tx<=1'b1; end default: begin cnt_tx<=4'd0; busy_tx<=1'b0; flag_tx<=1'b0; data_tx<=1'b1; end endcase end always@(c_state) begin case(c_state) idle: begin if(!busy_tx&tx_en)//·¢ËÍʹÄÜÓÐЧ²¢ÇÒ·¢ËͲ»Ã¦ c_state<=tx_state; else c_state<=idle; end tx_state: begin if(cnt_tx==4'd9) c_state<=tx_done; else c_state<=tx_state; end tx_done: begin c_state<=idle; end default:c_state<=idle; endcase end endmodule ........................................................................................................................................................ tx模块的测试模块: `timescale 10ps/1ps module data_tx_tb(); reg clk_bps,reset,tx_en; reg [7:0]data_from_fifo; wire flag_tx,data_to_rs232; data_tx tx_tb(.clk_bps(clk_bps),.reset(reset),.tx_en(tx_en),.data_from_fifo(data_from_fifo), .flag_tx(flag_tx),.data_to_rs232(data_to_rs232)); always begin #1 clk_bps<=~clk_bps; end initial begin clk_bps<=1'b0; reset<=1'b0; tx_en<=1'b0; data_from_fifo<=8'd0; #10 data_from_fifo<=8'd1; #2 reset<=1'b1; #10 tx_en<=1'b1; #10 data_from_fifo<=8'd2; #50 data_from_fifo<=8'd3; #50 data_from_fifo<=8'd4; #50 data_from_fifo<=8'd5; #50 data_from_fifo<=8'd6; #50 data_from_fifo<=8'd7; #50 data_from_fifo<=8'd8; #50 data_from_fifo<=8'd9; #50 data_from_fifo<=8'd10; #50 data_from_fifo<=8'd11; #50 data_from_fifo<=8'd12; #50 data_from_fifo<=8'd13; #50 data_from_fifo<=8'd14; #50 data_from_fifo<=8'd15; #50 data_from_fifo<=8'd16; #10tx_en<=1'b0; #20 data_from_fifo<=8'd1; end endmodule |
|
相关推荐
2个回答
|
|
|
|
|
|
出现什么问题描述清楚一点啊
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1226 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1027 浏览 0 评论
2292 浏览 1 评论
2008 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
2263 浏览 0 评论
1777 浏览 47 评论
6000 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 04:59 , Processed in 0.466712 second(s), Total 39, Slave 32 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号