// 同步时序,描述次状态寄存器转移到现态寄存器
always @(posedge clk or posedge reset) begin
if(reset)
current_state <= S_IDLE;
else
current_state <= next_state;
end
// 产生下一个状态的组合逻辑(只与输入和当前状态有关)
always @(current_state or count) begin
next_state = 2'bxx; // 要初始化,使得系统复位后能进入正确的状态
case (current_state)
S_IDLE: begin
next_state = S_READ;
end
S_READ: begin
next_state = S_SHIFT;
end
S_SHIFT: begin
if(count == 57)
next_state = S_WRITE;
else
next_state = S_SHIFT;
end
S_WRITE: begin
next_state = S_IDLE;
end
default:
next_state = S_IDLE;
endcase
end
// 同步时序,描述次态寄存器输出
always @(posedge clk or posedge reset) begin
if(reset) begin
read <= 0;
shift <= 0;
din <= 0;
count <= 0;
end
else begin
case(next_state)
S_IDLE: begin
read <= 0;
shift <= 0;
din <= 0;
count <= 0;
end
S_READ: begin
read <= 1;
shift <= 0;
din <= 0;
count <= 0;
end
S_SHIFT: begin
read <= 0;
shift <= 1;
count <= count + 1;
end
S_WRITE: begin
read <= 0;
shift <= 0;
end
default: begin
read <= 0;
shift <= 0;
count <= 0;
end
endcase
end
end
// 同步时序,描述次态寄存器输出
always @(posedge clk or posedge reset) begin
if(reset) begin
dna_id <= 0;
end
else begin
case(current_state)
S_SHIFT: begin
dna_id <= dna_id << 1;
dna_id[0] <= dout_c;
end
记错了,呵呵。spartan6的可以直接读出来.
DNA information is given in the respective Configuration user guide and the Device software library HDL user guide for the primitive.
For Spartan-3A series devices (Spartan-3A, Spartan-3AN and Spartan-3ANDSP)
To read if the DNA iMPACT batch mode command is available. ("readDna -p <position>")
For Spartan-6 and Virtex-6 FPGA devices:
A GUI option available in the iMPACT s/w under the "Process window", called "Read Device DNA". Also, the iMPACT batch mode command "readDna -p <position>" will work.
For 7 series FPGA devices (Artix-7, Kintex-7 and ZynQ-7)
Pre-iMPACT 14.4 does NOT have a GUI option available for READ DEVICE DNA in the iMPACT software under the "Process window". To get the Device DNA value read from the JTAG port, simply run the iMPACT batch mode command "readDna -p <position>"