Background technology
In the intelligent card chip emulator, can relate to the emulation of FLASH/EEPROM module,
1. before chip is realized, need emulator to realize usually, and also do not have the way of realization of FLASH/EEPROM this moment, particularly as Embedded FLASH/EEPROM module.
2. consider from the compatibility of emulator that the packing forms of FLASH/EEPROM, pin are arranged various, be difficult for assembling realization on same PCB.
A kind of NVRAM of employing that the present invention proposes adds the mode of logical circuit and comes the method for emulation FLASH/EEPROM can solve this type of problem.
Summary of the invention
The function that the present invention adopts NVRAM power down data not lose, the non-volatile characteristic of the data of emulation FLASH/EEPROM; The mode of employing fpga logic and NVRAM combination realizes the emulation of FLASH/EEPROM, pass through logical course, the various states of emulation FLASH/EEPROM, as wipe, programme, write caching of page district, sense data etc., and counter mode regularly, the sequential of the control signal of structure FLASH/EEPROM; When erase operation, force " 1 " is write NVRAM, when programming operation, pass through logical algorithm, promptly utilize data " with " function, when writing data to NVRAM, earlier the data in the NVRAM are read out, do AND-operation with the data that will write, its result is as the data that really write NVRAM, when the data of NVRAM inside were " 0 ", the data perseverance behind the AND-operation was " 0 ", guaranteed that the data that write are " 0 ", when only the data in NVRAM are " 1 ", data behind the AND-operation could with the data consistent that will write, thereby write among the NVRAM, realized that " 0 " function is write in the wiping " 1 " of FLASH/EEPROM.Simultaneously, adopt the function in the caching of page district of FPGA internal RAM emulation FLASH/EEPROM.
Embodiment
Below in conjunction with accompanying drawing the present invention is further described.
A kind of FLASH/EEPROM emulation mode based on NVRAM disclosed in this invention can be preserved data characteristic, the data hold function of emulation FLASH/EEPROM after utilizing the NVRAM power down; By logical circuit, come the wiping of emulation FLASH/EEPROM, program timing sequence; Adopt the caching of page district of FPGA internal RAM emulation FLASH/EEPROM; " 0 " function is write in wiping " 1 " with FPGA internal logic realization FLASH/EEPROM.
Logical circuit is described below:
Design a counting logic, as shown in Figure 2, no matter be erase operation or programming operation, the address signal of NVRAM is produced simultaneously by the output signal and the outside Input Address signal of counter, read-write according to the counter meter time certain, produce in conjunction with the Mbus signal, it is fixed that the concrete time can require according to the sequential of FLASH/EEPROM.Also design the caching of page district of an inside simultaneously, be used to deposit page or leaf or half page of data programmed, when carrying out programming operation, read the data in caching of page district earlier, write NVRAM again.
Under the effect of system clock and mode select signal, produce the Status Flag signal (as: page or leaf or half page wipe or programming state, write the caching of page zone state) of various operations by state machine generative circuit module.Designing a counter circuit, when the program enable signal is effective Mbus is counted, is basically under some Status Flags, when counter arrives certain value, produces corresponding state enable signal.Sequential chart as shown in Figure 3.
Enable the valid period at state, the address generator module is with counter output valve and outside Input Address signal combination, produce the address signal of NVRAM and the page address signal in caching of page district, the rule of combination of NVRAM address signal is least-significant byte address (the page operations mode of the output valve calculated address of counter, be 256 bytes) or low 7 bit address (half page mode, be 128 bytes), other high position of outside Input Address calculated address.The rule of combination of caching of page regional address signal is 8 bit address of counter output.
Read-write maker module produces the read-write of NVRAM and the read signal in caching of page district according to the output signal and the state enable signal of counter.
Enable the valid period at state, if Status Flag is erase operation (page or leaf or half page), the data of then exporting to NVRAM are " 1 ".Realize wiping " 1 " function of FLASH/EEPROM.
Enable the valid period at state, if Status Flag is programming operation (page or leaf or half page), when the address generator module is exported the address of a NVR, also export a caching of page regional address, meanwhile, read-write maker module is simultaneously output page read signal and NVR read signal also, reads value in the caching of page district and the data of NVRAM, two data are done AND operation in data conversion module, as the data that will write NVRAM.Realize to write " 0 " among the FLASH/EEPROM function that can not one writing.The write signal of last read-write maker module output NVRAM.The output data of data conversion module is write NVRAM.Sequential as shown in Figure 4.
The value in caching of page district writes external data by write signal in advance under corresponding mode of operation.