Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module fsm_zad1
- (
- input w,clk,aclr,
- output reg z,
- output reg [8:0] y
- );
- //Zdefiniowanie stanów//
- localparam [8:0]
- A = 9'b000000001,
- B = 9'b000000010,
- C = 9'b000000100,
- D = 9'b000001000,
- E = 9'b000010000,
- F = 9'b000100000,
- G = 9'b001000000,
- H = 9'b010000000,
- I = 9'b100000000;
- reg [8:0] current = A, next;
- always @(*)
- begin
- y = current;
- case (current)
- A: if (!w) next = B; else next = F;
- B: if (!w) next = C; else next = F;
- C: if (!w) next = D; else next = F;
- D: if (!w) next = E; else next = F;
- E: if (!w) next = E; else next = F;
- F: if (!w) next = B; else next = G;
- G: if (!w) next = B; else next = H;
- H: if (!w) next = B; else next = I;
- I: if (!w) next = B; else next = I;
- default: next = 9'bxxxxxxxxx;
- endcase
- end
- always @(*)
- begin
- case (current)
- A: z = 1'b0;
- B: z = 1'b0;
- C: z = 1'b0;
- D: z = 1'b0;
- E: z = 1'b1;
- F: z = 1'b0;
- G: z = 1'b0;
- H: z = 1'b0;
- I: z = 1'b1;
- endcase
- end
- always @(posedge clk,posedge aclr)
- if (aclr)
- current <= A;
- else
- begin
- current <= next;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement