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
相关推荐
cjie22135 分钟前
FWFT_FIFO和Standard_FIFO对比仿真
fpga开发
9527华安1 小时前
国产紫光同创FPGA实现SDI视频编解码,基于HSSTHP高速接口,提供3套工程源码和技术支持
fpga开发·紫光同创·sdi·高速接口·hssthp
hahaha60162 小时前
ARINC818协议一些说明综述
fpga开发
_Hello_Panda_4 小时前
FX10(CYUSB4014)USB3.2(10Gbps)开发笔记分享(1):硬件设计与开发环境搭建
笔记·fpga开发·fx10·cyusb4014
FakeOccupational8 小时前
fpga系列 HDL:tips 初始化错误排查 & 仿真和实际不符的可能原因
fpga开发
FakeOccupational9 小时前
fpga系列 HDL:verilog latch在fpga中的作用 & 避免latch的常见做法
fpga开发
S&Z346310 小时前
[FPGA基础] RAM篇
fpga开发
绿算技术15 小时前
存储新势力:助力DeepSeek一体机
人工智能·科技·缓存·fpga开发
9527华安1 天前
国产紫光同创FPGA视频采集转SDI编码输出,基于HSSTHP高速接口,提供2套工程源码和技术支持
fpga开发·音视频·紫光同创·sdi·高速接口·hssthp
S&Z34631 天前
[FPGA基础] 原语简介篇
fpga开发