Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Automatic parking control with counter

Hi all,

I have done a simple coding regarding my assignment but some error arise.

Can anyone tell me the problem

module parking (Remaining_spaces,G1,G2,E1,E2,clk,rst_n);

output Remaining_spaces;

input G1,G2,E1,E2;

input clk, rst_n;

parameter [2:0] IDLE = 3'b000,

DETECT = 3'b001,

FIND_IN = 3'b010,

FIND_OUT = 3'b011,

CHECK_IN = 3'b100,

CHECK_OUT= 3'b101;

reg [2:0] state, next;

always @ (posedge clk or negedge rst_n)

if (!rst_n) state <= IDLE;

else state <= next;

always @ (state or G1 or G2 or E1 or E2) begin

next = 3'bx;

case(state)

IDLE: begin

next = DETECT; // jump to the next state

end

DETECT : begin

if (G1 == 1'b1) begin

next = FIND_IN;

G1 = 1'b0;

end else if (G2 == 1'b1) begin

next = FIND_IN;

G2 = 1'b0;

end else if (E1 == 1'b1) begin

next = FIND_OUT;

E1 = 1'b0;

end else if (E2 == 1'b1) begin

next = FIND_OUT;

E2 = 1'b0;

end else begin

next = DETECT;

end

end

FIND_IN : begin

next = CHECK_IN ;

end

FIND_OUT : begin

next = CHECK_OUT ;

end

CHECK_IN: begin

Remaining_spaces = Remaining_spaces - 1;

end

CHECK_OUT: begin

Remaining_spaces = Remaining_spaces + 1;

end

endcase

end

endmodule
No RepliesBe the first to reply