Estoy escribiendo código para una combinación de cerradura de puerta. Mis entradas son b0, b1, b2 y b3, que corresponden a los botones para ingresar el código para desbloquear una puerta. El código para abrir esta puerta en particular es b2 --> b2 ---> b3 ---> b1.
Sin embargo, entre transiciones, el código debe tener en cuenta que el usuario levanta el dedo del botón antes de proceder a presionar el siguiente botón para el código de la puerta.
es decir. b2 --> soltar --> b2 --> soltar --> b2 --> soltar --> b3 ---> soltar --> cualquier botón ---> reiniciar. Si el usuario presiona el valor incorrecto en el proceso, el estado debe volver al reinicio.
La imagen a continuación es mi código, sin embargo, la síntesis está fallando. He revisado la lógica del siguiente estado de mi código, pero parece que no puedo encontrar ningún problema con él, y tampoco recibo ningún tipo de error de sintaxis.
Agradezco cualquier ayuda, gracias por su tiempo.
https://i.stack.imgur.com/8zBji.png
module Lock(input logic clk, reset, b0, b1, b2, b3,
output logic unlock);
typedef enum logic[2:0] {s0, s1, s2, s3, s4, s5, s6, s7, s8} statetype;
statetype state, nextstate;
//state register
always_ff @(posedge clk, posedge reset)
if (reset) state <= s0;
else state<=nextstate;
//next state logic
always_comb
case (state)
s0: if (b2 & ~b1 & ~b0 & ~b3) nextstate = s1;
else if (~(b2 & ~b1 & ~b0 & ~b3))nextstate = s0;//ie. if did not press the corrrect button (b2)
s1: if (~b2 & ~b1 & ~b0 & ~b3) nextstate = s2; //. ie move a state ahead when you release the b2
else if (b2 & ~b3 & ~b1 & ~b0) nextstate = s1; //ie. If user is holdig down the button b2.
s2: if (b2 & ~b1 & ~b0 & ~b3) nextstate = s3; //entering the second digit of the door code
else if(~( b2 & ~b1 & ~b0 & ~b3))nextstate = s0; //back to reset if the second digit inserted is not b2
else if ( ~ b2 & ~b3 & ~b1 & ~b0) nextstate=s2;//e. if still havent pressed a button, stay in state s2
s3: if (~b2 & ~b1 & ~b0 & ~b3) nextstate = s4; // ie. when releasing button b2
else if (b2 & ~b1 & ~b0 & ~b3) nextstate = s3;//ie. if holding down b2 still, stay in s3.
s4: if (b3 & ~b0 & ~b1 & ~b2) nextstate = s5;
else if (~(b3 & ~b0 & ~b1 & ~b2))nextstate = s0;
else if ( ~ b2 & ~b3 & ~b1 & ~b0) nextstate=s4;
s5: if (~b2 & ~b1 & ~b0 & ~b3) nextstate = s6;
else if (b3 & ~ b0 & ~ b1 & ~b2) nextstate=s5;
s6: if (b1 & ~b0 & ~b1 & ~b2 & ~b3) nextstate=s7;
else if (~ (b1 & ~b0 & ~b1 & ~b2 & ~b3))nextstate=s0;
else if ( ~ b2 & ~b3 & ~b1 & ~b0) nextstate=s6;
s7: if (~b2 & ~b1 & ~b0 & ~b3) nextstate = s8;
else if (b1 & ~b0 & ~b1 & ~b2 & ~b3) nextstate=s7;
s8: if (b0 + b1 + b2 + b3) nextstate = s0; //ie after unlocking, if press any button, return back to reset.
endcase
//output logic
assign unlock = (state==s7);
endmodule
Su logic
enumeración tiene 3 bits pero hay 9 valores en la enumeración. Debe proporcionar más bits logic
o reducir la cantidad de valores en la enumeración.
michel
eliot alderson
michel