User`s manual
131 busy <= 0;
132 state <= WRITE_READY;
133 end
134 else
135 mode <= MODE_IDLE;
136
137 READ_READY://5 //ready to read data
138 if(doread)
139 begin
140 busy <= 1;
141 mode <= MODE_READ;
142 if(busy) //lets the fsm raise its busy level
143 state <= READ_WAIT;
144 end
145 else
146 busy <= 0;
147
148 READ_WAIT://6 //waiting for flash to give the data up
149 if(!fsm_busy)
150 begin
151 busy <= 0;
152 state <= READ_READY;
153 end
154 else
155 mode <= MODE_IDLE;
156
157 default: begin //should never happen...
158 state <= 3’d7;
159 end
160 endcase
161 end
162 endmodule
A.1.11 test fsm.v
1 ‘define STATUS_RESET 4’h0
2 ‘define STATUS_READ_ID 4’h1
3 ‘define STATUS_CLEAR_LOCKS 4’h2
4 ‘define STATUS_ERASING 4’h3
5 ‘define STATUS_WRITING 4’h4
6 ‘define STATUS_READING 4’h5
7 ‘define STATUS_SUCCESS 4’h6
8 ‘define STATUS_BAD_MANUFACTURER 4’h7
9 ‘define STATUS_BAD_SIZE 4’h8
10 ‘define STATUS_LOCK_BIT_ERROR 4’h9
11 ‘define STATUS_ERASE_BLOCK_ERROR 4’hA
73