A semiconductor device includes a first memory including a first memory cell and a first redundant memory cell; a first test circuit configured to test the first memory and output first defect information indicating a defective portion included in the first memory cell; a first storage part; and a first control circuit configured to, based on unmodified information stored in the first storage part, and the first defect information, determine modified information to be stored in the first storage part, wherein the first memory identifies the defective portion based on the modified information of the first storage part and replaces the first memory cell including the defective portion with the first redundant memory cell.