A kind of write-protect implementation method that guides with ROM (read-only memory)
Technical field
The present invention relates to a kind of write-protect logic realization method that guides with ROM (read-only memory), belong to the applied technical field of semiconductor memory chips.
Background technology
In some electronic equipments, the board pilot ROM (read-only memory) of guiding function has been installed all usually on the veneer.Owing to have inconsiderate total factor unavoidably in the single-board bootstrap program design, and has new demand at any time, therefore board pilot is all supported online upgrade function generally speaking with ROM (read-only memory), and this moment, guiding must allow to be written into new boot with ROM (read-only memory) in the specific time.But in the veneer operational process, the situation of program fleet may appear.If program fleet is to the corresponding guiding erasable function of ROM (read-only memory), perhaps the write operation behind program fleet has just in time met the write operation sequential of guiding with ROM (read-only memory), then guiding will be wiped free of or rewrite with ROM (read-only memory), thereby the damage single-board bootstrap program causes veneer normally not start therefrom.The basic skills that the solution guiding is rewritten with ROM (read-only memory) is carried out write-protect to guiding with ROM chip exactly, when needs carry out write operation to guiding with ROM (read-only memory), forbids defencive function, restarts the write-protect function after write operation is finished.
Existing guiding is carried out in the write-protected method with ROM (read-only memory), mostly adopted hardware to realize.Different guiding ROM chip realizes that the method for data protection is also different.The guiding that has has program voltage pin VPP with ROM chip itself, and this class device requires to provide specific program voltage at the VPP pin when programming, and this voltage is different from the normal working voltage of chip.Guiding generally is to be provided by programmable device when loading with the program voltage of ROM (read-only memory), and this program voltage is not provided on veneer, so just when normal working of single board, just can guarantee that on hardware guiding can not be written into ROM device.The VPP of the chip that has end, when input voltage during greater than a certain threshold value, then device allows to be written into, if be lower than a certain threshold value, then device will be forbidden writing.Utilize this characteristic, can on veneer the VPP signal be implemented independent control, only it is set to be higher than voltage threshold again when guiding is programmed with ROM chip, and voltage threshold can generally provide in the device handbook.
In addition, also can realize data protection by the part control line of device.The write-protect that realizes by the control pin prevents that in fact just software from writing the accident of guiding with ROM chip.Guiding with ROM chip with write relevant control pin WP# (write-protect) and WE# (writing permission) arranged; some device also provides RP# (resetting or power down) pin; the control pin that different chips may provide is incomplete same; for example the SST39VF040 chip capacity is less; generally be used for the board pilot ROM (read-only memory), chip only provides WE# and does not have WP# and RP# pin.If device has the RP# pin, need to confirm before cpu reset finishes, will guide RP# pin to be changed to high level by low level with ROM chip.If guiding is carried out data protection with the ROM chip support by RP#, but advise that then WP# is set to guiding with the ROM (read-only memory) write state, realizes the data protection of guiding with ROM (read-only memory) and pass through control RP#; If only there is the WP# control line in guiding with ROM (read-only memory), then can controls WP# and realize data protection; There is not the control line of similar RP# in the if there is no control line of similar WP# yet, can also realize data protection by control WE# signal wire.Generally same chip is realized that the kinds of protect mode there is no need.If realize data protection by control WE# signal wire, generally be that WE# is drawn the dead high level that is in design, just can not support online upgrade function but guide in this case with ROM (read-only memory).The flash memory of other larger capacity (Flash) possesses the sector defencive function, and this also is a kind of protected mode of software.
Above-mentioned guiding mainly is pins such as the VPP, the WP# that have adopted chip itself, RP# with the Write-protection method of ROM (read-only memory).Utilize these pins to realize that write-protected precondition must be that chip itself provides these pins.But guiding commonly used now not necessarily provides these pins with ROM chip.If in addition WE# is drawn to fixing high level, then guides with ROM (read-only memory) and can not support online upgrade function again.
Be not fixing high level if WE# draws, utilize WE# to realize that to the write-protect of guiding with ROM (read-only memory), then guiding must be drawn with the WE# pin of ROM chip from logic, but the WE# signal be not the pin that must draw from logic.Comparatively speaking, guiding is come by decoding by logic with the chip selection signal CE# of ROM chip.Especially some veneer is not considered at the beginning of design and is supported the write-protect function, but their CE# but draws by logical device.
Summary of the invention
It is limited with the Write-protection method defencive function of ROM (read-only memory) to the present invention is directed to existing guiding; and use the shortcoming of underaction; a kind of write-protect logic realization method that guides with ROM (read-only memory) has been proposed; to strengthen the write-protect function of guiding, reduce the probability that it is wiped free of or is rewritten with ROM (read-only memory).
The guiding that the present invention the proposes write-protect logic realization method of ROM (read-only memory) may further comprise the steps:
(1) write-protect data register and write-protect status register are set, and are respectively above-mentioned two its registers addresses;
Described write-protect status register comprises " write-protect enables " state and " write-protect is forbidden " state;
(2) respectively put an initial value for above-mentioned two registers, guide with ROM (read-only memory) and be set to " write-protect enables " state;
(3) write data to the write-protect data register continuously, whenever write data, the value of write-protect status register changes once, is a particular value up to this value, and guide with ROM (read-only memory) and be set to " write-protect is forbidden " state this moment;
(4) guiding is deciphered with the chip selection signal of ROM (read-only memory), made guiding effective with the chip selection signal of ROM (read-only memory), carry out write operation to guiding with ROM (read-only memory) this moment;
(5) after write operation finishes, write data, make guiding be in " write-protect enables " state again with ROM (read-only memory) to the write-protect data register.
In above-mentioned (4) step, what be used for guiding is deciphered with the chip selection signal of ROM (read-only memory) is most significant digit and other control signal of chip of write-protect status register.
Write-protect status register in the said method also comprises " intermediate state " state, and in wherein said (3) step, its process is as follows:
When (1) initial, the write-protect status register is in " write-protect enables " state;
(2) at " write-protect enables " state, write first setting data, make the write-protect status register enter " intermediate state " state, if other operation then turns back to " write-protect enables " state to the write-protect data register;
(3) in " intermediate state "; if write first setting data to the write-protect data register; then the write-protect status register is kept current state; if write second setting data to the write-protect data register; make the write-protect status register enter " write-protect is forbidden " state; if other operation then turns back to " write-protect enables " state.
The guiding that the present invention the proposes write-protect logic realization method of ROM (read-only memory); for the veneer of not realizing in design initial guiding with ROM (read-only memory) write-protect function; can consider whether this chip provides the hardware pin relevant with write-protect; as long as guiding is obtained by logic decoding with the CE# signal of ROM chip; just can realize the write-protect function of guiding by the change logic with ROM (read-only memory).If this Write-protection method and other Write-protection method use simultaneously, then can greatly strengthen guiding write-protect function with ROM (read-only memory), reduce the probability that guiding is wiped free of or is rewritten with ROM (read-only memory).Method of the present invention can be applied to and comprise guiding with all flash chips (Flash) of ROM (read-only memory), and wherein guiding is realized the write-protect function with ROM chip.
Description of drawings
Fig. 1 is the process flow diagram that the present invention realizes an embodiment of write-protect logic.
Embodiment
Below in conjunction with accompanying drawing, the guiding that the present invention is proposed describes in detail with the write-protect logic realization method of ROM (read-only memory).
(1) register is set
One 8 write-protect data register and one 3 write-protect status register are set in logic.Be two its registers addresses separately.Had after the address, write process, promptly can implement the register pair read or write by in logic, setting up.
Above-mentioned write-protect status register is used to represent guide the write-protect state with ROM (read-only memory), and it one has three kinds of states: " write-protect enables ", " intermediate state ", " write-protect is forbidden "." intermediate state " wherein be the write-protect logic from " write-protect enables " state variation to " write-protect is forbidden " state must process intermediateness, when this state, still can not write data in ROM (read-only memory) to guiding.
The write-protect data register is used for to wherein writing data, and when writing certain data in the write-protect data register, corresponding variation will take place the state of write-protect status register
The figure place of above-mentioned write-protect status register can become, and can be designed to 2 or other as required.The data number that writes continuously in the write-protect data register can flexible design, if increase the data number, intermediate state is also done corresponding increase, to strengthen the write-protect function.The value that writes continuously in the write-protect data register also can flexible design.
(2) be that two registers are provided with initial value
When Board Power up or when resetting, the write-protect logic enters " write-protect enables " state, and be changed to entirely " 1 " with the write-protect data register this moment, and the write-protect status register also is changed to " 1 " entirely;
(3) write-protect is forbidden
If implement must at first make then that to the write operation of guiding the write-protect logic is in " forbidding write-protect " state with ROM (read-only memory).At this moment, write-protect logic needs through " write-protect enables ", " intermediate state ", " write-protect is forbidden " three kinds of states.
One embodiment of the present of invention are example with two " intermediate states ", and as shown in Figure 1, at this moment, the write-protect logic needs through " write-protect enables ", " the 1st intermediate state ", " the 2nd intermediate state ", " write-protect is forbidden " four kinds of states.If realize forbidding the write-protect function, then write 3 data: 0xAA, 0x99,0x66 (3 write operations must be continuous) to data register continuously.Whenever write data, the value of write-protect status register just takes place once to change, and is " 011 " up to its value, when the value of write-protect status register be " 011 ", guides this moment to be in " write-protect is forbidden " state with ROM (read-only memory).
As shown in Figure 1, the transformational relation between four of the write-protect status register kinds of states is as follows:
When Board Power up or when resetting, the write-protect status register is in " write-protect enables " state;
At " write-protect enables " state, if write first setting data (for example 0xAA) to the write-protect data register, then the write-protect status register enters " the 1st intermediate state " state, if other operation then will be kept current state;
At " the 1st intermediate state " state, if write first setting data (for example 0xAA) to the write-protect data register, then the write-protect status register is kept current state, if write second setting data (for example 0x99) to the write-protect data register, then the write-protect status register enters " the 2nd intermediate state " state, if other operation then turns back to " write-protect enables " state;
At " the 2nd intermediate state " state, if write the 3rd setting data (for example 0x66) to the write-protect data register, then the write-protect status register enters " write-protect is forbidden " state, if other operation then turns back to " write-protect enables ";
At " write-protect is forbidden " state; if write the 4th setting data (for example 0x55) to the write-protect data register; then the write-protect status register turns back to " write-protect enables " state; if other operation then can be carried out write operation and other any operation of guiding with ROM (read-only memory).
At " write-protect is forbidden " state; can carry out write operation and other any operation of guiding with ROM (read-only memory); if write the 4th setting data (0x55) to the write-protect data register, then the write-protect status register turns back to " write-protect enables " state.
The corresponding relation of the four kinds of states of write-protect status register and the register value of write-protect status register is as follows:
The value of " write-protect enables " state--write-protect status register is " 111 ";
The value of " the 1st intermediate state " state--write-protect status register is " 110 ";
The value of " the 2nd intermediate state " state--write-protect status register is " 101 ";
The value of " write-protect is forbidden " state--write-protect status register is " 011 ".
(4) implement the write operation of guiding with ROM (read-only memory)
When the write-protect status register is in " write-protect is forbidden " state, can carry out write operations such as online upgrading with ROM (read-only memory) to guiding.When enforcement was used the write operation of ROM (read-only memory) to guiding, guiding should be deciphered with other control signal by the 2nd bit data of write-protect status register with the chip selection signal of ROM (read-only memory) and obtain.The state of CE# signal is except by in the general control signal, beyond (comprising the read signal, write signal, high-order address signal, chip selection signal of CPU etc.) decoding obtains, also is subjected to the 2nd control of write-protect status register.In addition, when carrying out read operation, the CE# signal should not be subjected to the 2nd control of write-protect status register.
(5) after write operation finishes, the write-protect status register is changed to the write-protect state again.Write the 4th data 0x55 to the write-protect data register, then guide with ROM (read-only memory) to be in the write-protect state again.