User`s manual

23
24 // horizontal: 800 pixels total
25 // display 640 pixels per line
26 reg hblank,vblank;
27 wire hsyncon,hsyncoff,hreset,hblankon;
28 assign hblankon = (hcount == VGA_HBLANKON);
29 assign hsyncon = (hcount == VGA_HSYNCON);
30 assign hsyncoff = (hcount == VGA_HSYNCOFF);
31 assign hreset = (hcount == VGA_HRESET);
32
33 // vertical: 524 lines total
34 // display 480 lines
35 wire vsyncon,vsyncoff,vreset,vblankon;
36 assign vblankon = hreset & (vcount == VGA_VBLANKON);
37 assign vsyncon = hreset & (vcount == VGA_VSYNCON);
38 assign vsyncoff = hreset & (vcount == VGA_VSYNCOFF);
39 assign vreset = hreset & (vcount == VGA_VRESET);
40
41 // sync and blanking
42 wire next_hblank,next_vblank;
43 assign next_hblank = hreset ? 0 : hblankon ? 1 : hblank;
44 assign next_vblank = vreset ? 0 : vblankon ? 1 : vblank;
45 always @(posedge vclock) begin
46 hcount <= hreset ? 0 : hcount + 1;
47 hblank <= next_hblank;
48 hsync <= hsyncon ? 0 : hsyncoff ? 1 : hsync; // active low
49
50 vcount <= hreset ? (vreset ? 0 : vcount + 1) : vcount;
51 vblank <= next_vblank;
52 vsync <= vsyncon ? 0 : vsyncoff ? 1 : vsync; // active low
53
54 blank <= next_vblank | (next_hblank & ~hreset);
55 end
56 endmodule
A.1.5 divider.v
1 // The divider module divides one number by another. It
2 // produces a signal named "ready" when the quotient output
3 // is ready, and takes a signal named "start" to indicate
4 // the the input dividend and divider is ready.
5 // sign -- 0 for unsigned, 1 for twos complement
6
7 // It uses a simple restoring divide algorithm.
8 // http://en.wikipedia.org/wiki/Division_(digital)#Restoring_division
9
37