Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module swfsj7(input [1:0] SW,
- input KEY0,
- output [9:0] LEDR);
- zad3 ex(SW[1], KEY0, SW[0], LEDR[9]);
- endmodule
- module zad3(
- input w,clk,aclr,
- output reg z);
- reg [3:0] current, next;
- localparam [3:0]
- A = 4'b0000,
- B = 4'b0001,
- C = 4'b0010,
- D = 4'b0011,
- E = 4'b0100,
- F = 4'b0101,
- G = 4'b0110,
- H = 4'b0111,
- I = 4'b1000;
- always @(*)
- begin
- A: if (!w) next = B; else next = F;
- case (current)
- 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 = 4'bxxxx;
- endcase
- z = (current == E) | (current == I);
- end
- always @(posedge clk,negedge aclr)
- if (~aclr) current <= 0;
- else current <= next;
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement