OpenCores
URL https://opencores.org/ocsvn/wb_lcd/wb_lcd/trunk

Subversion Repositories wb_lcd

[/] [wb_lcd/] [trunk/] [verilog/] [wb_lcd/] [boards/] [s3esk-mm_lcd/] [rtl/] [system.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jvillar
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  system.v                                                    ////
4
////                                                              ////
5
////  This file is part of:                                       ////
6
////  WISHBONE/MEM MAPPED CONTROLLER FOR LCD CHARACTER DISPLAYS   ////
7
////  http://www.opencores.org/projects/wb_lcd/                   ////
8
////                                                              ////
9
////  Description                                                 ////
10
////   - Memory mapped controller testbench implementation for    ////
11
////     Spartan 3E Starter Kit (XC3S500E) board from Digilent.   ////
12
////  To Do:                                                      ////
13
////   - nothing really                                           ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////   - José Ignacio Villar, jose@dte.us.es , jvillar@gmail.com  ////
17
////      - Grupo ID2 http://www.dte.us.es/id2/                   ////
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2009 José Ignacio Villar - jvillar@gmail.com   ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 3 of the License, or (at your option) any     ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.gnu.org/licenses/lgpl.txt                    ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46
`include "lcd_defines.v"
47
 
48
module system(
49
        input clk,
50
        input reset,
51
 
52
        input  [2:0] rot,
53
 
54
        output [3:0] SF_D,
55
        output LCD_E,
56
        output LCD_RS,
57
        output LCD_RW,
58
        output SF_CE0,
59
 
60
        output reg [7:0] led
61
        );
62
 
63
//----------------------------------------------------------------------------
64
// rotary decoder
65
//----------------------------------------------------------------------------
66
wire rot_btn;
67
wire rot_event;
68
wire rot_left;
69
 
70
rotary rotdec0 (
71
        .clk(       clk        ),
72
        .reset(     reset      ),
73
        .rot(       rot        ),
74
        // output
75
        .rot_btn(   rot_btn    ),
76
        .rot_event( rot_event  ),
77
        .rot_left(  rot_left   )
78
);
79
 
80
//----------------------------------------------------------------------------
81
// LCD Display
82
//----------------------------------------------------------------------------
83
 
84
 
85
wire busy;
86
reg repaint = 0;
87
reg [`DAT_RNG]  dat = 8'b00100000;
88
reg [`ADDR_RNG] addr = 0;
89
reg we = 0;
90
 
91
lcd lcd(
92
        .clk            ( clk ),
93
        .reset  ( reset),
94
 
95
        .dat            ( dat ),
96
        .addr           ( addr ),
97
        .we             ( we ),
98
        .repaint        ( repaint ),
99
 
100
        .busy           ( busy ),
101
        .SF_D           ( SF_D ),
102
        .LCD_E  ( LCD_E ),
103
        .LCD_RS ( LCD_RS ),
104
        .LCD_RW ( LCD_RW )
105
 
106
        );
107
 
108
//----------------------------------------------------------------------------
109
// Behavioural description
110
//----------------------------------------------------------------------------
111
assign SF_CE0 = 1'b1; // disable intel strataflash
112
 
113
// Handles "start displaying character" shift
114
reg [`DAT_RNG]  start_dat = 8'b00100000;
115
 
116
 
117
// Handles transfers to the display
118
integer i = 0;
119
always @(posedge clk)
120
begin
121
        if(reset) begin
122
                i <= 0;
123
                repaint <= 0;
124
 
125
                we <= 1;
126
                addr <= 0;
127
                dat <= start_dat;
128
 
129
                led <= 8'b00100000;
130
                start_dat <= 8'b00100000;
131
        end if (i < 104) begin
132
                i <= i + 1;
133
                repaint <= 0;
134
 
135
                we <= 1'b1;
136
                addr <= addr + 1;
137
                dat <= dat + 1;
138
        end if (i == 104 && !busy) begin
139
                i <= i + 1;
140
                repaint <= 1;
141
                we <= 1'b0;
142
 
143
        end if (i == 105) begin
144
                i <= i + 1;
145
                repaint <= 0;
146
                we <= 1'b0;
147
        end else if (rot_event && rot_left && !busy) begin
148
                i <= 0;
149
                led <= led - 1;
150
                start_dat <= start_dat - 1;
151
 
152
                addr <= 0;
153
                repaint <= 0;
154
                we <= 1'b1;
155
                dat <= start_dat - 1;
156
        end else if (rot_event && !busy) begin
157
                i <= 0;
158
                led <= led + 1;
159
                start_dat <= start_dat + 1;
160
 
161
                addr <= 0;
162
                repaint <= 0;
163
                we <= 1'b1;
164
                dat <= start_dat + 1;
165
        end
166
end
167
 
168
 
169
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.