集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 990|回复: 0

大神帮看看 o_TxD 通过示波器看看左右抖动很严重

[复制链接]
zxopen08 发表于 2016-8-9 16:38:59 | 显示全部楼层 |阅读模式
`timescale 1ns / 1ps

module Rec_commond(
                     i_clk, //20M
                      i_clk100m, //100M
                      i_rstn,
                      o_TxD,
                      ready //

    );
input i_clk,
     i_clk100m;
input i_rstn;
output o_TxD;
output ready;

reg [10:0] RegData =11'b010_1010_1010 ;
reg pos_ready;
reg pos_Sclk;
reg start;
reg sent;

reg o_TxD;
reg cnt_start;
reg [3:0] cnt_sent;
reg [3:0] state;
reg Lclk;

wire i_clk;
wire i_rstn;
wire [7:0]  k_Sclk = 8'd20;
wire [10:0] k_ready = 11'd1000;
wire Sclk;  // 1M
wire ready;//20K

/////////// ready上升沿识别
always@(posedge i_clk)
begin
   if (~i_rstn) begin
   start<=0;
   pos_ready<=0;

end
    else begin
    pos_ready <= ready;
    start <= {(~pos_ready) & ready};  
    end
end

///////////Sclk 上升沿识别
always@(posedge i_clk)
begin
   if (~i_rstn) begin
    sent<=0;
    pos_Sclk<=0;
    end
    else begin
    pos_Sclk <= Sclk;
    sent <= {(~pos_Sclk) & Sclk};
    end
end


always @(posedge i_clk)begin
  if (~i_rstn) begin
    state <= 4'b0000;
     o_TxD<=1;
     end
  else begin
  case(state)
     4'b0000: if(start)begin
                          state<=4'b0001;
                               // o_TxD <= RegData[0];
                                 end
     4'b0001: if(sent)begin
                          state<=4'b0010;
                                 o_TxD <= RegData[0];
                                 end
     4'b0010: if(sent)begin
                          state<=4'b0011;
                                 o_TxD <= RegData[1];
                                 end
     4'b0011: if(sent)begin
                          state<=4'b0100;
                                 o_TxD <= RegData[2];
                                 end
     4'b0100: if(sent)begin
                          state<=4'b0101;
                                 o_TxD <= RegData[3];
                                 end
     4'b0101: if(sent)begin
                          state<=4'b0110;
                                 o_TxD <= RegData[4];
                                 end
     4'b0110: if(sent)begin
                          state<=4'b0111;
                                 o_TxD <= RegData[5];
                                 end
     4'b0111: if(sent)begin
                          state<=4'b1000;
                                 o_TxD <= RegData[6];
                                 end
     4'b1000: if(sent)begin
                          state<=4'b1001;
                                 o_TxD <= RegData[7];
                                 end
     4'b1001: if(sent)begin
                          state<=4'b1010;
                                 o_TxD <= RegData[8];
                                 end
        4'b1010: if(sent)begin
                          state<=4'b1011;
                                 o_TxD <= RegData[9];
                                 end
        4'b1011: if(sent)begin
                          state<=4'b0000;
                                o_TxD <= RegData[10];
                                 end

    default:state<=4'b0000;
    endcase
end
end

////////////////分频得到1M Sclk

Sclk U_Sclk(
                    .i_clk(i_clk),
                    .i_rstn(i_rstn),
                    .k(k_Sclk),
                    .clkk(Sclk) //1M

    );
//////////////////分频得到ready 20k
ready U_ready(
                    .i_clk(i_clk),
                    .i_rstn(i_rstn),
                    .k(k_ready),  
                    .clkk(ready) //ready 20k

    );
endmodule
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 06:31 , Processed in 0.080509 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表