在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2207|回复: 0

[求助] 大神求帮助 o_TxD脚用示波器看左右抖动很厉害

[复制链接]
发表于 2016-7-18 23:19:21 | 显示全部楼层 |阅读模式
2资产
大神求帮助
o_TxD脚用示波器看左右抖动很厉害
`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;
wire ready;

/////////// ready  20k上升沿识别
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 1M上升沿识别
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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-21 08:54 , Processed in 0.016442 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表