应用场景
方法1:通过JTAG读取
Read Device DNA
,可以读出芯片的DNA。
REGISTER->EFUSE->DNA_PORT
,可以看到读取的DNA寄存器的值。
方法2:调用原语读取
DNA_PORT原语的使用
.SIM_DNA_VALUE(57′h000000000000000) // Specifies the Pre-programmed factory ID value
)DNA_PORT_inst (
.DOUT(DOUT), // 1-bit output: DNA output data
.CLK(CLK), // 1-bit input: Clock input
.DIN(DIN), // 1-bit input: User data input pin
.READ(READ), // 1-bit input: Active high load DNA, active low read input
.SHIFT(SHIFT) // 1-bit input: Active high shift enable input
);
.SIM_DNA_VALUE(96′h000000000000000000000000) // Specifies a sample 96-bit DNA value for simulation
)DNA_PORTE2_inst (
.DOUT(DOUT), // 1-bit output: DNA output data
.CLK(CLK), // 1-bit input: Clock input
.DIN(DIN), // 1-bit input: User data input pin
.READ(READ), // 1-bit input: Active-High load DNA, active-Low read input
.SHIFT(SHIFT) // 1-bit input: Active-High shift enable input
);
/***************************************************************
* Copyright(C), 2010-2022, YOUR CORP/INC/COMPANY/LTD/LIMITED.
* ModuleName : get_dna.v
* Date : 2022年5月22日
* Time : 11:06:00
* Author : wcc149
* Function : XC7A75T获取DNA芯片ID
* Version : v1.0
* Version | Modify
* ----------------------------------
* v1.0 .....
***************************************************************/
module get_dna(
//inputs
input clk,
input rst_n,
//Outputs
output reg [56:0] dna,
output reg dna_vld
);
localparam S0_IDLE = 4'd0;
localparam S1_LOAD = 4'd1;
localparam S2_SHIFT = 4'd2;
localparam S3_FINSIH = 4'd3;
reg [7:0] cnt_bit;
reg [56:0] dna_buf;
reg [3:0] fsm;
reg load;
reg shift;
always @ (posedge clk) begin
if(!rst_n) begin
cnt_bit <= 0;
fsm <= S0_IDLE;
load <= 0;
shift <= 0;
dna <= 0;
dna_vld <= 0;
end
else begin
case (fsm)
S0_IDLE: begin
if(cnt_bit != 10)//上电等待10个clk
cnt_bit <= cnt_bit + 1;
else begin
cnt_bit <= 0;
fsm <= S1_LOAD;
load <= 0;
shift <= 0;
dna <= 0;
dna_vld <= 0;
end
end
S1_LOAD:begin
if(cnt_bit != 5) begin//load信号维持5个clk
cnt_bit <= cnt_bit + 1;
load <= 1;
end
else begin
cnt_bit <= 0;
load <= 0;
fsm <= S2_SHIFT;
end
end
S2_SHIFT: begin
// if(cnt_bit != 56) begin //Spartan-6
if(cnt_bit != 57) begin //Artix-7
cnt_bit <= cnt_bit + 1;
shift <= 1;
end
else begin
shift <= 0;
fsm <= S3_FINSIH;
cnt_bit <= 0;
dna <= dna_buf;
end
end
S3_FINSIH: begin
cnt_bit <= 0;
dna <= dna;
dna_vld <= 1;
fsm <= S3_FINSIH;
end
endcase
end
end
//dout在上升沿变化,在下降沿采样
always @ (negedge clk) begin
if(!rst_n)
dna_buf <= 'h0;
else if(fsm == S2_SHIFT)
dna_buf <= dna_buf << 1 | dout;
else
dna_buf <= 'h0;
end
DNA_PORT #(
.SIM_DNA_VALUE(57'h123456789ABCDEF) // Specifies the Pre-programmed factory ID value
)get_xc6slx9_dna(
//Inputs
.CLK(clk), // 1-bit input: Clock input
.DIN(1'b0), // 1-bit input: User data input pin
.READ(load), // 1-bit input: Active high load DNA, active low read input
.SHIFT(shift), // 1-bit input: Active high shift enable input
//Outputs
.DOUT(dout) // 1-bit output: DNA output data
);
endmodule
没有回复内容