关于FIFO Generator IP和XPM_FIFO在涉及位宽转换上的区别

news2024/11/15 11:05:04

在Xilinx FPGA中,要实现FIFO的功能时,大部分时候会使用两种方法:

  • FIFO Generator IP核
  • XPM_FIFO原语

FIFO Generator IP核的优点是有图形化界面,配置参数非常直观;缺点是参数一旦固定,想要更改的化就只能重新generate IP核。

XPM_FIFO原语的优点就是参数配置方便。

对于两者,还有一个非常重要的区别。!!!大小端不一样!!!

当din的位宽和dout的位宽非对称时。举个栗子:当din的位宽为8bit,dout的位宽为32bit时。

FIFO Generator IP核按大端输出,即先写进去的数据放在高8bit

XPM_FIFO原语按小端输出,即先写进去的数据放在低8bit

下面为RTL设计文件和测试结果。

//-----------------------------------------------------------------------------
//  
//  Copyright (c) JoeJoe.
//
//  Project  : fifo_test
//  Module   : fifo_test.v
//  Parent   : None
//  Children : None
//
//  Description: 
//     
//     
//     
//
//  Parameters:
//    
//    
//    
//
//  Local Parameters:
//
//  Notes       : 
//
//  Multicycle and False Paths
//    Some exist, embedded within the submodules. See the submodule
//    descriptions.
//

`timescale 1ns/1ps


module fifo_test (
     input sclk
    ,input srst_n
);


//***************************************************************************
// Parameter definitions
//***************************************************************************


//***************************************************************************
// Reg declarations
//***************************************************************************

    reg [2:0] wait_cnt;

    reg wr_en;
    reg [7:0] din;
    wire rd_en;
    wire prog_full;
    wire full;
    wire empty;
    wire [31:0] dout;
    
    reg xpm_wr_en;
    reg [7:0] xpm_din;
    wire xpm_rd_en;
    wire xpm_prog_full;
    wire xpm_full;
    wire xpm_empty;
    wire [31:0] xpm_dout;

//***************************************************************************
// Wire declarations
//***************************************************************************


//***************************************************************************
// Code
//***************************************************************************

    // 等待XPM FIFO not busy
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            wait_cnt <= 'd0;
        end
        else begin
            if (wait_cnt == 'd7) begin
                wait_cnt <= wait_cnt;
            end
            else begin
                wait_cnt <= wait_cnt + 'd1;
            end
        end
    end

    // 非满就写
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            wr_en <= 1'b0;
            din <= 'd0;
        end
        else begin
            if (prog_full == 1'b1) begin
                wr_en <= 1'b0;
                din <= 'd0;
            end
            else if (wait_cnt == 'd7) begin
                wr_en <= 1'b1;
                din <= din + 'd1;
            end
            else begin
                wr_en <= 1'b0;
                din <= 'd0;
            end
        end
    end

    // 非空就读
    assign rd_en = ~empty;

    // 非满就写
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            xpm_wr_en <= 1'b0;
            xpm_din <= 'd0;
        end
        else begin
            if (xpm_prog_full == 1'b1) begin
                xpm_wr_en <= 1'b0;
                xpm_din <= 'd0;
            end
            else if (wait_cnt == 'd7) begin
                xpm_wr_en <= 1'b1;
                xpm_din <= din + 'd1;
            end
            else begin
                xpm_wr_en <= 1'b0;
                xpm_din <= 'd0;
            end
        end
    end

    // 非空就读
    assign xpm_rd_en = ~xpm_empty;

    fifo_generator_0 U_FIFO_GENERATOR_0 (
         .clk              ( sclk           ) // input wire clk
        ,.srst             ( ~srst_n        ) // input wire srst
        ,.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             ( full           ) // output wire full
        ,.empty            ( empty          ) // output wire empty
        ,.prog_full        ( prog_full      ) // output wire prog_full
    );

    xpm_fifo_sync #(
        .DOUT_RESET_VALUE   ( "0"      ), // String
        .ECC_MODE           ( "no_ecc" ), // String
        .FIFO_MEMORY_TYPE   ( "block"  ), // String
        .FIFO_READ_LATENCY  ( 0        ), // DECIMAL
        .FIFO_WRITE_DEPTH   ( 1024     ), // DECIMAL
        .FULL_RESET_VALUE   ( 0        ), // DECIMAL
        .PROG_EMPTY_THRESH  ( 10       ), // DECIMAL
        .PROG_FULL_THRESH   ( 500      ), // DECIMAL
        .RD_DATA_COUNT_WIDTH( 1        ), // DECIMAL
        .READ_DATA_WIDTH    ( 32       ), // DECIMAL
        .READ_MODE          ( "fwft"   ), // String
        .SIM_ASSERT_CHK     ( 0        ), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages
        .USE_ADV_FEATURES   ( "0707"   ), // String
        .WAKEUP_TIME        ( 0        ), // DECIMAL
        .WRITE_DATA_WIDTH   ( 8        ), // DECIMAL
        .WR_DATA_COUNT_WIDTH( 1        )  // DECIMAL
     )
     U_XPM_FIFO_SYNC (
        .almost_empty   (             ), // 1-bit output: Almost Empty : When asserted, this signal indicates that
                                         // only one more read can be performed before the FIFO goes to empty.
  
        .almost_full    (             ), // 1-bit output: Almost Full: When asserted, this signal indicates that
                                         // only one more write can be performed before the FIFO is full.
  
        .data_valid     (             ), // 1-bit output: Read Data Valid: When asserted, this signal indicates
                                         // that valid data is available on the output bus (dout         ).
  
        .dbiterr        (             ), // 1-bit output: Double Bit Error: Indicates that the ECC decoder detected
                                         // a double-bit error and data in the FIFO core is corrupted.
  
        .dout           (xpm_dout     ), // READ_DATA_WIDTH-bit output: Read Data: The output data bus is driven
                                         // when reading the FIFO.
  
        .empty          (xpm_empty    ), // 1-bit output: Empty Flag: When asserted, this signal indicates that the
                                         // FIFO is empty. Read requests are ignored when the FIFO is empty,
                                         // initiating a read while empty is not destructive to the FIFO.
  
        .full           (xpm_full     ), // 1-bit output: Full Flag: When asserted, this signal indicates that the
                                         // FIFO is full. Write requests are ignored when the FIFO is full,
                                         // initiating a write when the FIFO is full is not destructive to the
                                         // contents of the FIFO.
  
        .overflow       (             ), // 1-bit output: Overflow: This signal indicates that a write request
                                         // (wren) during the prior clock cycle was rejected, because the FIFO is
                                         // full. Overflowing the FIFO is not destructive to the contents of the
                                         // FIFO.
  
        .prog_empty     (             ), // 1-bit output: Programmable Empty: This signal is asserted when the
                                         // number of words in the FIFO is less than or equal to the programmable
                                         // empty threshold value. It is de-asserted when the number of words in
                                         // the FIFO exceeds the programmable empty threshold value.
  
        .prog_full      (xpm_prog_full), // 1-bit output: Programmable Full: This signal is asserted when the
                                         // number of words in the FIFO is greater than or equal to the
                                         // programmable full threshold value. It is de-asserted when the number of
                                         // words in the FIFO is less than the programmable full threshold value.
  
        .rd_data_count  (             ), // RD_DATA_COUNT_WIDTH-bit output: Read Data Count: This bus indicates the
                                         // number of words read from the FIFO.
  
        .rd_rst_busy    (             ), // 1-bit output: Read Reset Busy: Active-High indicator that the FIFO read
                                         // domain is currently in a reset state.
  
        .sbiterr        (             ), // 1-bit output: Single Bit Error: Indicates that the ECC decoder detected
                                         // and fixed a single-bit error.
  
        .underflow      (             ), // 1-bit output: Underflow: Indicates that the read request (rd_en) during
                                         // the previous clock cycle was rejected because the FIFO is empty. Under
                                         // flowing the FIFO is not destructive to the FIFO.
  
        .wr_ack         (             ), // 1-bit output: Write Acknowledge: This signal indicates that a write
                                         // request(wr_en) during the prior clock cycle is succeeded.
  
        .wr_data_count  (             ), // WR_DATA_COUNT_WIDTH-bit output: Write Data Count: This bus indicates
                                         // the number of words written into the FIFO.
  
        .wr_rst_busy    (             ), // 1-bit output: Write Reset Busy: Active-High indicator that the FIFO
                                         // write domain is currently in a reset state.
  
        .din            (xpm_din      ), // WRITE_DATA_WIDTH-bit input: Write Data: The input data bus used when
                                         // writing the FIFO.
  
        .injectdbiterr  (1'b0         ), // 1-bit input: Double Bit Error Injection: Injects a double bit error if
                                         // the ECC feature is used on block RAMs or UltraRAM macros.
  
        .injectsbiterr  (1'b0         ), // 1-bit input: Single Bit Error Injection: Injects a single bit error if
                                         // the ECC feature is used on block RAMs or UltraRAM macros.
  
        .rd_en          (xpm_rd_en    ), // 1-bit input: Read Enable: If the FIFO is not empty, asserting this
                                         // signal causes data(on dout) to be read from the FIFO. Must be held
                                         // active-low when rd_rst_busy is active high.
  
        .rst            (~srst_n      ), // 1-bit input: Reset: Must be synchronous to wr_clk. The clock(s) can be
                                         // unstable at the time of applying reset, but reset must be released only
                                         // after the clock(s) is/are stable.
  
        .sleep          (1'b0         ), // 1-bit input: Dynamic power saving- If sleep is High, the memory/fifo
                                         // block is in power saving mode.
  
        .wr_clk         (sclk         ), // 1-bit input: Write clock: Used for write operation. wr_clk must be a
                                         // free running clock.
  
        .wr_en          (xpm_wr_en    )  // 1-bit input: Write Enable: If the FIFO is not full, asserting this
                                         // signal causes data(on din) to be written to the FIFO Must be held
                                         // active-low when rst or wr_rst_busy or rd_rst_busy is active high
     );      

endmodule

32bit写,8bit读
当din的位宽和dout的位宽非对称时。举个栗子:当din的位宽为32bit,dout的位宽为8bit时。

FIFO Generator IP核 高8bit先输出,低8bit最后输出

XPM_FIFO原语 低8bit先输出,高8bit最后输出

下面为RTL设计文件和测试结果。

//-----------------------------------------------------------------------------
//  
//  Copyright (c) JoeJoe.
//
//  Project  : fifo_test
//  Module   : fifo_test.v
//  Parent   : None
//  Children : None
//
//  Description: 
//     
//     
//     
//
//  Parameters:
//    
//    
//    
//
//  Local Parameters:
//
//  Notes       : 
//
//  Multicycle and False Paths
//    Some exist, embedded within the submodules. See the submodule
//    descriptions.
//

`timescale 1ns/1ps


module fifo_test (
     input sclk
    ,input srst_n
);


//***************************************************************************
// Parameter definitions
//***************************************************************************


//***************************************************************************
// Reg declarations
//***************************************************************************

    reg [2:0] wait_cnt;

    reg wr_en;
    reg [31:0] din;
    wire rd_en;
    wire prog_full;
    wire full;
    wire empty;
    wire [7:0] dout;
    
    reg xpm_wr_en;
    reg [31:0] xpm_din;
    wire xpm_rd_en;
    wire xpm_prog_full;
    wire xpm_full;
    wire xpm_empty;
    wire [7:0] xpm_dout;

//***************************************************************************
// Wire declarations
//***************************************************************************


//***************************************************************************
// Code
//***************************************************************************

    // 等待XPM FIFO not busy
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            wait_cnt <= 'd0;
        end
        else begin
            if (wait_cnt == 'd7) begin
                wait_cnt <= wait_cnt;
            end
            else begin
                wait_cnt <= wait_cnt + 'd1;
            end
        end
    end

    // 非满就写
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            wr_en <= 1'b0;
            din <= 'd0;
        end
        else begin
            if (prog_full == 1'b1) begin
                wr_en <= 1'b0;
                din <= din;
            end
            else if (wait_cnt == 'd7) begin
                wr_en <= 1'b1;
                din <= din + 'd1;
            end
            else begin
                wr_en <= 1'b0;
                din <= 'd0;
            end
        end
    end

    // 非空就读
    assign rd_en = ~empty;

    // 非满就写
    always @(posedge sclk) begin
        if (srst_n == 1'b0) begin
            xpm_wr_en <= 1'b0;
            xpm_din <= 'd0;
        end
        else begin
            if (xpm_prog_full == 1'b1) begin
                xpm_wr_en <= 1'b0;
                xpm_din <= xpm_din;
            end
            else if (wait_cnt == 'd7) begin
                xpm_wr_en <= 1'b1;
                xpm_din <= xpm_din + 'd1;
            end
            else begin
                xpm_wr_en <= 1'b0;
                xpm_din <= 'd0;
            end
        end
    end

    // 非空就读
    assign xpm_rd_en = ~xpm_empty;

    // fifo_generator_0 U_FIFO_GENERATOR_0 (
    //      .clk              ( sclk           ) // input wire clk
    //     ,.srst             ( ~srst_n        ) // input wire srst
    //     ,.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             ( full           ) // output wire full
    //     ,.empty            ( empty          ) // output wire empty
    //     ,.prog_full        ( prog_full      ) // output wire prog_full
    // );

    fifo_generator_1 U_FIFO_GENERATOR_1 (
         .clk              ( sclk           ) // input wire clk
        ,.srst             ( ~srst_n        ) // input wire srst
        ,.din              ( din            ) // input wire [31 : 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
        ,.prog_full        ( prog_full      ) // output wire prog_full
      );

    xpm_fifo_sync #(
        .DOUT_RESET_VALUE   ( "0"      ), // String
        .ECC_MODE           ( "no_ecc" ), // String
        .FIFO_MEMORY_TYPE   ( "block"  ), // String
        .FIFO_READ_LATENCY  ( 0        ), // DECIMAL
        .FIFO_WRITE_DEPTH   ( 256      ), // DECIMAL
        .FULL_RESET_VALUE   ( 0        ), // DECIMAL
        .PROG_EMPTY_THRESH  ( 10       ), // DECIMAL
        .PROG_FULL_THRESH   ( 125      ), // DECIMAL
        .RD_DATA_COUNT_WIDTH( 1        ), // DECIMAL
        .READ_DATA_WIDTH    ( 8        ), // DECIMAL
        .READ_MODE          ( "fwft"   ), // String
        .SIM_ASSERT_CHK     ( 0        ), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages
        .USE_ADV_FEATURES   ( "0707"   ), // String
        .WAKEUP_TIME        ( 0        ), // DECIMAL
        .WRITE_DATA_WIDTH   ( 32       ), // DECIMAL
        .WR_DATA_COUNT_WIDTH( 1        )  // DECIMAL
     )
     U_XPM_FIFO_SYNC (
        .almost_empty   (             ), // 1-bit output: Almost Empty : When asserted, this signal indicates that
                                         // only one more read can be performed before the FIFO goes to empty.
  
        .almost_full    (             ), // 1-bit output: Almost Full: When asserted, this signal indicates that
                                         // only one more write can be performed before the FIFO is full.
  
        .data_valid     (             ), // 1-bit output: Read Data Valid: When asserted, this signal indicates
                                         // that valid data is available on the output bus (dout         ).
  
        .dbiterr        (             ), // 1-bit output: Double Bit Error: Indicates that the ECC decoder detected
                                         // a double-bit error and data in the FIFO core is corrupted.
  
        .dout           (xpm_dout     ), // READ_DATA_WIDTH-bit output: Read Data: The output data bus is driven
                                         // when reading the FIFO.
  
        .empty          (xpm_empty    ), // 1-bit output: Empty Flag: When asserted, this signal indicates that the
                                         // FIFO is empty. Read requests are ignored when the FIFO is empty,
                                         // initiating a read while empty is not destructive to the FIFO.
  
        .full           (xpm_full     ), // 1-bit output: Full Flag: When asserted, this signal indicates that the
                                         // FIFO is full. Write requests are ignored when the FIFO is full,
                                         // initiating a write when the FIFO is full is not destructive to the
                                         // contents of the FIFO.
  
        .overflow       (             ), // 1-bit output: Overflow: This signal indicates that a write request
                                         // (wren) during the prior clock cycle was rejected, because the FIFO is
                                         // full. Overflowing the FIFO is not destructive to the contents of the
                                         // FIFO.
  
        .prog_empty     (             ), // 1-bit output: Programmable Empty: This signal is asserted when the
                                         // number of words in the FIFO is less than or equal to the programmable
                                         // empty threshold value. It is de-asserted when the number of words in
                                         // the FIFO exceeds the programmable empty threshold value.
  
        .prog_full      (xpm_prog_full), // 1-bit output: Programmable Full: This signal is asserted when the
                                         // number of words in the FIFO is greater than or equal to the
                                         // programmable full threshold value. It is de-asserted when the number of
                                         // words in the FIFO is less than the programmable full threshold value.
  
        .rd_data_count  (             ), // RD_DATA_COUNT_WIDTH-bit output: Read Data Count: This bus indicates the
                                         // number of words read from the FIFO.
  
        .rd_rst_busy    (             ), // 1-bit output: Read Reset Busy: Active-High indicator that the FIFO read
                                         // domain is currently in a reset state.
  
        .sbiterr        (             ), // 1-bit output: Single Bit Error: Indicates that the ECC decoder detected
                                         // and fixed a single-bit error.
  
        .underflow      (             ), // 1-bit output: Underflow: Indicates that the read request (rd_en) during
                                         // the previous clock cycle was rejected because the FIFO is empty. Under
                                         // flowing the FIFO is not destructive to the FIFO.
  
        .wr_ack         (             ), // 1-bit output: Write Acknowledge: This signal indicates that a write
                                         // request(wr_en) during the prior clock cycle is succeeded.
  
        .wr_data_count  (             ), // WR_DATA_COUNT_WIDTH-bit output: Write Data Count: This bus indicates
                                         // the number of words written into the FIFO.
  
        .wr_rst_busy    (             ), // 1-bit output: Write Reset Busy: Active-High indicator that the FIFO
                                         // write domain is currently in a reset state.
  
        .din            (xpm_din      ), // WRITE_DATA_WIDTH-bit input: Write Data: The input data bus used when
                                         // writing the FIFO.
  
        .injectdbiterr  (1'b0         ), // 1-bit input: Double Bit Error Injection: Injects a double bit error if
                                         // the ECC feature is used on block RAMs or UltraRAM macros.
  
        .injectsbiterr  (1'b0         ), // 1-bit input: Single Bit Error Injection: Injects a single bit error if
                                         // the ECC feature is used on block RAMs or UltraRAM macros.
  
        .rd_en          (xpm_rd_en    ), // 1-bit input: Read Enable: If the FIFO is not empty, asserting this
                                         // signal causes data(on dout) to be read from the FIFO. Must be held
                                         // active-low when rd_rst_busy is active high.
  
        .rst            (~srst_n      ), // 1-bit input: Reset: Must be synchronous to wr_clk. The clock(s) can be
                                         // unstable at the time of applying reset, but reset must be released only
                                         // after the clock(s) is/are stable.
  
        .sleep          (1'b0         ), // 1-bit input: Dynamic power saving- If sleep is High, the memory/fifo
                                         // block is in power saving mode.
  
        .wr_clk         (sclk         ), // 1-bit input: Write clock: Used for write operation. wr_clk must be a
                                         // free running clock.
  
        .wr_en          (xpm_wr_en    )  // 1-bit input: Write Enable: If the FIFO is not full, asserting this
                                         // signal causes data(on din) to be written to the FIFO Must be held
                                         // active-low when rst or wr_rst_busy or rd_rst_busy is active high
     );      

endmodule

8bit写,32bit读
参考文档如下:《FIFO Generator v13.2 Product Guide》(PG057)
FIFO Generator IP
支持的非对称比

FIFO Generator IP,小位宽写,大位宽读,大端。
大转小
大转小时序图
FIFO Generator IP,大位宽写,小位宽读。
小转大
小转大时序图
疑问:XPM_FIFO为什么不可以设置大小端,以及为什么不和FIFO Generator IP统一???

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1678541.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【大数据】计算引擎MapReduce

目录 1.概述 1.1.前言 1.2.大数据要怎么计算&#xff1f; 1.3.什么是MapReduce&#xff1f; 2.架构 3.工作流程 4.shuffle 4.1.map过程 4.2.reduce过程 1.概述 1.1.前言 本文是作者大数据系列专栏的其中一篇&#xff0c;专栏地址&#xff1a; https://blog.csdn.ne…

AI交互数字人赋能农业数字化、智能化推广营销

2024陵水荔枝文化节上“数字新农人”陵小荔身着黎族服饰、佩戴银器亮相开幕式现场&#xff0c;AI交互数字人生动地以互动式推介和歌舞等形式&#xff0c;带领宾客们了解陵水荔枝的发展历程、产业布局、未来愿景等。如今&#xff0c;越来越多农产品品牌通过3D虚拟数字人定制&…

声纹识别的对抗与防御

随着机器学习理论和方法的发展, 出现了用于模仿特定说话人语音的深度伪造、针对语音识别和声纹识别的对抗样本, 它们都为破坏语音载体的可信性和安全性提供了具体手段, 进而对各自应用场景的信息安全构成了挑战。 深度伪造是利用生成式对抗网络等方法, 通过构建特定的模型, 产生…

用HAL库改写江科大的stm32入门例子4-1 OLED

大体 步骤&#xff1a; step1&#xff1a;使用STM32CubeMX初始化I2C1&#xff0c;生成初始化代码 step2&#xff1a;将任意一个库导入到工程&#xff0c;配置好编译路径 step3&#xff1a;调用函数即可 IIC原理图&#xff1a; 接线图&#xff1a; 先设置clock&#xff1a; 开…

GPT-4o模型介绍和使用方法

大家好,我是herosunly。985院校硕士毕业,现担任算法研究员一职,热衷于机器学习算法研究与应用。曾获得阿里云天池比赛第一名,CCF比赛第二名,科大讯飞比赛第三名。拥有多项发明专利。对机器学习和深度学习拥有自己独到的见解。曾经辅导过若干个非计算机专业的学生进入到算法…

VBA直连SAP RFC 接口实例

引用依赖: VBA 调用 SAP API的RFC函数:RFC_READ_TABLE Sub A() 查询SAP表数据并输出到EXCEL,VBA中不区分大小写(保存后会自动把代码、变量转换大小写)Dim iData As Integer Dim nField As Integer Dim nData As Integer Dim Result As Boolean Dim vRow As Variant MsgBox…

Socks5:网络世界的隐形斗篷

在数字化时代&#xff0c;网络隐私和安全已成为人们日益关注的话题。Socks5&#xff0c;作为一种代理协议&#xff0c;为用户在网络世界中的匿名性提供了强有力的支持。本文将从Socks5的多个方面&#xff0c;深入探讨这一技术如何成为网络世界的“隐形斗篷”。 一、Socks5的基本…

如何在WordPress中启用两因素身份验证?

在WordPress中启用两因素身份验证方法&#xff1a;安装和激活WordFence安全性、启用两因素验证。 使用您可以从任何位置登录的任何门户&#xff0c;建议启用两个因素身份验证以增加帐户的安全性。 这样&#xff0c;即使有人可以正确猜测你的密码&#xff0c;它们仍然需要获得2…

代码随想录算法训练营第四十八天|121. 买卖股票的最佳时机 、122.买卖股票的最佳时机II

121. 买卖股票的最佳时机 思路&#xff1a; 动规五部曲分析如下&#xff1a; 1.确定dp数组&#xff08;dp table&#xff09;以及下标的含义 dp[i][0] 表示第i天持有股票所得最多现金 &#xff0c;这里可能有同学疑惑&#xff0c;本题中只能买卖一次&#xff0c;持有股票之…

队列的实现与OJ题目解析

"不是你变优秀了, 那个人就会喜欢你." 文章索引 前言1. 什么是队列2. 队列的实现3. OJ题目解析4. 总结 前言 感情可以培养是个伪命题. 如果有足够多的时间和爱, 就可以让另一个人爱上你的话, 那谁和谁都可以相爱了. 爱情之所以会让人死去活来, 是因为, 答案都写在了…

虚拟化技术 安装和配置StartWind iSCSI目标服务器

一、实验内容 安装StartWind iSCSI目标服务器配置StartWind iSCSI目标服务器 二、实验主要仪器设备及材料 安装有64位Windows操作系统的台式电脑或笔记本电脑&#xff0c;建议4C8G或以上配置已安装vSphere Client已创建虚拟机并在其上安装CentOS6.5StarWind安装介质starwind.…

VUE如何实现批量下载多个文件并导出zip格式

效果图 1、安装jszip和file-saver插件 npm install jszip npm install file-saver2、在所需页面引入 import JSZip from "jszip"; import FileSaver from "file-saver";3、模拟fileList数组 //fileList模拟文件数组export default {name: "notic…

react18【系列实用教程】useMemo —— 缓存数据 (2024最新版)

为什么添加了 memo &#xff0c;子组件2依然重新渲染了呢&#xff1f; 因为父组件向子组件2传递了引用类型的数据 const userInfo {name: "朝阳",};<Child2 userInfo{userInfo} />memo() 函数的本质是通过校验Props中数据的内存地址是否改变来决定组件是否重新…

《米小圈动画成语》—和孩子一起意动“神州”成语连击!

成语有着独特的语言魅力&#xff0c;以其源远流长、凝练浓缩、概括力强而历久弥新,久盛不衰&#xff0c;是中华民族特有的文化现象。成语既是语言文字符号&#xff0c;又具有无穷的艺术魅力。在表情达意、传递高质量语言信息方面起着以一当十的作用。成语的结构严谨、言简意赅&…

动规解决01背包/完全背包精讲

还不会用动态规划解决01背包/完全背包&#xff1f;看这一篇文章就够了&#xff01; 首先我们要明白什么是01背包和完全背包。 背包问题总体问法就是&#xff1a; 你有一个背包&#xff0c;最多能容纳的体积是V。 现在有n个物品&#xff0c;第i个物品的体积为vi​ ,价值为wi​…

2023年数维杯国际大学生数学建模挑战赛D题洗衣房清洁计算解题全过程论文及程序

2023年数维杯国际大学生数学建模挑战赛 D题 洗衣房清洁计算 原题再现&#xff1a; 洗衣房清洁是人们每天都要做的事情。洗衣粉的去污作用来源于一些表面活性剂。它们可以增加水的渗透性&#xff0c;并利用分子间静电排斥机制去除污垢颗粒。由于表面活性剂分子的存在&#xff…

zip压缩unzip解压缩、gzip和gunzip解压缩、tar压缩和解压缩

一、tar压缩和解压缩 tar [选项] 打包文件名 源文件或目录 选项含义-c创建新的归档文件-x从归档文件中提取文件-v显示详细信息-f指定归档文件的名称-z通过gzip进行压缩或解压缩-j通过bzip2进行压缩或解压缩-J通过xz进行压缩或解压缩-p保留原始文件的权限和属性–excludePATTE…

查看Linux服务器的硬盘占用情况

查看Linux服务器的硬盘占用情况 一、查看各分区的使用情况和磁盘挂载1、查看磁盘分区使用和磁盘挂载2、结果解释&#xff08;1&#xff09;列名解释&#xff08;2&#xff09;各系统解释 二、查看一个目录及其所有子目录中文件的总占用大小1、查看指定目录的总大小2、列出目录下…

2024/5/15 英语每日一段

Many pet owners are now turning to pet insurance policies to avoid higher vet bills should something bad happen unexpectedly. But Carlson said that preventive veterinary care—like vaccination, parasite control and weight management—is "the best way …

【REST2SQL】14 基于角色的数据权限设计与实现

【REST2SQL】01RDB关系型数据库REST初设计 【REST2SQL】02 GO连接Oracle数据库 【REST2SQL】03 GO读取JSON文件 【REST2SQL】04 REST2SQL第一版Oracle版实现 【REST2SQL】05 GO 操作 达梦 数据库 【REST2SQL】06 GO 跨包接口重构代码 【REST2SQL】07 GO 操作 Mysql 数据库 【RE…