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,一经查实,立即删除!

相关文章

嵌入式培训机构四个月实训课程笔记(完整版)-Linux ARM驱动编程第八天-高级驱动framebuffer(物联技术666)

链接&#xff1a;https://pan.baidu.com/s/1cd7LOSAvmPgVRPAyuMX7Fg?pwd1688 提取码&#xff1a;1688 帧缓冲&#xff08;framebuffer&#xff09;设备应用于linux显示技术方面。因为linux的显示平台已经全部基于framebuffer&#xff0c;所以目前在linux环境下开发图形化界面…

python opencv图像模糊

目录 一:均值滤波 二:高斯滤波 三:中值滤波 四:双边滤波 在OpenCV中,模糊图片或进行图像平滑处理时常用的方法包括以下几种: 均值滤波 (Blurring): 均值滤波是一种简单的平滑方法,它通过对图像中每个像素的邻域内像素值进行平均来计算新的像素值。在OpenC

ABC341 题解

ABC341 题解 A Description 给定一个数 N N N&#xff0c;求长度 2 N 1 2N1 2N1 的 01 交替的字符串&#xff08;0 开始&#xff09;。 Solution 直接模拟&#xff0c;注意 0-index 是 i m o d 2 i\bmod 2 imod2&#xff0c;1-index 是 ( i 1 ) m o d 2 (i1) \bmod …

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

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

算法-位运算

题目&#xff1a;题目5 一个数组中有一种数出现K次&#xff0c;其他数都出现了M次&#xff0c; M > 1, K < M 找到&#xff0c;出现了K次的数&#xff0c; 要求&#xff0c;额外空间复杂度O(1)&#xff0c;时间复杂度O(N) 思路&#xff1a;遍历数组按位计数&#xff0c;不…

SRS关闭无人观看的流

这里需要使用到SRS自身自带的钩子回调功能&#xff0c;配置文件中有标注&#xff1a; Hook函数&#xff1a; 分为on_publish、on_play、on_stop、on_unpublish、on_dvr等类别&#xff1b; 其中主要介绍on_play、on_stop on_play&#xff1a; 主要用于用户在对srs拉流进行播…

十六进制数

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

Spring设计模式之工厂模式创建Bean对象

BeanFactory和Application是Spring容器中创建和管理Bean对象的接口&#xff0c;但是它们的实现方式不同。 BeanFactory&#xff1a; BeanFactory采用延迟初始化策略&#xff0c;只有应用程序向容器请求特定的Bean时才创建该Bean对象。它的启动速度很快&#xff0c;但在程序运…

MySQL、Redis、Nginx配置优化

文章目录 一、MySQL二、Redis三、Nginx 一、MySQL mysql.cnf [mysqld] binlog_cache_size 128K thread_stack 256K join_buffer_size 2048K max_heap_table_size 512Mdefault_storage_engine InnoDB performance_schema_max_table_instances 400 table_definition_cach…

leetcode hot100组合综合四

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

.net 微服务 服务保护 自动重试 Polly

1. 概要 实验服务保护&#xff0c;自动重新连接功能。 2.代码 2.1 重复工具 using Polly; using Polly.Retry; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks;namespace WebApplication2 {pu…

c# DotNetty

对于 .NET 开发者来说&#xff0c;DotNetty 是一个开源、高性能的网络库&#xff0c;它是对 Java 平台上流行的 Netty 异步事件驱动网络应用程序框架的一个端口。DotNetty 适用于创建各种网络应用程序&#xff0c;如 IoT (物联网)、游戏服务器以及消息传递系统等。 以下是对 Do…

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

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

Redis命令和Redisson对象匹配列表

大家好&#xff0c;Redisson系列再发一文。 多克创新国庆福利继续发&#xff0c;有需要的可以前往官网了解详情&#xff01;&#xff01;&#xff01; Redis命令Redisson对象方法AUTHConfig.setPassword();APPENDRBinaryStream.getOutputStream().write()BITCOUNTRBitSet.ca…

嵌入式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 对…

数学家的趣闻轶事15则

目录 前言趣闻轶事15则参考文献 前言 有人的地方就有江湖&#xff0c;有江湖的地方就有故事。数学本身就是一个江湖&#xff0c;这个江湖也充满着血雨腥风和侠骨柔情&#xff0c;至今流传着各种各样的传说&#xff0c;其中不乏”马踏江湖潇潇事“&#xff0c;也有"何当共…

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编辑器还可以帮助用户重构、理解和优化代码&…

Mybatisplus 传参参数为自定义sql, 使用条件构造器作为参数

1 pom依赖 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.3.1</version> </dependency> 2 mapper 接口文件 List<TBookOrder> searchDiy(Param(Const…