File: autoasciienum_onehot.v

package info (click to toggle)
verilog-mode 20161124.fd230e6-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,764 kB
  • ctags: 5,143
  • sloc: lisp: 12,430; perl: 293; makefile: 146; sh: 35; fortran: 2
file content (56 lines) | stat: -rw-r--r-- 1,572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// lint_checking MODLNM OFF

module autoasciienum_onehot (
                             input  clk,
                             input  rst_n,
                             output ack
                             );
   
   localparam // synopsys enum state_info
     IDLE  = 0,
     S1    = 1,
     S2    = 2,
     S3    = 3,
     DONE  = 4;
   
   reg [4:0] // synopsys enum state_info
             cur_state, nxt_state;
   
   always @ (*) begin
      nxt_state  = 5'h0;
      
      case (1'b1)
        cur_state[IDLE] : nxt_state[S1]    = 1'b1;
        cur_state[S1]   : nxt_state[S2]    = 1'b1;
        cur_state[S2]   : nxt_state[S3]    = 1'b1;
        cur_state[S3]   : nxt_state[DONE]  = 1'b1;
        cur_state[DONE] : nxt_state[DONE]  = 1'b1;
      endcase
   end
   
   always @ (posedge clk or negedge rst_n)
     if (rst_n == 1'b0) begin
        cur_state <= 'h1;
     end
     else begin
        cur_state <= nxt_state;
     end
   
   assign ack  = cur_state[DONE];
   
   /*AUTOASCIIENUM("cur_state", "cur_state_ascii")*/
   // Beginning of automatic ASCII enum decoding
   reg [31:0] cur_state_ascii;  // Decode of cur_state
   always @(cur_state) begin
      case ({cur_state})
        (5'b1<<IDLE):     cur_state_ascii  = "idle";
        (5'b1<<S1):       cur_state_ascii  = "s1  ";
        (5'b1<<S2):       cur_state_ascii  = "s2  ";
        (5'b1<<S3):       cur_state_ascii  = "s3  ";
        (5'b1<<DONE):     cur_state_ascii  = "done";
        default:          cur_state_ascii  = "%Err";
      endcase
   end
   // End of automatics
   
endmodule