Rev 534 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
534 | lvd | 1 | // prints data output through SDcard spi iface |
2 | // |
||
3 | |||
4 | `ifdef SPITEST |
||
5 | module spitest_print( |
||
6 | |||
7 | input wire sdclk, |
||
8 | input wire sdcs_n, |
||
9 | input wire sddo, |
||
10 | output wire sddi |
||
11 | ); |
||
12 | |||
13 | |||
14 | assign sddi = 1'b1; |
||
15 | |||
16 | |||
17 | |||
18 | |||
19 | reg [7:0] txt_buffer [0:255]; |
||
20 | |||
21 | reg [7:0] shift_in; |
||
22 | |||
23 | integer counter; |
||
24 | integer pointer; |
||
25 | integer i; |
||
26 | |||
27 | |||
28 | initial |
||
29 | begin |
||
30 | counter = 0; |
||
31 | pointer = 0; |
||
32 | end |
||
33 | |||
34 | |||
35 | |||
36 | always @(posedge sdclk) |
||
37 | if( !sdcs_n ) |
||
38 | begin |
||
39 | shift_in = { shift_in[6:0], sddo }; |
||
40 | |||
41 | counter = counter + 1; |
||
42 | |||
43 | if( counter >= 8 ) |
||
44 | begin |
||
45 | counter = 0; |
||
46 | |||
47 | txt_buffer[pointer] = shift_in; |
||
48 | pointer = pointer + 1; |
||
49 | |||
50 | if( shift_in == 8'd10 ) |
||
51 | begin |
||
52 | $write("received string: <"); |
||
53 | |||
54 | for(i=0;i<(pointer-1);i=i+1) |
||
55 | $write("%s",txt_buffer[i]); |
||
56 | |||
57 | $display(">"); |
||
58 | |||
59 | pointer = 0; |
||
60 | end |
||
61 | end |
||
62 | |||
63 | end |
||
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | endmodule |
||
70 | `endif |
||
71 |