FPGA模块——IIC接口设计

FPGA模块——IIC接口设计

  • IIC协议
  • IIC接口代码
  • 应用IIC接口的代码

IIC协议

在这里插入图片描述
在这里插入图片描述

IIC接口代码


module iic_drive#(parameter           P_ADDR_WIDTH = 16                      
)(              input               i_clk                   ,//模块输入时钟input               i_rst                   ,//模块输入复位-高有效/*--------用户接口--------*/input  [6 :0]       i_drive                 ,//用户输入设备地址input  [15:0]       i_operation_addr        ,//用户输入存储地址input  [7 :0]       i_operation_len         ,//用户输入读写长度input  [1 :0]       i_operation_type        ,//用户输入操作类型input               i_opeartion_valid       ,//用户输入有效信号output              o_operation_ready       ,//用户输出准备信号input  [7 :0]       i_write_data            ,//用户输入写数据output              o_write_req             ,//用户写数据请求信号output [7 :0]       o_read_data             ,//输出IIC读到的数据output              o_read_valid            ,//输出IIC读数据有效/*--------IIC接口--------*/output              o_iic_scl               ,//IIC的时钟inout               io_iic_sda               //IIC的双向数据项
);/***************function**************//***************parameter*************/
parameter               P_ST_IDLE   = 0         ,//状态机-空闲P_ST_START  = 1         ,//状态机-起始P_ST_UADDR  = 2         ,//状态机-设备地址P_ST_DADDR1 = 3         ,//状态机-存储地址高位P_ST_DADDR2 = 4         ,//状态机-存储地址地位P_ST_WRITE  = 5         ,//状态机-写数据P_ST_RESTART= 6         ,P_ST_READ   = 7         ,//状态机-读数据P_ST_WAIT   = 8         ,P_ST_STOP   = 9         ,//状态机-停止P_ST_EMPTY  = 10        ;localparam              P_W =   1               ,//2'b01P_R =   2               ;//2'b10/***************port******************/             /***************mechine***************/
reg  [7 :0]             r_st_current            ;//当前状态机
reg  [7 :0]             r_st_next               ;//下一个状态机
reg  [7 :0]             r_st_cnt                ;//状态机计数器/***************reg*******************/
reg                     ro_operation_ready      ;//操作准备信号
reg                     ro_write_req            ;//写数据请求
reg                     ro_write_valid          ;//写数据有效
reg  [7 :0]             ro_read_data            ;//读数据
reg                     ro_read_valid           ;//读数据有效
reg                     ro_iic_scl              ;//IIC的SCL输出寄存器
reg  [7 :0]             ri_drive                ;//输入的设备地址
reg  [15:0]             ri_operation_addr       ;//输入的存储地址
reg  [7 :0]             ri_operation_len        ;//输入的读写长度
reg  [1 :0]             ri_operation_type       ;//输入读写类型
reg  [7 :0]             ri_write_data           ;//输入的写数据
reg                     r_iic_st                ;//iic时钟状态
reg                     r_iic_sda_ctrl          ;//iic数据三态门控制信号
reg                     ro_iic_sda              ;//iic数据信号
reg  [7 :0]             r_wr_cnt                ;//读写数据bit计数器
reg                     r_slave_ack             ;//iic操作里的从机应答
reg                     r_ack_valid             ;//应答有效
reg                     r_st_restart            ;
reg                     r_ack_lock              ;
reg  [7 :0]             r_read_drive            ;/***************wire******************/
wire                    w_operation_active      ;//操作激活信号
wire                    w_st_trun               ;//状态机跳转信号
wire                    w_iic_sda               ;//iic数据线输入信号/***************component*************//***************assign****************/
assign o_operation_ready    = ro_operation_ready    ;//准备信号
assign o_write_req          = ro_write_req          ;//写数据请求信号
assign o_read_data          = ro_read_data          ;//读数据
assign o_read_valid         = ro_read_valid         ;//读数据有效
assign o_iic_scl            = ro_iic_scl            ;//iic的scl
assign w_operation_active   = i_opeartion_valid & o_operation_ready ;//激活信号
assign w_st_trun            = r_st_cnt == 8 && r_iic_st             ;//状态机跳转条件
//三态门使用
assign io_iic_sda           = r_iic_sda_ctrl  ? ro_iic_sda : 1'bz   ;//三态门输出
assign w_iic_sda            = !r_iic_sda_ctrl ? io_iic_sda : 1'b0   ;//三态门输入// IOBUF #(
//    .DRIVE           (12                 ),
//    .IBUF_LOW_PWR    ("TRUE"             ),
//    .IOSTANDARD      ("DEFAULT"          ),
//    .SLEW            ("SLOW"             ) 
// ) 
// IOBUF_u0 
// (      
//    .O               (ro_iic_sda         ),  
//    .IO              (io_iic_sda         ),  
//    .I               (w_iic_sda          ),  
//    .T               (!r_iic_sda_ctrl    )   
// );/***************always****************/
//第一段状态
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_st_current <= P_ST_IDLE;else r_st_current <= r_st_next;
end//状态机跳转
always@(*)
begincase(r_st_current)P_ST_IDLE   : r_st_next <= w_operation_active   ? P_ST_START    : P_ST_IDLE     ;//空闲,操作激活时跳转到起始状态P_ST_START  : r_st_next <= P_ST_UADDR;                                           //起始状态,跳转设备地址P_ST_UADDR  : r_st_next <= w_st_trun            ? r_st_restart ? P_ST_READ : P_ST_DADDR1                //判断是否时重启,重启转入读状态,不是重启转入写存储地址状态: P_ST_UADDR    ;                                     //写设备地址,写完跳转存储地址P_ST_DADDR1 : r_st_next <= r_slave_ack          ? P_ST_STOP     :                //存储地址,先等待应答,应答后操作结束跳转存储地址低位w_st_trun            ? P_ST_DADDR2   : P_ST_DADDR1   ;P_ST_DADDR2 : r_st_next <= w_st_trun & ri_operation_type == P_W ? P_ST_WRITE    ://存储地址低位,判断读写,读跳转读状态,写跳转写状态 w_st_trun & ri_operation_type == P_R ? P_ST_RESTART  :P_ST_DADDR2   ;P_ST_WRITE  : r_st_next <= w_st_trun & r_wr_cnt == ri_operation_len - 1  ? P_ST_WAIT     : P_ST_WRITE    ;//写数据状态,写完目标长度跳转结束P_ST_RESTART: r_st_next <= P_ST_STOP;                                            //读数据时,重启总线状态P_ST_READ   : r_st_next <= w_st_trun ? P_ST_WAIT     : P_ST_READ     ;//读数据状态,写完目标长度跳转结束P_ST_WAIT   : r_st_next <= P_ST_STOP    ;P_ST_STOP   : r_st_next <= r_st_cnt == 1? P_ST_EMPTY : P_ST_STOP;P_ST_EMPTY  : r_st_next <= r_st_restart | r_ack_lock ? P_ST_START : P_ST_IDLE;   //空状态,等待IIC成功停止,判断是否重启,重启转入START,不重启转入IDLEdefault     : r_st_next <= P_ST_IDLE;endcase
end//iic应答状态,1为没应答
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_ack_lock <= 'd0;else if(r_ack_valid && !w_iic_sda && r_st_current == P_ST_DADDR1)r_ack_lock <= 'd0;else if(r_ack_valid && w_iic_sda && r_st_current == P_ST_DADDR1)r_ack_lock <= 'd1;else r_ack_lock <= r_ack_lock;
end//读数据时,假写操作后重启信号
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_st_restart <= 'd0;else if(r_st_current == P_ST_READ)r_st_restart <= 'd0;else if(r_st_current == P_ST_RESTART)r_st_restart <= 'd1;else r_st_restart <= r_st_restart;
end//操作准备信号
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_operation_ready <= 'd1;else if(w_operation_active)ro_operation_ready <= 'd0;else if(r_st_current == P_ST_IDLE)ro_operation_ready <= 'd1;else ro_operation_ready <= ro_operation_ready;
end//寄存操作数据
always@(posedge i_clk,posedge i_rst)
beginif(i_rst) beginri_drive          <= 'd0;ri_operation_addr <= 'd0;ri_operation_len  <= 'd0;ri_operation_type <= 'd0;end else if(w_operation_active) beginri_drive          <= {i_drive,1'b0};ri_operation_addr <= i_operation_addr   ;ri_operation_len  <= i_operation_len    ;ri_operation_type <= i_operation_type   ;end else beginri_drive          <= ri_drive           ;ri_operation_addr <= ri_operation_addr  ;ri_operation_len  <= ri_operation_len   ;ri_operation_type <= ri_operation_type  ;end
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_read_drive <= 'd0;else if(w_operation_active)r_read_drive <= {i_drive,1'b1};else r_read_drive <= r_read_drive;
end//状态计数器
always@(posedge i_clk,posedge i_rst)
beginif(i_rst) r_st_cnt <= 'd0;else if(r_st_current != r_st_next || ro_write_valid || ro_read_valid)//状态跳转、写完8bit数、读写8bit数r_st_cnt <= 'd0;else if(r_st_current == P_ST_STOP)r_st_cnt <= r_st_cnt + 1;else if(r_iic_st)r_st_cnt <= r_st_cnt + 1;elser_st_cnt <= r_st_cnt;
end//iic时钟
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_iic_scl <= 'd1;else if(r_st_current >= P_ST_UADDR && r_st_current <= P_ST_WAIT)ro_iic_scl <= ~ro_iic_scl;elsero_iic_scl <= 'd1;
end//iic时钟状态
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_iic_st <= 'd0;else if(r_st_current >= P_ST_UADDR && r_st_current <= P_ST_WAIT)r_iic_st <= ~r_iic_st;elser_iic_st <= 'd0;
end//iic数据线三态门控制
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_iic_sda_ctrl <= 'd0;else if(r_st_cnt == 8 || r_st_next == P_ST_IDLE)r_iic_sda_ctrl <= 'd0;else if(r_st_current >= P_ST_START && r_st_current <= P_ST_WRITE || r_st_current == P_ST_STOP)r_iic_sda_ctrl <= 'd1;elser_iic_sda_ctrl <= r_iic_sda_ctrl;
end//iic数据线写数据
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_iic_sda <= 'd0;else if(r_st_current == P_ST_START)ro_iic_sda <= 'd0;else if(r_st_current == P_ST_UADDR)ro_iic_sda <= r_st_restart ? r_read_drive[7 - r_st_cnt] :  ri_drive[7 - r_st_cnt];else if(r_st_current == P_ST_DADDR1)ro_iic_sda <= ri_operation_addr[15 - r_st_cnt];else if(r_st_current == P_ST_DADDR2)ro_iic_sda <= ri_operation_addr[7  - r_st_cnt];else if(r_st_current == P_ST_WRITE)ro_iic_sda <= ri_write_data[7  - r_st_cnt];else if(r_st_current == P_ST_STOP && r_st_cnt == 1)ro_iic_sda <= 'd1;elsero_iic_sda <= 'd0;
end//写请求
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_write_req <= 'd0;else if(r_st_current == P_ST_DADDR2 && ri_operation_type == P_W && r_st_cnt == 7 && r_iic_st)ro_write_req <= 'd1;else if(r_st_current >= P_ST_DADDR2 && ri_operation_type == P_W && r_st_cnt == 7 && r_iic_st)ro_write_req <= r_wr_cnt < ri_operation_len - 1 ? 1'b1 : 1'b0;elsero_write_req <= 'd0;
end//写有效
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_write_valid <= 'd0;else ro_write_valid <= ro_write_req;
end//写数据
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ri_write_data <= 'd0;else if(ro_write_valid)ri_write_data <= i_write_data;else        ri_write_data <= ri_write_data;
end//读写计数器
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_wr_cnt <= 'd0;else if(r_st_current == P_ST_IDLE)r_wr_cnt <= 'd0;else if((r_st_current == P_ST_WRITE || r_st_current == P_ST_READ) && w_st_trun)r_wr_cnt <= r_wr_cnt + 1;else r_wr_cnt <= r_wr_cnt;
end//读出数据
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_read_data <= 'd0;else if(r_st_current == P_ST_READ && r_st_cnt >= 1 && r_st_cnt <= 8 && !r_iic_st)       ro_read_data <= {ro_read_data[6:0],w_iic_sda};else ro_read_data <= ro_read_data;
end//读出数据有效
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_read_valid <= 'd0;else if(r_st_current == P_ST_READ && r_st_cnt == 8 && !r_iic_st)ro_read_valid <= 'd1;else ro_read_valid <= 'd0;
end//从机应答信号
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_slave_ack <= 'd0;else if(r_ack_valid)r_slave_ack <= w_iic_sda;else r_slave_ack <= 'd0;
end//指示应答有效信号
always@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_ack_valid <= 'd0;else r_ack_valid <= w_st_trun;
end
endmodule

应用IIC接口的代码

module my_ctrl(input               i_clk                   ,input               i_rst                   ,input  [2 :0]       i_ctrl_eeprom_addr      ,input  [15:0]       i_ctrl_operation_addr   ,input  [1 :0]       i_ctrl_operation_type   ,input  [7 :0]       i_ctrl_operation_len    ,input               i_ctrl_opeartion_valid  ,output              o_ctrl_operation_ready  ,input  [7 :0]       i_ctrl_write_data       ,input               i_ctrl_write_sop        ,input               i_ctrl_write_eop        ,input               i_ctrl_write_valid      ,output [7 :0]       o_ctrl_read_data        ,output              o_ctrl_read_valid       ,/*--------iic dirve--------*/output [6 :0]       o_drive                 ,//用户输入设备地址output [15:0]       o_operation_addr        ,//用户输入存储地址output [7 :0]       o_operation_len         ,//用户输入读写长度output [1 :0]       o_operation_type        ,//用户输入操作类型output              o_opeartion_valid       ,//用户输入有效信号input               i_operation_ready       ,//用户输出准备信号output [7 :0]       o_write_data            ,//用户输入写数据input               i_write_req             ,//用户写数据请求信号input  [7 :0]       i_read_data             ,//输出IIC读到的数据input               i_read_valid             //输出IIC读数据有效
);/***************function**************//***************parameter*************/
localparam              P_ST_IDLE       =   0               ,P_ST_WRITE      =   1               ,P_ST_WAIT       =   2               ,P_ST_READ       =   3               ,P_ST_REREAD     =   4               ,P_ST_OREAD      =   5               ;/***************port******************/             /***************mechine***************/
reg  [7 :0]             r_st_current                        ;
reg  [7 :0]             r_st_next                           ;/***************reg*******************/
reg                     ro_ctrl_operation_ready             ;
reg  [7 :0]             ro_ctrl_read_data                   ;
reg                     ro_ctrl_read_valid                  ;
reg  [7 :0]             ri_ctrl_write_data                  ;
reg                     ri_ctrl_write_sop                   ;
reg                     ri_ctrl_write_eop                   ;
reg                     ri_ctrl_write_valid                 ;
reg  [2 :0]             ri_ctrl_eeprom_addr                 ;
reg  [15:0]             ri_ctrl_operation_addr              ;
reg  [1 :0]             ri_ctrl_operation_type              ;
reg  [7 :0]             ri_ctrl_operation_len               ;
reg                     ri_operation_ready                  ;
reg  [7 :0]             ri_read_data                        ;
reg                     ri_read_valid                       ;
reg  [6 :0]             ro_drive                            ;
reg  [15:0]             ro_operation_addr                   ;
reg  [7 :0]             ro_operation_len                    ;
reg  [1 :0]             ro_operation_type                   ;
reg                     ro_opeartion_valid                  ;
reg                     r_fifo_read_en                      ;
reg  [7 :0]             r_read_cnt                          ;
reg  [15:0]             r_read_addr                         ;
reg                     r_read_vld_1d                       ;/***************wire******************/     
wire                    w_ctrl_active                       ;
wire                    w_drive_end                         ;
wire                    w_drive_act                         ;
wire [7 :0]             w_fifo_read_data                    ;
wire                    w_fifo_empty                        ;/***************component*************/FIFO_8X1024 FIFO_8X1024_WRITE_U0 (.clk                  (i_clk                  ),.srst                 (i_rst                  ),.din                  (ri_ctrl_write_data     ),.wr_en                (ri_ctrl_write_valid    ),.rd_en                (i_write_req            ),.dout                 (o_write_data           ),.full                 (),.empty                () );FIFO_8X1024 FIFO_8X1024_READ_U0 (.clk                  (i_clk                  ),.srst                 (i_rst                  ),.din                  (ri_read_data           ),.wr_en                (ri_read_valid          ),.rd_en                (r_fifo_read_en         ),.dout                 (w_fifo_read_data       ),.full                 (),.empty                (w_fifo_empty           ) );/***************assign****************/
assign o_ctrl_operation_ready   = ro_ctrl_operation_ready   ;
assign o_ctrl_read_data         = ro_ctrl_read_data         ;
assign o_ctrl_read_valid        = r_read_vld_1d             ;
assign w_ctrl_active            = i_ctrl_opeartion_valid&o_ctrl_operation_ready;
assign w_drive_end              = i_operation_ready & !ri_operation_ready;
assign w_drive_act              = o_opeartion_valid & i_operation_ready;
assign o_drive                  = ro_drive          ;
assign o_operation_addr         = ro_operation_addr ;
assign o_operation_len          = ro_operation_len  ;
assign o_operation_type         = ro_operation_type ;
assign o_opeartion_valid        = ro_opeartion_valid;
/***************always****************/
always@(posedge i_clk,posedge i_rst)
beginif(i_rst) r_st_current <= P_ST_IDLE;elser_st_current <= r_st_next;
endalways@(*)
begincase(r_st_current)P_ST_IDLE   :r_st_next = w_ctrl_active && i_ctrl_operation_type == 1 ? P_ST_WRITE : w_ctrl_active && i_ctrl_operation_type == 2 ? P_ST_WAIT  :P_ST_IDLE; P_ST_WRITE  :r_st_next = w_drive_end ? P_ST_IDLE : P_ST_WRITE; P_ST_WAIT   :r_st_next = P_ST_READ;P_ST_READ   :r_st_next = w_drive_end ? r_read_cnt == ri_ctrl_operation_len - 1  ? P_ST_OREAD : P_ST_REREAD : P_ST_READ; P_ST_REREAD :r_st_next = P_ST_READ;P_ST_OREAD  :r_st_next = w_fifo_empty ? P_ST_IDLE : P_ST_OREAD;default     :r_st_next = P_ST_IDLE;endcase
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) r_fifo_read_en <= 'd0;else if(w_fifo_empty)r_fifo_read_en <= 'd0;else if(r_st_current != P_ST_OREAD && r_st_next == P_ST_OREAD)r_fifo_read_en <= 'd1;else r_fifo_read_en <= r_fifo_read_en;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) ro_ctrl_read_data <= 'd0;else ro_ctrl_read_data <= w_fifo_read_data;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) ro_ctrl_read_valid <= 'd0;else if(w_fifo_empty)ro_ctrl_read_valid <= 'd0;else if(r_fifo_read_en)ro_ctrl_read_valid <= 'd1;else ro_ctrl_read_valid <= ro_ctrl_read_valid;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) r_read_vld_1d <= 'd0;else r_read_vld_1d <= ro_ctrl_read_valid;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) beginri_ctrl_eeprom_addr    <= 'd0;ri_ctrl_operation_addr <= 'd0;ri_ctrl_operation_type <= 'd0;ri_ctrl_operation_len  <= 'd0;end else if(w_ctrl_active) beginri_ctrl_eeprom_addr    <= i_ctrl_eeprom_addr    ;ri_ctrl_operation_addr <= i_ctrl_operation_addr;ri_ctrl_operation_type <= i_ctrl_operation_type;ri_ctrl_operation_len  <= i_ctrl_operation_len;end else beginri_ctrl_eeprom_addr    <= ri_ctrl_eeprom_addr   ;ri_ctrl_operation_addr <= ri_ctrl_operation_addr;ri_ctrl_operation_type <= ri_ctrl_operation_type;ri_ctrl_operation_len  <= ri_ctrl_operation_len;end
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) beginri_ctrl_write_data  <= 'd0;ri_ctrl_write_sop   <= 'd0;ri_ctrl_write_eop   <= 'd0;ri_ctrl_write_valid <= 'd0;end else beginri_ctrl_write_data  <= i_ctrl_write_data    ;ri_ctrl_write_sop   <= i_ctrl_write_sop     ;ri_ctrl_write_eop   <= i_ctrl_write_eop     ;ri_ctrl_write_valid <= i_ctrl_write_valid   ;end
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst)ro_ctrl_operation_ready <= 'd1;else if(w_ctrl_active)ro_ctrl_operation_ready <= 'd0;else if(r_st_current == P_ST_IDLE)ro_ctrl_operation_ready <= 'd1;elsero_ctrl_operation_ready <= ro_ctrl_operation_ready; 
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst)ri_operation_ready <= 'd0;elseri_operation_ready <= i_operation_ready;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) beginri_read_data  <= 'd0;ri_read_valid <= 'd0;end else beginri_read_data  <= i_read_data ;ri_read_valid <= i_read_valid;end
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst) beginro_drive           <= 'd0;ro_operation_addr  <= 'd0;ro_operation_len   <= 'd0;ro_operation_type  <= 'd0;ro_opeartion_valid <= 'd0;end else if(w_drive_act) beginro_drive           <= 'd0;ro_operation_addr  <= 'd0;ro_operation_len   <= 'd0;ro_operation_type  <= 'd0;ro_opeartion_valid <= 'd0;end else if(ri_ctrl_write_eop) beginro_drive           <= {4'b1010,ri_ctrl_eeprom_addr};ro_operation_addr  <= ri_ctrl_operation_addr;ro_operation_len   <= ri_ctrl_operation_len;ro_operation_type  <= ri_ctrl_operation_type;ro_opeartion_valid <= 'd1;end else if(r_st_next == P_ST_READ && r_st_current != P_ST_READ) beginro_drive           <= {4'b1010,ri_ctrl_eeprom_addr};ro_operation_addr  <= r_read_addr;ro_operation_len   <= 1;ro_operation_type  <= ri_ctrl_operation_type;ro_opeartion_valid <= 'd1;end else beginro_drive           <= ro_drive          ;ro_operation_addr  <= ro_operation_addr ;ro_operation_len   <= ro_operation_len  ;ro_operation_type  <= ro_operation_type ;ro_opeartion_valid <= ro_opeartion_valid;end
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_read_addr <= 'd0;else if(w_ctrl_active)r_read_addr <= i_ctrl_operation_addr;else if(r_st_current == P_ST_READ && w_drive_end)r_read_addr <= r_read_addr + 1 ;elser_read_addr <= r_read_addr;
endalways@(posedge i_clk,posedge i_rst)
beginif(i_rst)r_read_cnt <= 'd0;else if(r_st_current == P_ST_IDLE)r_read_cnt <= 'd0;else if(r_st_current == P_ST_READ && w_drive_end)r_read_cnt <= r_read_cnt  +1;elser_read_cnt <= r_read_cnt;
endendmodule

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

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

相关文章

js-Vue Router 中的方法,父A-子B-子C依次返回,无法返回到A,BC中形成循环跳转解决

1.常用的方法 在 Vue Router 中&#xff0c;有一些常用的方法用于实现路由导航和管理。以下是一些常见的 Vue Router 方法及其作用&#xff1a; push: router.push(location, onComplete, onAbort) 作用&#xff1a;向路由历史记录中添加一个新条目&#xff0c;并导航到指定的路…

十六进制数

1.做一个收电费程序&#xff0c;要求输入使用的电的度数&#xff08;整数&#xff09;以及电费单价&#xff08;实数&#xff09;&#xff0c;输出总的用电费用。 2.提示并输入一个小写字母数据&#xff0c;输出其对应的ASCII值&#xff0c;以及该小写字母对应的大写字母。 3.提…

leetcode hot100组合综合四

本题中&#xff0c;是要求nums中求的总和为target的排列数&#xff0c;因为题中说了&#xff0c;元素顺序不同&#xff0c;则可以视为不同的结果之一。 所以&#xff0c;根据对背包问题的总结&#xff0c;本题中元素可以重复使用&#xff0c;是完全背包并且需要求排列数&#…

Redis之缓存击穿问题解决方案

文章目录 一、书接上文二、介绍三、解决方案1. 单例双检锁2. 缓存预热和定时任务 一、书接上文 Redis之缓存雪崩问题解决方案 二、介绍 缓存击穿就是大量并发访问同一个热点数据&#xff0c;一旦这个热点数据缓存失效&#xff0c;则请求压力都来到数据库。 三、解决方案 1…

嵌入式Qt 计算器核心算法_1

一.表达式分离算法分析 二.分离算法实现 QCalculatorDec.cpp #include "QCalculatorDec.h"#include <QDebug>QCalculatorDec::QCalculatorDec() {m_exp "";m_result "";QQueue<QString> r split("9.11 ( -3 - 1 ) * -5 &…

C#,整数转为短字符串(Short string)的加解密算法与源代码

1 整数转为短字符串的应用 网站生成的动态 URL 往往以内容序列号id为标识与参数&#xff0c;比如&#xff1a; http://www.jerry.com/tom.aspx?id1 使用 Web Rewrite&#xff0c;可以实现网页静态化&#xff0c;称为&#xff1a; http://www.jerry.com/content/1.html 对…

Centos安装图形化桌面环境

1.使用root远程登录最小化安装的虚拟机 2.执行命令yum groupinstall "X Window System" 这是安装窗口系统 3.执行命令yum grouplist" 检查安装的软件可可以安装的软件 4.执行命令yum groupinstall "Server with GUI" 这是安装图形化界面 5.执行命令sy…

抛弃chatgpt,使用微软的Cursor提升coding效率

Whats Cursor? Cursor编辑器是一个基于GPT-4的代码编辑器&#xff0c;它可以根据用户的自然语言指令或者正在编辑的代码上下文为用户提供代码建议&#xff0c;支持多种编程语言&#xff0c;如Python、Java、C/C#、go等。Cursor编辑器还可以帮助用户重构、理解和优化代码&…

P1605 迷宫

题目传送门&#xff1a;P1605 迷宫 前言 dfs迷宫题&#xff0c;是一道很好的练手模板题 这道题一定要回溯&#xff01;回溯&#xff01;&#xff01; 代码 #include<bits/stdc.h> using namespace std; int n,m,t; int sx,sy,fx,fy; int lx,ly; int a[10][10]{0},ans…

国内最全的AIGC大模型软件都是免费的,不比chatgpt香吗?我都为你准备好了,又可以提前下班了

无极低码 &#xff1a;https://wheart.cn 豆包(云雀大模型)、文心一言、悟空、星火、百度文库、360智脑、天宫AI、智谱清言(GLM大模型)、百川模型(百川智能)、日日新(商汤)、上海人工智能实验室&#xff08;书生通用大模型&#xff09;、夸克。 国内最全的AIGC大模型软件都是…

mysql 2-21

约束的分类 添加约束 查看表约束 非空约束 唯一性约束 复合的唯一性约束 只要有一个字段不重复&#xff0c;就可以添加成功 主键约束 自增列 mysql 8.0具有持久化&#xff0c;重启服务器会继续自增 外键约束 创建外键 关联必须有唯一性约束&#xff0c;或者是主键 约束等级 …

MySQL篇之undo log和redo log

一、持久化时服务器宕机 缓冲池&#xff08;buffer pool&#xff09;: 主内存中的一个区域&#xff0c;里面可以缓存磁盘上经常操作的真实数据&#xff0c;在执行增删改查操作时&#xff0c;先操作缓冲池中的数据&#xff08;若缓冲池没有数据&#xff0c;则从磁盘加载并缓存&a…

我是如何从功能测试成功转岗测试开发的?记录下我的面试经验

由于这段时间我面试了很多家公司&#xff0c;也经历了之前公司的不愉快。所以我想写一篇文章来分享一下自己的面试体会。希望能对我在之后的工作或者面试中有一些帮助&#xff0c;也希望能帮助到正在找工作的你。 一 找工作 壹&#xff0f; 我们总是草率地进入一个自己不了解…

mac拼图软件有哪些?推荐5款拼图软件

mac拼图软件有哪些&#xff1f;在数字图像处理中&#xff0c;拼图软件扮演着至关重要的角色。对于Mac用户来说&#xff0c;选择一款功能强大、操作简便的拼图软件是提升工作效率和创作体验的关键。本文将为你介绍五款优秀的Mac拼图软件&#xff0c;帮助你轻松完成图片拼接、制作…

WEB APIs (3)

事件对象 事件对象有事件触发时的相关信息&#xff0c;如点击事件中事件对象储存了鼠标点在哪个位置的信息 场景&#xff1a; 用户按下了哪个键&#xff0c;按下回车键可以发布新闻 鼠标点击了哪个元素&#xff0c;从而做哪些操作 参数e为事件对象 常用属性 type 获取当前…

如何用微软画图把1280X720的图片压缩成4:3?

最近在看20多年前的电视剧&#xff0c;视频截图是1280X720&#xff0c;比例失调。 如何压缩成4:3&#xff1f; 4 / 3 W / 720 W 720 X 4 / 3 960 打开画图&#xff0c;调整大学和扭曲&#xff08;Ctrl W&#xff09;&#xff0c;依据选择像素&#xff0c;取消保持纵横比…

【C++】类和对象---const成员,取地址及const取地址操作符重载,static成员

目录 ⭐const成员 ⭐取地址及const取地址操作符重载 ⭐static成员 ⭐概念 ⭐特性 ⭐const成员 将const修饰的“成员函数”称之为const成员函数&#xff0c;const修饰类成员函数&#xff0c;实际修饰该成员函数隐含的this指针&#xff0c;表明在该成员函数中不能对类的任何…

Nginx服务介绍与部署管理

目录 一、Nginx相关介绍 1. 概述 2. 优缺点 3. 零拷贝技术 4. I/O模型相关概念 5. 网络I/O模型 5.1 阻塞型I/O模型 5.2 非阻塞型I/O模型 5.3 多路复用I/O型 5.4 信号驱动式I/O模型 5.5 异步I/O模型 6. 事件驱动模型 7. Nginx与Apache区别 二、Nginx部署和使用 1…

哪些工具可以改变手机电脑网络IP地址?

在互联网时代&#xff0c;网络已经成为了我们日常生活中不可或缺的一部分。然而&#xff0c;随着网络的普及和技术的不断发展&#xff0c;网络安全问题也日益凸显。为了保护个人隐私和信息安全&#xff0c;我们需要了解一些工具可以改变手机电脑网络IP地址的知识。 首先&#x…

【Java面试】MQ(Message Queue)消息队列

目录 一、MQ介绍二、MQ的使用1应用解耦2异步处理3流量削峰4日志处理5消息通讯三、使用 MQ 的缺陷1.系统可用性降低:2.系统复杂性变高3.一致性问题四、常用的 MQActiveMQ:RabbitMQ:RocketMQ:Kafka:五、如何保证MQ的高可用?ActiveMQ:RabbitMQ:RocketMQ:Kafka:六、如何保…