Enable pps interrupts. Not sure why they were disabled in the first place.
[debian/gnuradio] / usrp2 / fpga / models / uart_rx.v
1
2
3 // Simple printout of characters from the UART
4 //   Only does 8N1, requires the baud clock
5
6 module uart_rx (input baudclk, input rxd);
7    reg [8:0] sr = 9'b0;
8    reg [3:0]  baud_ctr = 4'b0;
9
10    /*
11    wire       byteclk = baud_ctr[3];
12    reg        rxd_d1 = 0;
13    always @(posedge baudclk)
14      rxd_d1 <= rxd;
15    
16    always @(posedge baudclk)
17      if(rxd_d1 != rxd)
18        baud_ctr <= 0;
19      else
20        baud_ctr <= baud_ctr + 1;
21 */
22
23    wire       byteclk = baudclk;
24    
25    always @(posedge byteclk)
26      sr <= { rxd, sr[8:1] };
27
28    reg [3:0]  state = 0;
29    always @(posedge byteclk)
30      case(state)
31        0 : 
32          if(~sr[8] & sr[7])  // found start bit
33            state  <= 1;
34        1, 2, 3, 4, 5, 6, 7, 8 :
35          state <= state + 1;
36        9 : 
37          begin
38             state <= 0;
39             $write("%c",sr[7:0]);
40             if(~sr[8])
41               $display("Error, no stop bit\n");
42          end
43        default :
44          state <= 0;
45      endcase // case(state)
46
47 endmodule // uart_rx
48