End or New?

 Give me a new life!

Ok,but u will die first!

Yes I'll

 

It's not a joke. I will have a new life style .

 

thx Yazi , because ,he always study.

thx Mars, He has a real good tech.

thx H, He has a happy life ./

and thx My wife, I want give her a good life .!

thx My parent ,  for y I could be here ,writing this.

 

 

 

 

`timescale 1ns/1ps module password_lock( input clk, // ?????50MHz input rst_n, // ?????????? input [3:0] num_input, // ????(0-9) input enter, // ??? input reset, // ?????????? input [3:0] new_password, // ????????????????num_input??? output reg unlocked, // ???? output reg error, // ???? output reg locked_out, // ???????????3?? output reg [7:0] display_msg // ???? ); // ???? parameter DEFAULT_PASS = 24'h123456; // ????123456 (6?BCD?) parameter MAX_ATTEMPTS = 3; // ?????? // ????? reg [23:0] current_password; // ????(6?BCD???4???1???) reg [23:0] input_buffer; // ???? reg [23:0] new_pass_temp; // ???????? reg [2:0] digit_count; // ??????(0-5) reg [1:0] attempt_count; // ??????(0-3) reg [2:0] state; // ????? // ???? localparam IDLE = 3'b000; // ???? localparam INPUT = 3'b001; // ???? localparam VERIFY = 3'b010; // ???? localparam LOCKED = 3'b011; // ???? localparam RESETTING = 3'b100; // ?????? // ?????? localparam MSG_IDLE = 8'h00; // "???" localparam MSG_CORRECT = 8'h01; // "????" localparam MSG_WRONG = 8'h02; // "?????????: X" localparam MSG_LOCKED = 8'h03; // "???????" localparam MSG_RESET = 8'h04; // "?????: XXXXXX" // ????? always @(posedge clk or negedge rst_n) begin if (!rst_n) begin // ????? current_password <= DEFAULT_PASS; input_buffer <= 0; new_pass_temp <= 0; digit_count <= 0; attempt_count <= 0; state <= IDLE; unlocked <= 0; error <= 0; locked_out <= 0; display_msg <= MSG_IDLE; end else begin // ???? case (state) IDLE: begin unlocked <= 0; error <= 0; display_msg <= MSG_IDLE; // ????? if (reset) begin state <= RESETTING; digit_count <= 0; new_pass_temp <= 0; // ??????????? $display("????????"); end // ?????????? else if (enter && num_input <= 9) begin // ????? input_buffer <= (input_buffer << 4) | num_input; digit_count <= 1; state <= INPUT; $display("??: %d", num_input); end end INPUT: begin // ??????????? if (reset) begin state <= RESETTING; digit_count <= 0; new_pass_temp <= 0; // ??????????? $display("????????"); end // ?????????? else if (enter && num_input <= 9) begin // ?????????? input_buffer <= (input_buffer << 4) | num_input; digit_count <= digit_count + 1; $display("??: %d", num_input); // ??6???????? if (digit_count == 5) begin state <= VERIFY; $display("6????????????..."); end end end VERIFY: begin // ???? if (input_buffer == current_password) begin // ???? unlocked <= 1; error <= 0; attempt_count <= 0; display_msg <= MSG_CORRECT; $display("?????????"); state <= IDLE; end else begin // ???? unlocked <= 0; error <= 1; attempt_count <= attempt_count + 1; display_msg <= MSG_WRONG; $display("???????????: %d", MAX_ATTEMPTS - attempt_count - 1); // ???????? if (attempt_count >= MAX_ATTEMPTS - 1) begin locked_out <= 1; display_msg <= MSG_LOCKED; $display("??????3?????"); state <= LOCKED; end else begin // ????????????? input_buffer <= 0; digit_count <= 0; state <= IDLE; end end end LOCKED: begin // ???? locked_out <= 1; display_msg <= MSG_LOCKED; if (reset) begin state <= RESETTING; digit_count <= 0; new_pass_temp <= 0; // ??????????? locked_out <= 0; // ???? attempt_count <= 0; // ?????? $display("?????????????"); end end RESETTING: begin // ?????? display_msg <= MSG_RESET; if (enter && num_input <= 9) begin // ??????? new_pass_temp <= (new_pass_temp << 4) | num_input; digit_count <= digit_count + 1; $display("?????: %d", num_input); // ??6??????????????? if (digit_count == 5) begin current_password <= new_pass_temp; state <= IDLE; attempt_count <= 0; locked_out <= 0; $display("???????: %6h", new_pass_temp); end end end endcase end end endmodule 简述一下易错问题及解决思路
06-20
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值