FPGA 外置Flash的读写,用户数据存储_fpga将图片存储到flash中-程序员宅基地

技术标签: fpga  


前言

大多数FPGA内部不具有掉电存储程序的功能,所以都是外置flash存储器来存储程序,上电后加载flash中的程序到FPGA中,在运行。外置flash不仅可以作为存储程序使用,也可以存储任何你想存储的用户数据,这样可以更有效的利用flash的存储空间,本文不讲其寄存器及原理,这个网上很多。


一,该功能验证平台及参考文章

1,Xilinx xc7k325tffg676-2

2,vivado 2017.4

3,验证的flash芯片:MT25QL256

4,参考文章:MT25QL256_datasheet

5,工程网盘链接:https://pan.baidu.com/s/1HCBXLYvVRce5k5N_ro-3CA 提取码:cyfo

二、实现的功能

1,read Device ID

2,设置4-byte模式

3,flash的数据读写

三,部分代码


flash_spi

`timescale 1ns / 1ps
//
// Company: 
// Engineer: QSJ
// 
// Create Date: 2021/03/26 9:02:44
// Design Name: 
// Module Name: flash_spi
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//

module flash_spi(
    input wire  sys_clk,
    input wire  i_rst_n,
    
    // ---------- spi port ---------
    output wire o_spi_clk,
    output wire o_spi_cs,
    output wire o_spi_mosi,
    input  wire i_spi_miso,
    
    // --------- data port -----------
    input  wire [7:0]  iv_write_data ,
    output reg         o_wr_1_byte_ok ,
    input  wire [15:0] iv_write_num,
    input  wire [15:0] iv_read_num,
    input  wire [3:0]  iv_cmd_type,
    output reg         o_flash_done,
    input  wire [7:0]  iv_flash_cmd,
    input  wire [31:0] iv_flash_addr,
    output reg  [7:0]  ov_read_data,
    output wire        o_read_data_vld

);


wire spi_clk;
reg spi_cs;
reg spi_mosi;
wire spi_miso;
assign o_spi_clk = spi_clk;
assign o_spi_cs = spi_cs;
assign o_spi_mosi = spi_mosi;
assign spi_miso = i_spi_miso;

reg read_data_vld;
reg [7:0] read_data;


reg  [2:0] spi_state;
reg spi_clk_en=1'b0;
reg data_come;

assign o_read_data_vld=read_data_vld;

assign spi_clk=spi_clk_en?sys_clk:0;


parameter IDLE         = 3'b000;
parameter CMD_SEND     = 3'b001;
parameter ADDRESS_SEND = 3'b010;
parameter READ_WAIT    = 3'b011;
parameter WRITE_DATA   = 3'b101;
parameter FINISH_DONE  = 3'b110;


reg [7:0]  cmd_reg;
reg [31:0] address_reg;
reg [7:0]  wr_bit_cnt;
reg [15:0] write_cnt;
reg [7:0]  rd_bit_cnt;
reg [15:0] read_cnt;
reg [15:0]  read_num_inner;

reg read_finish;

always @(negedge sys_clk)
begin
if(!i_rst_n)
	begin
		spi_cs<=1'b1;		
		spi_state<=IDLE;
		cmd_reg<=0;
		address_reg<=0;
	    spi_clk_en<=1'b0; 
		wr_bit_cnt<=0;
        write_cnt<=0;
        read_num_inner<=0;	
		o_flash_done<=1'b0;
		data_come<=1'b0;
		o_wr_1_byte_ok <= 1'b0;	
	end
else
	begin
	case(spi_state)
		IDLE: begin	  
				spi_clk_en<=1'b0;
				spi_cs<=1'b1;
				spi_mosi<=1'b1;	
			    cmd_reg<=iv_flash_cmd;
                address_reg<=iv_flash_addr;
		        o_flash_done<=1'b0;				
				if(iv_cmd_type[3]==1'b1) 
				begin
				   spi_state<=CMD_SEND;
                   wr_bit_cnt<=7;		
                   write_cnt<=0;
                   read_num_inner<=0;					
				end
		end
		CMD_SEND:
		begin 	
		    spi_clk_en<=1'b1;                        
		    spi_cs<=1'b0;                    
			if(wr_bit_cnt>0) 
			begin                  
			   spi_mosi<=cmd_reg[wr_bit_cnt];  
               wr_bit_cnt<=wr_bit_cnt-1'b1;						
			end				
			else 
			begin                                 
				spi_mosi<=cmd_reg[0];
				if ((iv_cmd_type[2:0]==3'b001) | (iv_cmd_type[2:0]==3'b100)) 
				begin 
 				    spi_state<=FINISH_DONE;
                end							 
                else if (iv_cmd_type[2:0]==3'b011)  
                begin 
				 	 spi_state<=READ_WAIT;
					 wr_bit_cnt<=7;
					 read_num_inner<=1;                 
				end
                else if (iv_cmd_type[2:0]==3'b000)  
                begin 
				 	 spi_state<=READ_WAIT;                  
					 wr_bit_cnt<=7;
					 read_num_inner<=17;                   
				end						
				else 
				begin	     
				    spi_state<=ADDRESS_SEND;
				    wr_bit_cnt<=31;
				end
			end
		end
		ADDRESS_SEND:
		begin 
			if(wr_bit_cnt>0)  
			begin                       
				spi_mosi<=address_reg[wr_bit_cnt];          
                wr_bit_cnt<=wr_bit_cnt-1;						
			end				
			else begin                         
			   spi_mosi<=address_reg[0];   
               if(iv_cmd_type[2:0]==3'b010) 
               begin           
 					 spi_state<=FINISH_DONE;	
               end
               else if (iv_cmd_type[2:0]==3'b101) 
               begin	 				
			        spi_state<=WRITE_DATA;
				    wr_bit_cnt<=7;                       
			   end			 
			   else begin
				    spi_state<=READ_WAIT;
			        read_num_inner<=iv_read_num;                 						 
               end						 
			end
		end
		READ_WAIT: 
		begin   
		     if(read_finish)  
		     begin
			     spi_state<=FINISH_DONE;
				 data_come<=1'b0;
			  end
			  else
			     data_come<=1'b1;
		end		
		WRITE_DATA: 
		begin  
		   if(write_cnt<iv_write_num) 
		   begin                  
			   if(wr_bit_cnt>0) 
			   begin                       
					spi_mosi<=iv_write_data[wr_bit_cnt];
                    wr_bit_cnt<=wr_bit_cnt-1'b1;	
                    o_wr_1_byte_ok <= 1'b0;					
				end				
				else  
				begin                                 
					 spi_mosi<=iv_write_data[0];     
					 wr_bit_cnt<=7;
					 o_wr_1_byte_ok <= 1'b1;		
					 write_cnt<=write_cnt+1'b1;
				end
			end
         else 
         begin
			spi_state<=FINISH_DONE;
			spi_clk_en<=1'b0;
			o_wr_1_byte_ok <= 1'b0;	
			write_cnt <= 0;
		 end
				 
		end
		FINISH_DONE:
		begin
 		      spi_cs<=1'b1;
			  spi_mosi<=1'b1;
			  spi_clk_en<=1'b0;
			  o_flash_done<=1'b1;
			  spi_state<=IDLE;
		end
		default:spi_state<=IDLE;
		endcase		
	end
end
	

always @(posedge sys_clk)
begin
	if(!i_rst_n)
	begin
			read_cnt<=0;
			rd_bit_cnt<=0;
			read_finish<=1'b0;
			read_data_vld<=1'b0;
			read_data<=0;
			ov_read_data<=0;
	end
	else
		 if(data_come)   
		 begin
			if(read_cnt<read_num_inner) 
			begin 
				if(rd_bit_cnt<7) 
				begin       
					 read_data_vld<=1'b0;
					 read_data<={
    read_data[6:0],spi_miso};
					 rd_bit_cnt<=rd_bit_cnt+1'b1;
				end
				else  
				begin
					 read_data_vld<=1'b1;      
					 ov_read_data<={
    read_data[6:0],spi_miso};
					 rd_bit_cnt<=0;
					 read_cnt<=read_cnt+1'b1;
				end
			end				 			 
			else begin 
				 read_cnt<=0;
				 read_finish<=1'b1;
				 read_data_vld<=1'b0;
			end
		end
		else 
		begin
		    read_cnt<=0;
		    rd_bit_cnt<=0;
		    read_finish<=1'b0;
		    read_data_vld<=1'b0;
		    read_data<=0;
		end
end			

endmodule



flash_cmd


`timescale 1ns / 1ps
//
// Company: 
// Engineer: QSJ
// 
// Create Date: 2021/03/26 9:04:02
// Design Name: 
// Module Name: flash_cmd
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//


module flash_cmd(
    input sys_clk,
	input i_rst_n,
    input i_wr_flash_start,
    input i_rd_flash_start,
    input i_rd_device_id_start,
    input i_subsector_erase_start,
    
    input  wire [7:0]  iv_write_data ,
    output wire        o_wr_1_byte_ok ,
    input  wire [15:0] iv_write_num,
    input  wire [15:0] iv_read_num,
    
    input  wire [31:0] iv_base_addr    ,

    output o_spi_clk  , 
	output o_spi_cs   ,    
	output o_spi_mosi ,  
	input  i_spi_miso ,
	
	output [7:0] ov_rd_data,
	output       o_rd_data_vld
	 

);
	 

reg [7:0] flash_cmd_def;
reg [3:0] cmd_type;

wire flash_done;
wire [7:0] read_data;
wire read_data_vld;


reg [4:0] curr_state = 'd15;
always @ ( posedge sys_clk )
begin
    if( !i_rst_n ) begin
			curr_state <= 'd15;
			flash_cmd_def <= 8'd0;
			cmd_type <= 4'b0000;
	 end
	 else 
	 begin
	     case( curr_state ) 
             'd0://idle
              if(i_wr_flash_start)             curr_state <= 'd8 ;
              else if(i_rd_flash_start)        curr_state <= 'd13;
              else if(i_rd_device_id_start)    curr_state <= 'd1 ;
              else if(i_subsector_erase_start) curr_state <= 'd3 ;
              else                             curr_state <= 'd0;
              
// --------------  read device ID  ------------------
			'd1://Read Status Register:05H
             if( flash_done ) 
             begin 
                 if (read_data[0]==1'b0) 
                 begin 
                      flash_cmd_def <= 8'h00; 
                      curr_state <= 'd2; 
                      cmd_type <= 4'b0000; 
                 end
                 else 
                 begin 
                      flash_cmd_def <= 8'h05; 
                      cmd_type <= 4'b1011; 
                 end
             end
             else 
             begin 
                  flash_cmd_def <= 8'h05; 
                  cmd_type <= 4'b1011; 
             end
	      'd2:// Read Device ID:9FH
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     if(read_data == 8'hFF) // if the device id is error
			         curr_state <= 'd1; 
			     else
			         curr_state <= 'd0; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h9f; 
			     curr_state <= curr_state; 
			     cmd_type <= 4'b1000; 
			end	


// --------------  Erase  ------------------
          'd3://Read Status Register:05H
             if( flash_done ) 
             begin 
                 if (read_data[0]==1'b0) 
                 begin 
                      flash_cmd_def <= 8'h00; 
                      curr_state <= 'd4; 
                      cmd_type <= 4'b0000; 
                 end
                 else 
                 begin 
                      flash_cmd_def <= 8'h05; 
                      cmd_type <= 4'b1011; 
                 end
             end
             else 
             begin 
                  flash_cmd_def <= 8'h05; 
                  cmd_type <= 4'b1011; 
             end
	      'd4://Write Enable:06H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd5; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h06; 
			     curr_state <= curr_state; 
			     cmd_type <= 4'b1001; 
			end
	
			'd5://4-byte address mode Sector Erase:DCH  Subsector Erase:21H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd6; 
			     cmd_type<=4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h21; 
			     curr_state <= curr_state; 
			     cmd_type <= 4'b1010; 
			end
			
			'd6://Read Status Register:05H
			if( flash_done ) 
			begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd7; 
			         cmd_type <= 4'b0000; 
			    end
				else 
				begin 
				    flash_cmd_def <= 8'h05; 
				    cmd_type <= 4'b1011; 
				end
			end
			else 
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end

	      'd7://Write disable: 04H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd0; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h04; 
			     cmd_type <= 4'b1100; 
			end			
			

// --------------  write Data  ------------------
			'd8://Read Status Register:05H
			if( flash_done ) 
			begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd9; 
			         cmd_type <= 4'b0000; 
			    end
			    else 
			    begin 
			         flash_cmd_def <= 8'h05; 
			         cmd_type <= 4'b1011; 
			    end
			end
			else 
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end

	      'd9://Write Enable:06H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd10; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h06; 
			     cmd_type <= 4'b1001; 
			end 


	      'd10://4-byte address page program: write data to flash
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd11;
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h12; 
			     cmd_type <= 4'b1101; 
			end

			'd11://Read Status Register:05H
			if( flash_done ) 
			begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd12; 
			         cmd_type <= 4'b0000; 
			    end
				else 
				begin 
				     flash_cmd_def <= 8'h05; 
				     cmd_type <= 4'b1011; 
				end
			end
			else
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end

	      'd12://Write disable: 04H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd0; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h04; 
			     cmd_type <= 4'b1100; 
			end		


// --------------  read Data  ------------------
			'd13://Read Status Register:05H
			if( flash_done ) begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd14; 
			         cmd_type <= 4'b0000; 
			    end
				else 
				begin 
				    flash_cmd_def <= 8'h05; 
				    cmd_type <= 4'b1011; 
				end
			end
			else 
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end
					
			'd14://4-byte address read flash data
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd0; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h13; 
			     cmd_type <= 4'b1110; 
			end


// --------------  enter 4-byte mode  ------------------		
            'd15://Read Status Register:05H
			if( flash_done ) begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd16; 
			         cmd_type <= 4'b0000; 
			    end
				else 
				begin 
				    flash_cmd_def <= 8'h05; 
				    cmd_type <= 4'b1011; 
				end
			end
			else 
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end	
			'd16://Write Enable:06H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd17; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h06; 
			     cmd_type <= 4'b1001; 
			end 


	      'd17://Enter 4-byte address mode:B7H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd18;
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'hB7; 
			     cmd_type <= 4'b1001; 
			end

			'd18://Read Status Register:05H
			if( flash_done ) 
			begin 
			    if (read_data[0]==1'b0) 
			    begin 
			         flash_cmd_def <= 8'h00; 
			         curr_state <= 'd19; 
			         cmd_type <= 4'b0000; 
			    end
				else 
				begin 
				     flash_cmd_def <= 8'h05; 
				     cmd_type <= 4'b1011; 
				end
			end
			else
			begin 
			     flash_cmd_def <= 8'h05; 
			     cmd_type <= 4'b1011; 
			end

	      'd19://Write disable: 04H
			if( flash_done ) 
			begin 
			     flash_cmd_def <= 8'h00; 
			     curr_state <= 'd1; 
			     cmd_type <= 4'b0000; 
			end
			else 
			begin 
			     flash_cmd_def <= 8'h04; 
			     cmd_type <= 4'b1100; 
			end
	      endcase
	 end
end



reg [31:0] base_addr;
always @ ( posedge sys_clk)
begin
    if( !i_rst_n ) begin
		  base_addr <= 'd0;
	 end
	 else 
	 begin
	      if(curr_state == 0)
	      begin
	          if(i_wr_flash_start|i_rd_flash_start|i_subsector_erase_start) base_addr <= iv_base_addr ;
              else                                                          base_addr <= 'd0;
	      end
	      else base_addr <= base_addr ;
	 end
end

flash_spi U_flash_spi(
    .sys_clk( sys_clk ),  
    .i_rst_n( i_rst_n ),   
    
    .o_spi_clk  ( o_spi_clk      ),
    .o_spi_cs   ( o_spi_cs       ),
    .o_spi_mosi ( o_spi_mosi     ),  
    .i_spi_miso ( i_spi_miso     ),    
     
    .iv_write_data  ( iv_write_data   ),
    .o_wr_1_byte_ok ( o_wr_1_byte_ok  ),
    .iv_write_num   ( iv_write_num    ),
    .iv_read_num    ( iv_read_num     ),
    .iv_cmd_type    ( cmd_type        ),	  
    .o_flash_done   ( flash_done      ),   
    .iv_flash_cmd   ( flash_cmd_def       ),
    .iv_flash_addr   ( base_addr       ), 
    .ov_read_data   ( read_data       ),    
    .o_read_data_vld( read_data_vld   )  
);

assign ov_rd_data    = read_data;
assign o_rd_data_vld = (curr_state == 'd14) ? read_data_vld : 0;

endmodule

总结

以上就是全部内容,仅做个人记录,若需要对flash进行更多操作,可阅读flash对应的datasheet。
有完整的VIVADO FPGA测试工程。
工程未经过全面的调试,有问题请指正!

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qsj_csdn/article/details/115293789

智能推荐

从零开始搭建Hadoop_创建一个hadoop项目-程序员宅基地

文章浏览阅读331次。第一部分:准备工作1 安装虚拟机2 安装centos73 安装JDK以上三步是准备工作,至此已经完成一台已安装JDK的主机第二部分:准备3台虚拟机以下所有工作最好都在root权限下操作1 克隆上面已经有一台虚拟机了,现在对master进行克隆,克隆出另外2台子机;1.1 进行克隆21.2 下一步1.3 下一步1.4 下一步1.5 根据子机需要,命名和安装路径1.6 ..._创建一个hadoop项目

心脏滴血漏洞HeartBleed CVE-2014-0160深入代码层面的分析_heartbleed代码分析-程序员宅基地

文章浏览阅读1.7k次。心脏滴血漏洞HeartBleed CVE-2014-0160 是由heartbeat功能引入的,本文从深入码层面的分析该漏洞产生的原因_heartbleed代码分析

java读取ofd文档内容_ofd电子文档内容分析工具(分析文档、签章和证书)-程序员宅基地

文章浏览阅读1.4k次。前言ofd是国家文档标准,其对标的文档格式是pdf。ofd文档是容器格式文件,ofd其实就是压缩包。将ofd文件后缀改为.zip,解压后可看到文件包含的内容。ofd文件分析工具下载:点我下载。ofd文件解压后,可以看到如下内容: 对于xml文件,可以用文本工具查看。但是对于印章文件(Seal.esl)、签名文件(SignedValue.dat)就无法查看其内容了。本人开发一款ofd内容查看器,..._signedvalue.dat

基于FPGA的数据采集系统(一)_基于fpga的信息采集-程序员宅基地

文章浏览阅读1.8w次,点赞29次,收藏313次。整体系统设计本设计主要是对ADC和DAC的使用,主要实现功能流程为:首先通过串口向FPGA发送控制信号,控制DAC芯片tlv5618进行DA装换,转换的数据存在ROM中,转换开始时读取ROM中数据进行读取转换。其次用按键控制adc128s052进行模数转换100次,模数转换数据存储到FIFO中,再从FIFO中读取数据通过串口输出显示在pc上。其整体系统框图如下:图1:FPGA数据采集系统框图从图中可以看出,该系统主要包括9个模块:串口接收模块、按键消抖模块、按键控制模块、ROM模块、D.._基于fpga的信息采集

微服务 spring cloud zuul com.netflix.zuul.exception.ZuulException GENERAL-程序员宅基地

文章浏览阅读2.5w次。1.背景错误信息:-- [http-nio-9904-exec-5] o.s.c.n.z.filters.post.SendErrorFilter : Error during filteringcom.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud..._com.netflix.zuul.exception.zuulexception

邻接矩阵-建立图-程序员宅基地

文章浏览阅读358次。1.介绍图的相关概念  图是由顶点的有穷非空集和一个描述顶点之间关系-边(或者弧)的集合组成。通常,图中的数据元素被称为顶点,顶点间的关系用边表示,图通常用字母G表示,图的顶点通常用字母V表示,所以图可以定义为:  G=(V,E)其中,V(G)是图中顶点的有穷非空集合,E(G)是V(G)中顶点的边的有穷集合1.1 无向图:图中任意两个顶点构成的边是没有方向的1.2 有向图:图中..._给定一个邻接矩阵未必能够造出一个图

随便推点

MDT2012部署系列之11 WDS安装与配置-程序员宅基地

文章浏览阅读321次。(十二)、WDS服务器安装通过前面的测试我们会发现,每次安装的时候需要加域光盘映像,这是一个比较麻烦的事情,试想一个上万个的公司,你天天带着一个光盘与光驱去给别人装系统,这将是一个多么痛苦的事情啊,有什么方法可以解决这个问题了?答案是肯定的,下面我们就来简单说一下。WDS服务器,它是Windows自带的一个免费的基于系统本身角色的一个功能,它主要提供一种简单、安全的通过网络快速、远程将Window..._doc server2012上通过wds+mdt无人值守部署win11系统.doc

python--xlrd/xlwt/xlutils_xlutils模块可以读xlsx吗-程序员宅基地

文章浏览阅读219次。python–xlrd/xlwt/xlutilsxlrd只能读取,不能改,支持 xlsx和xls 格式xlwt只能改,不能读xlwt只能保存为.xls格式xlutils能将xlrd.Book转为xlwt.Workbook,从而得以在现有xls的基础上修改数据,并创建一个新的xls,实现修改xlrd打开文件import xlrdexcel=xlrd.open_workbook('E:/test.xlsx') 返回值为xlrd.book.Book对象,不能修改获取sheett_xlutils模块可以读xlsx吗

关于新版本selenium定位元素报错:‘WebDriver‘ object has no attribute ‘find_element_by_id‘等问题_unresolved attribute reference 'find_element_by_id-程序员宅基地

文章浏览阅读8.2w次,点赞267次,收藏656次。运行Selenium出现'WebDriver' object has no attribute 'find_element_by_id'或AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'等定位元素代码错误,是因为selenium更新到了新的版本,以前的一些语法经过改动。..............._unresolved attribute reference 'find_element_by_id' for class 'webdriver

DOM对象转换成jQuery对象转换与子页面获取父页面DOM对象-程序员宅基地

文章浏览阅读198次。一:模态窗口//父页面JSwindow.showModalDialog(ifrmehref, window, 'dialogWidth:550px;dialogHeight:150px;help:no;resizable:no;status:no');//子页面获取父页面DOM对象//window.showModalDialog的DOM对象var v=parentWin..._jquery获取父window下的dom对象

什么是算法?-程序员宅基地

文章浏览阅读1.7w次,点赞15次,收藏129次。算法(algorithm)是解决一系列问题的清晰指令,也就是,能对一定规范的输入,在有限的时间内获得所要求的输出。 简单来说,算法就是解决一个问题的具体方法和步骤。算法是程序的灵 魂。二、算法的特征1.可行性 算法中执行的任何计算步骤都可以分解为基本可执行的操作步,即每个计算步都可以在有限时间里完成(也称之为有效性) 算法的每一步都要有确切的意义,不能有二义性。例如“增加x的值”,并没有说增加多少,计算机就无法执行明确的运算。 _算法

【网络安全】网络安全的标准和规范_网络安全标准规范-程序员宅基地

文章浏览阅读1.5k次,点赞18次,收藏26次。网络安全的标准和规范是网络安全领域的重要组成部分。它们为网络安全提供了技术依据,规定了网络安全的技术要求和操作方式,帮助我们构建安全的网络环境。下面,我们将详细介绍一些主要的网络安全标准和规范,以及它们在实际操作中的应用。_网络安全标准规范