FIFO 位宽转换

从8位转32位

c 复制代码
module tb_fifo(

    );

reg clk,rst;   
initial begin
    clk=0;
    forever #4.545 clk=~clk;
end
initial begin
    rst=1;
    #9.09 rst=0;
end

reg [31:0] cnts;
always @ (posedge clk or posedge rst)
begin
    if(rst)
    begin
    cnts <= 32'd0;
    end
    
    else
    begin
    cnts <= cnts + 1'b1;
    end
end

reg  [7:0] din;
reg  wr_en;

reg  rd_en;
wire [31:0] dout;

wire [12:0] rd_data_count;
wire [14:0] wr_data_count;

fifo_ICBR_8_32 FIFO (
  .rst(rst),                      // input wire rst
  .wr_clk(clk),                // input wire wr_clk
  .rd_clk(clk),                // input wire rd_clk
  .din(din),                      // 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 [31 : 0] dout
  .full( ),                    // output wire full
  .empty( ),                  // output wire empty
  .rd_data_count(rd_data_count),  // output wire [12 : 0] rd_data_count
  .wr_data_count(wr_data_count)  // output wire [14 : 0] wr_data_count
);

always @ (posedge clk or posedge rst)
begin
    if(rst)
    begin
    din <= 8'd0;
    wr_en <= 1'b0;
    rd_en <= 1'b0;
    end
    
    else
    begin
    case(cnts)
    32'd33: begin din<=8'h11;wr_en<=1'b1; end
    32'd34: begin din<=8'h22;wr_en<=1'b1; end
    32'd35: begin din<=8'h33;wr_en<=1'b1; end
    32'd36: begin din<=8'h44;wr_en<=1'b1; end
    32'd37: begin            wr_en<=1'b0; end
    32'd60: begin rd_en<=1'b1; end
    32'd61: begin rd_en<=1'b0; end
    default:begin din<=din;wr_en<=wr_en;rd_en<=rd_en; end
    endcase
    end
end
相关推荐
apple_ttt17 小时前
从零开始讲PCIe(6)——PCI-X概述
fpga开发·fpga·pcie
水饺编程19 小时前
【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,1-2
linux·嵌入式硬件·fpga开发
apple_ttt20 小时前
从零开始讲PCIe(5)——66MHZ的PCI总线与其限制
fpga开发·fpga·pcie
最好有梦想~1 天前
FPGA时序分析和约束学习笔记(2、FPGA时序传输模型)
fpga开发
IM_DALLA1 天前
【Verilog学习日常】—牛客网刷题—Verilog企业真题—VL76
学习·fpga开发
诚实可靠小郎君95271 天前
FPGA IO延迟的约束与脚本
fpga开发·fpga·数字电路
GGGLF2 天前
FPGA-UART串口接收模块的理解
fpga开发
北京太速科技股份有限公司2 天前
太速科技-495-定制化仪器户外便携式手提触摸一体机
fpga开发
9527华安2 天前
FPGA实现PCIE图片采集转HDMI输出,基于XDMA中断架构,提供3套工程源码和技术支持
fpga开发·pcie·xdma·hdmi
水饺编程2 天前
简易CPU设计入门:取指令(三),ip_buf与rd_en的非阻塞赋值
fpga开发