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
相关推荐
红糖果仁沙琪玛1 天前
fpga iic协议
fpga开发
嵌入式-老费1 天前
Zynq开发实践(FPGA之pwm输出)
fpga开发
hexiaoyan8271 天前
光纤加速的板卡设计原理图:基于6U VPX XCVU9P+XCZU7EV的双FMC信号处理板卡
嵌入式硬件·fpga开发·光纤加速板卡·国产化板卡·xcvu9p板卡·xcvu9p
XiaoChaoZhiNeng1 天前
Altera Quartus17.1 Modelsim 库编译与仿真
fpga开发
燎原星火*2 天前
FPGA复位
fpga开发
博览鸿蒙2 天前
FPGA笔试面试常考问题及答案汇总
fpga开发
9527华安2 天前
FPGA实现Aurora 64B66B图像视频点对点传输,基于GTY高速收发器,提供2套工程源码和技术支持
fpga开发·音视频·aurora·高速收发器·gty·64b66b·点对点传输
博览鸿蒙2 天前
入行FPGA选择国企、私企还是外企?
fpga开发
红糖果仁沙琪玛2 天前
FPGA实现流水式排序算法
算法·fpga开发·排序算法
陌夏微秋2 天前
FPGA硬件设计4 ZYNQ外围-以太网-PL/PS
stm32·单片机·嵌入式硬件·fpga开发·硬件架构·硬件工程·信息与通信