Subversion Repositories pentevo

Rev

Rev 323 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
323 lvd 1
`include "../include/tune.v"
2
 
3
// Pentevo project (c) NedoPC 2011
4
//
5
// VGA scandoubler
6
 
7
module video_vga_double(
8
 
9
        input  wire        clk,
10
 
11
        input  wire        hsync_start,
12
 
13
        input  wire        scanin_start,
14
        input  wire [ 5:0] pix_in,
15
 
16
        input  wire        scanout_start,
17
        output reg  [ 5:0] pix_out
18
);
19
/*
20
addressing of non-overlapping pages:
21
 
22
pg0 pg1
23
0xx 1xx
24
2xx 3xx
25
4xx 5xx
26
*/
27
 
28
        reg [9:0] ptr_in;  // count up to 720
29
        reg [9:0] ptr_out; //
30
 
31
        reg pages; // swapping of pages
32
 
33
        reg wr_stb;
34
 
35
        wire [ 7:0] data_out;
36
 
37
 
38
        always @(posedge clk) if( hsync_start )
39
                pages <= ~pages;
40
 
41
 
42
        // write ptr and strobe
43
        always @(posedge clk)
44
        begin
45
                if( scanin_start )
46
                begin
47
                        ptr_in[9:8] <= 2'b00;
48
                        ptr_in[5:4] <= 2'b11;
49
                end
50
                else
51
                begin
52
                        if( ptr_in[9:8]!=2'b11 ) //  768-720=48
53
                        begin
54
                                wr_stb <= ~wr_stb;
55
                                if( wr_stb )
56
                                begin
57
                                        ptr_in <= ptr_in + 10'd1;
58
                                end
59
                        end
60
                end
61
        end
62
 
63
 
64
        // read ptr
65
        always @(posedge clk)
66
        begin
67
                if( scanout_start )
68
                begin
69
                        ptr_out[9:8] <= 2'b00;
70
                        ptr_out[5:4] <= 2'b11;
71
                end
72
                else
73
                begin
74
                        if( ptr_out[9:8]!=2'b11 )
75
                        begin
76
                                ptr_out <= ptr_out + 10'd1;
77
                        end
78
                end
79
        end
80
 
81
        //read data
82
        always @(posedge clk)
83
        begin
84
                if( ptr_out[9:8]!=2'b11 )
85
                        pix_out <= data_out[5:0];
86
                else
87
                        pix_out <= 6'd0;
88
        end
89
 
90
 
91
 
92
 
93
 
94
        mem1536 line_buf( .clk(clk),
95
 
96
                          .wraddr({ptr_in[9:8], pages, ptr_in[7:0]}),
97
                          .wrdata({2'b00,pix_in}),
98
                          .wr_stb(wr_stb),
99
 
100
                          .rdaddr({ptr_out[9:8], (~pages), ptr_out[7:0]}),
101
                          .rddata(data_out)
102
                        );
103
 
104
 
105
endmodule
106
 
107
 
108
 
109
 
110
// 3x512b memory
111
module mem1536(
112
 
113
        input  wire        clk,
114
 
115
        input  wire [10:0] wraddr,
116
        input  wire [ 7:0] wrdata,
117
        input  wire        wr_stb,
118
 
119
        input  wire [10:0] rdaddr,
120
        output reg  [ 7:0] rddata
121
);
122
 
123
        reg [7:0] mem [0:1535];
124
 
125
        always @(posedge clk)
126
        begin
127
                if( wr_stb )
128
                begin
129
                        mem[wraddr] <= wrdata;
130
                end
131
 
132
                rddata <= mem[rdaddr];
133
        end
134
 
135
endmodule
136
 
137