看看这个程序可行 module codelock( indata, // 密码锁输入数字 set, // 重新设置密码 outdata // 开关控制信号 ); parameter IN_MSB = 5; // 假定密码锁位数为6 input[IN_MSB:0] indata; input set; output outdata; wire[IN_MSB:0] rightkey; // 只有在密码锁开启状态下可以重新设置密码 assign rightkey = (outdata==1&&set==1) ? indata : rightkey; // 当输入数字与当前设置密码匹配时输出开关控制信号 assign outdata = (indata == rightkey) ? 1 : 0; endmodule |