The logic format of a mask ROM (10) is composed of a user region (11)
having a plurality of blocks, a spare region (12) having a plurality of
blocks, and a table region (13) having a plurality of blocks. When the
outside data is written in the mask ROM by the control of a MPU (24), if
there is a defective block in the user region, the defective block is
replaced by a spare block in the spare region. If the spare block is
defective, it is replaced by another spare block. The replacement
information (address, et.) is stored in a block in the table region, and
if the block of the table region is defective, it is replaced by another
block. Accordingly, since a defective block in the mask ROM (10) is
replaced by another block, a defective mask ROM is relieved.