国产毛片a精品毛-国产毛片黄片-国产毛片久久国产-国产毛片久久精品-青娱乐极品在线-青娱乐精品

查看: 4876|回復(fù): 0
打印 上一主題 下一主題

[提問] 基于Verilog的串口調(diào)試,在Modelsim中仿真正常,但在FPGA開發(fā)板上沒反應(yīng)

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
發(fā)表于 2012-11-21 19:23:20 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
關(guān)鍵詞: Verilog , 串口 , FPGA , 串口調(diào)試助手
基于Verilog的串口調(diào)試,在Modelsim中仿真正常,但在FPGA開發(fā)板上用串口調(diào)試助手調(diào)試沒反應(yīng),麻煩高手指教一下。萬分感謝!

頂層文件
module ckdcwj(rst,clk,rxd,txd,data1,nclk);
input rst;
input clk;
input rxd;
output  txd;
inout [9:0] data1;
inout nclk;
wire  [9:0]  data1;
wire  nclk;
js_rxd u1(.rst(rst), .nclk(nclk), .rxd(rxd), .data1(data1));
fs_txd u2(.rst(rst), .nclk(nclk), .data1(data1), .txd(txd));
nclk   u3(.clk(clk), .rst(rst), .nclk(nclk));
endmodule

接受模塊

module js_rxd(rst,nclk,rxd,data1);
input  rst;
input  nclk;
input  rxd;
output [9:0] data1;
reg  [3:0] count1;
reg  [3:0] count2;
reg [7:0]   data;
reg  [3:0] cnt;
reg rec_reg1;
reg  rec_reg2;
reg  txdone=1'b1;
reg  [9:0]data1;
reg  [2:0] cunt=0;

parameter start=4'b0000,
          bit0=4'b1000,
    bit1=4'b1001,
    bit2=4'b1010,
    bit3=4'b1011,
    bit4=4'b1100,
    bit5=4'b1101,
    bit6=4'b1110,
    bit7=4'b1111,
    stop=4'b0010;
   
         
initial cnt<=start;
always  @(posedge nclk or negedge rst)
begin
  if(!rst)
  begin
    cunt<=0;
    rec_reg1<=1'b1;
  rec_reg2<=1'b1;
  data<=8'hzz;
  end
  else if(rec_reg1&&rec_reg2)
  begin
    rec_reg1<=rxd;
  rec_reg2<=rec_reg1;
  end
  else if(!rec_reg1&&rec_reg2&&cunt==2)
  begin
  case(cnt)
  start:cnt<=bit0;  
  bit0:begin
        if(count1)begin
            data[0]<=rxd;
            cnt<=bit1;
        end
    else cnt<=bit0;
        end
  bit1:begin
         if(count1)begin
      data[1]<=rxd;
    cnt<=bit2;
   end
   else cnt<=bit1;
   end
  bit2:begin
         if(count1)begin
      data[2]<=rxd;
    cnt<=bit3;
   end
   else cnt<=bit2;
   end
bit3:begin
         if(count1)begin
      data[3]<=rxd;
    cnt<=bit4;
   end
   else cnt<=bit3;
   end
bit4:begin
         if(count1)begin
      data[4]<=rxd;
    cnt<=bit5;
   end
   else cnt<=bit4;
   end
bit5:begin
         if(count1)begin
      data[5]<=rxd;
    cnt<=bit6;
   end
   else cnt<=bit5;
   end
bit6:begin
         if(count1)begin
      data[6]<=rxd;
    cnt<=bit7;
   end
   else cnt<=bit6;
   end
bit7:begin
        if(count1)begin
      data[7]<=rxd;
    cnt<=stop;
   end
   else cnt<=bit7;
   end
stop:begin
       if(count1)begin
  if(txdone)
        begin
         data1<={1'b1,data[7:0],1'b0};   
        cnt<=start;
  rec_reg1<=1'b1;
    rec_reg2<=1'b1;
    cunt<=0;      
    end
    end
    end   
  default:begin
       data<=8'hzz;
  rec_reg1<=1'b1;
    rec_reg2<=1'b1;
    end
endcase
  end
  else  cunt<=cunt+1;
  end
  
always @(posedge nclk or negedge rst)
begin
if(!rst)
begin
  count1<=0;
  count2<=0;
  end
  else if(count2==7)
  begin
  count2<=0;
  count1<=1;
  end
else  begin
count1<=0;
count2<=count2+1;
end
end
  endmodule

發(fā)送模塊

module fs_txd(rst,nclk,data1,txd);
input rst;
input nclk;
input [9:0] data1;
output txd;
reg  [3:0] count1;
reg  [3:0] count2;
reg  txd;
reg  [3:0] count;
parameter start=4'b0000,
          wit0=4'b1000,
          wit1=4'b1001,
    wit2=4'b1010,
    wit3=4'b1011,
    wit4=4'b1100,
    wit5=4'b1101,
    wit6=4'b1110,
    wit7=4'b1111,
    stop=4'b0001;
initial count<=start;
always @(posedge nclk or negedge rst)
begin
     if(!rst)
   txd<=1'bz;
   else if(!data1[0]) begin
   case(count)
   start:begin
         if(count1)begin
        txd<=data1[0];
        count<=wit0;
    end
    else count<=start;
        end
   wit0:begin
         if(count1)begin
        txd<=data1[1];
        count<=wit1;
    end
    else count<=wit0;
    end
   wit1:begin
         if(count1)begin
        txd<=data1[2];
    count<=wit2;
    end
    else  count<=wit1;
    end
   wit2:begin
          if(count1)begin
        txd<=data1[3];
    count<=wit3;
    end
    else  count<=wit2;
    end
  wit3:begin
         if(count1)begin
        txd<=data1[4];
    count<=wit4;
    end
    else  count<=wit3;
    end
  wit4:begin
        if(count1)begin
        txd<=data1[5];
    count<=wit5;
    end
    else  count<=wit4;
    end
wit5:begin
        if(count1)begin
        txd<=data1[6];
    count<=wit6;
    end
    else count<=wit5;
    end
wit6:begin
        if(count1)begin
        txd<=data1[7];
    count<=wit7;
    end
    else count<=wit6;
    end
wit7:begin
         if(count1)begin
        txd<=data1[8];
    count<=stop;
    end
    else count<=wit7;
    end
  stop:begin
         if(count1)begin
         txd<=data1[9];
     count<=start;
     end
     else  count<=stop;
     end
default:txd<=1'bz;
endcase
end
end

always @(posedge nclk or negedge rst)
begin
if(!rst)
begin
  count1<=0;
  count2<=0;
  end
  else if(count2==7)
  begin
  count2<=0;
  count1<=1;
  end
else  begin
count1<=0;
count2<=count2+1;
end
end
endmodule
   
波特率發(fā)生模塊

module nclk(clk,rst,nclk);
input  clk,rst;
output  nclk;
reg nclk;
reg [15:0]  cnt;
parameter yu_clk=50000000,
mu_clk=76800;
wire [15:0] step=yu_clk/mu_clk-1;
always @( clk or  rst)
begin
if(!rst)
begin
nclk<=0;
cnt<=0;
end
else if(cnt==step)
begin
nclk<=~nclk;
cnt<=0;
end
else
cnt<=cnt+1;
end
endmodule

仿真結(jié)果
[img]file:///C:/Users/Administrator/AppData/Roaming/Tencent/Users/1727445957/QQ/WinTemp/RichOle/NTSB%7DOD[K]U6~P@%60K_X_2IG.jpg[/img]

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

關(guān)于我們  -  服務(wù)條款  -  使用指南  -  站點地圖  -  友情鏈接  -  聯(lián)系我們
電子工程網(wǎng) © 版權(quán)所有   京ICP備16069177號 | 京公網(wǎng)安備11010502021702
快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 香蕉视频网站在线播放 | 丁香六月欧美 | 国产一区二区三区久久精品 | 紫色丝袜人妖被调教榨精 | 青青视频免费在线 | 麻豆国产传媒片在线看 | 在线看欧美三级中文经典 | 国产日韩欧美精品 | 免费福利在线看黄网站 | 久久99久久成人免费播放 | 欧美a∨| 国产三级在线观看完整版 | 国产一区二区三区在线观看视频 | 男啪女 | 精品欧美一区手机在线观看 | 黄色免费的网站 | 日韩高清一区二区三区五区七区 | 在线看片91 | 在线精品视频播放 | 国产美女啪啪 | 亚洲美女激情视频 | 毛片网子 | 另类专区 亚洲 | 亚洲国产成人在线 | 亚洲欧洲日韩国产一区二区三区 | 亚洲 欧美 中文 日韩欧美 | 国产成人精品影视 | 视频在线观看一区二区 | 亚洲国产成人久久 | 日韩精品久久不卡中文字幕 | 日韩精品一区二区三区毛片 | 精品欧美一区二区三区精品久久 | 欧美激情久久久久久久大片 | www.天天操 | 日本中文字幕一区二区 | 巨大挺进湿润黑人粗大视频 | 中文字幕亚洲色图 | 操欧美女| 亚洲 欧美 日韩 在线 香蕉 | 日本网站免费观看 | 精品国产亚洲人成在线 |