Rev | Line | |
---|
[28] | 1 | //typedef enum {ZERO,UN,DEUX} state_t; |
---|
| 2 | |
---|
| 3 | module concret(clk,i); |
---|
| 4 | input clk; |
---|
| 5 | |
---|
| 6 | reg p; |
---|
| 7 | reg q; |
---|
| 8 | input i; |
---|
| 9 | reg[1:0] state; |
---|
| 10 | |
---|
| 11 | initial |
---|
| 12 | begin |
---|
| 13 | p = 0; |
---|
| 14 | q = 0; |
---|
| 15 | state[1:0] = 0; |
---|
| 16 | end |
---|
| 17 | |
---|
| 18 | always @(posedge clk) |
---|
| 19 | begin |
---|
| 20 | case(state) |
---|
| 21 | 0 : |
---|
| 22 | if(i == 1) |
---|
| 23 | begin |
---|
| 24 | state[1:0] = 1; |
---|
| 25 | p = 0; |
---|
| 26 | q = 1; |
---|
| 27 | end |
---|
| 28 | else |
---|
| 29 | begin |
---|
| 30 | state[1:0] = 2; |
---|
| 31 | p = 1; |
---|
| 32 | q = 0; |
---|
| 33 | end |
---|
| 34 | 1 : if(i == 1) |
---|
| 35 | begin |
---|
| 36 | state[1:0] = 1; |
---|
| 37 | p = 0; |
---|
| 38 | q = 1; |
---|
| 39 | end |
---|
| 40 | else |
---|
| 41 | begin |
---|
| 42 | state[1:0] = 3; |
---|
| 43 | p = 1; |
---|
| 44 | q = 1; |
---|
| 45 | end |
---|
| 46 | 2 : if(i == 1) |
---|
| 47 | begin |
---|
| 48 | state[1:0] = 2; |
---|
| 49 | p = 1; |
---|
| 50 | q = 0; |
---|
| 51 | end |
---|
| 52 | else |
---|
| 53 | begin |
---|
| 54 | state[1:0] = 3; |
---|
| 55 | p = 1; |
---|
| 56 | q = 1; |
---|
| 57 | end |
---|
| 58 | 3 : if(i == 1) |
---|
| 59 | begin |
---|
| 60 | state[1:0] = 2; |
---|
| 61 | p = 1; |
---|
| 62 | q = 0; |
---|
| 63 | end |
---|
| 64 | else |
---|
| 65 | begin |
---|
| 66 | state[1:0] = 3; |
---|
| 67 | p = 1; |
---|
| 68 | q = 1; |
---|
| 69 | end |
---|
| 70 | |
---|
| 71 | endcase |
---|
| 72 | |
---|
| 73 | end |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | endmodule |
---|
Note: See
TracBrowser
for help on using the repository browser.