Question

In: Electrical Engineering

imulate/ code in verilog: Develop an electronic key system using the FSM (moore) methology. Use from...

imulate/ code in verilog:

Develop an electronic key system using the FSM (moore) methology. Use from student ID and use the last 4 digits:(0864)

if the number is <5 then = 1

if the number is >=5 then = 0

example: 8012345. Take last 4 digits (2345) which makes it 0001.

In my case, the last 4 digits are 0864, which makes it 0110

features of FSM (moore FSM):

input 4 bits serially,

if the sequence is correct, then you proceed to next state. Otherwise, go to error state, then go to rest state

Solutions

Expert Solution

module fsm (input clock, X, output reg Z);

parameter REST=4'b0000, BIT1_C=4'b0001, BIT1_W=4'b0010, BIT2_C=4'b0011, BIT2_W=4'b0100, BIT3_C=4'b0101, BIT3_W=4'b0110, ERROR=4'b0111, NEXT=4'b1000; //define states

reg [3:0] current_state, next_state;

always @ (posedge clock)

begin

current_state <= next_state;

end

always @ (current_state, X)

begin

Z <= 1'b0; //output

case (current_state)

REST : if (X == 1'b0) //check for input '0'

next_state <= BIT1_C;

else

next_state <= BIT1_W;

BIT1_C : if (X == 1'b1) //check for input '1'

next_state <= BIT2_C;

else

next_state <= BIT2_W;

BIT1_W : next_state <= BIT2_W;

BIT2_C : if (X == 1'b1) //check for input '1'

next_state <= BIT3_C;

else

next_state <= BIT3_W;

BIT2_W : next_state <= BIT3_W;

BIT3_C : if (X == 1'b0) //check for input '0'

next_state <= NEXT;

else

next_state <= ERROR;

BIT3_W : next_state <= ERROR;

ERROR : next_state <= REST;

NEXT : Z <= 1'b1; // next_state <= REST; //uncomment this statement if design requires to reset after every successful key verification

default : next_state <= REST;

endcase

end

endmodule

//Simulation


Related Solutions

Design an Moore FSM for an 8-interval stoplight system where the red light is ON (yellow...
Design an Moore FSM for an 8-interval stoplight system where the red light is ON (yellow and green lights are OFF) for 4 intervals, then yellow light is ON (red and green lights are OFF) for 1 interval and then green light is ON (red and yellow lights are OFF) for 3 intervals. After the green light has been ON for three intervals, we go back to the red light being ON for 4 intervals. Use binary encoding for states...
Write Verilog code for a Moore detector that detects sequences 10111 and 10101 on its j...
Write Verilog code for a Moore detector that detects sequences 10111 and 10101 on its j input and creates a pulse of exactly one clock duration on its output. The output becomes 1 if either of the sequences, or an overlap of the two is detected. A) Show the state diagram of this machine. B) Write complete Verilog for the design. C) Write a testbench and test your state machine using ModelSim.
Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or...
Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or half adders. Please include testbench
Using vhdl in a FSM , how could you write code to delay a state change...
Using vhdl in a FSM , how could you write code to delay a state change for one hour? For example, you have a fan running in the 'on' state , but after 1 hour you would like that fan to switch back to the 'off' state. What is the best way going about doing this?
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point...
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point representation.
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
Design a 32 bit after using a single 4 bit using verilog code
Design a 32 bit after using a single 4 bit using verilog code
write a verilog code to implement a digital system that has an odd counter that counts...
write a verilog code to implement a digital system that has an odd counter that counts from 1 to 11. Also, this system has an output Y that detects a specific number in the odd counter. Test your code when you detect the number 3, the output Y is 1, if the counter value is set to 3, otherwise 0.
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT