fpga异步fifo



复制代码
module top(
    input      wire       clk  ,
    input      wire       rst_n,
    output     wire       tx   
);
//reg
reg  [7:0]cunt  ;//din
reg  [25:0]cunt_num; 
reg  [25:0]cunt1   ;
//wire 
wire      wr_clk;
wire      rd_clk;
wire      locked;
wire      rst   ;
wire      wr_en ;
wire      rd_en ;
wire [7:0]dout  ;
wire      full  ;
wire      empty ;
wire      wr_rst_busy;
wire      rd_rst_busy;
wire      vled   ;
wire      busy   ;

assign rst=(locked==1&&rst_n==1&&wr_rst_busy==0)?1'b0:1'b1;  //高电平复位开始 低电平复位不使能 系统正常运行
//产生一个计数器计数 0~9只产生一次
always @(posedge wr_clk or posedge rst) begin
    if(rst)
        cunt<=0;
    else if(cunt==11)
        cunt<=cunt;
    else
        cunt<=cunt+1;
end

assign wr_en=(cunt>1&&cunt<10&&cunt>0)?1'b1:1'b0;
always @(posedge rd_clk) begin
    if(rst)
        cunt_num<=0;
    else if(busy==0)begin
        if(cunt_num==20)
        cunt_num<=cunt_num;
        else
        cunt_num<=cunt_num+1;
        end
    else
    cunt_num<=0;
end
always @(posedge rd_clk) begin
    if(rst)
        cunt1<=0;
    else if(vled==1)
        cunt1<=cunt1+1;
    else
        cunt1<=cunt1;
end


assign rd_en=(cunt_num==8)?1'b1:1'b0;
assign vled =(cunt_num==9&&cunt1<13)?1'b1:1'b0;
clk_wiz_0 u_clk(
    // Clock out ports
    .wr_clk(wr_clk),     // output wr_clk  100mhz
    .rd_clk(rd_clk),     // output rd_clk  125mhz
    // Status and control signals
    .reset(~rst_n), // input reset
    .locked(locked),       // output locked
   // Clock in ports
    .clk_in1(clk));      // input clk_in1


fifo_generator_0 u_fifo (
  .rst(~rst_n),                  // input wire rst
  .wr_clk(wr_clk),            // input wire wr_clk
  .rd_clk(rd_clk),            // input wire rd_clk
  .din(cunt),                  // input wire [7 : 0] din
  .wr_en(wr_en),              // input wire wr_en
  .rd_en(rd_en),              // input wire rd_en
  .dout(dout),                // output wire [7 : 0] dout
  .full(full),                // output wire full
  .empty(empty),              // output wire empty
  .wr_rst_busy(wr_rst_busy),  // output wire wr_rst_busy
  .rd_rst_busy(rd_rst_busy)  // output wire rd_rst_busy
);

uart_tx#(
    /*parameter*/ . CLK_DIV(125_000_000) ,
    /*parameter*/ . BIT    (9600) 
)u_tx(
    /*input       */ . clk  (rd_clk),
    /*input       */ . rst_n(rst_n),
    /*input       */ . vled (vled ),
    /*input  [7:0]*/ . data (dout ),
    /*output  reg */ . tx   (tx   ),
                     . busy (busy ) 
    );
endmodule

前面 dout初始值就是0 因为rd_en没有使能

相关推荐
可编程芯片开发7 小时前
基于FPGA的电子万年历系统开发,包含各模块testbench
fpga开发·fpga·电子万年历
爱学习的张哥10 小时前
UDP--DDR--SFP,FPGA实现之ddr读写控制模块
网络协议·fpga开发·udp
GateWorld1 天前
深入浅出IIC协议 - 从总线原理到FPGA实战开发 -- 第一篇:I2C总线协议深度解剖
fpga开发·开源协议
爱学习的张哥1 天前
UDP--DDR--SFP,FPGA实现之模块梳理及AXI读写DDR读写上板测试
单片机·fpga开发·udp·axi·ddr
白杨树田1 天前
【EDA软件】【联合Modelsim仿真使用方法】
fpga开发
搬砖的小码农_Sky1 天前
FPGA: XILINX Kintex 7系列器件的架构
fpga开发·架构·硬件架构
搬砖的小码农_Sky2 天前
FPGA:如何提高RTL编码能力?
fpga开发·硬件架构
晶台光耦2 天前
高速光耦在通信行业的应用(五) | 5Mbps通信光耦的特性
fpga开发
梓仁沐白2 天前
Verilog HDL 语言整理
fpga开发
FPGA_ADDA2 天前
基于PXIE 总线架构的Kintex UltraScale 系列FPGA 高性能数据预处理板卡
fpga开发·pxie总线·ku060·ku115