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

Subversion Repositories wb_lcd

[/] [wb_lcd/] [trunk/] [verilog/] [wb_lcd_ramless/] [boards/] [s3esk-wb_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
////   - Wishbone 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
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2009 José Ignacio Villar - jvillar@gmail.com   ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 3 of the License, or (at your option) any     ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.gnu.org/licenses/lgpl.txt                    ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
 
45
`include "lcd_defines.v"
46
 
47
module system(
48
        input clk,
49
        input reset,
50
 
51
        input  [2:0] rot,
52
 
53
        output [3:0] SF_D,
54
        output LCD_E,
55
        output LCD_RS,
56
        output LCD_RW,
57
        output SF_CE0,
58
 
59
        output reg [7:0] led
60
        );
61
 
62
//----------------------------------------------------------------------------
63
// rotary decoder
64
//----------------------------------------------------------------------------
65
wire rot_btn;
66
wire rot_event;
67
wire rot_left;
68
 
69
rotary rotdec0 (
70
        .clk(       clk        ),
71
        .reset(     reset      ),
72
        .rot(       rot        ),
73
        // output
74
        .rot_btn(   rot_btn    ),
75
        .rot_event( rot_event  ),
76
        .rot_left(  rot_left   )
77
);
78
 
79
//----------------------------------------------------------------------------
80
// LCD Display
81
//----------------------------------------------------------------------------
82
 
83
reg     [`DAT_RNG]      dat = 8'b00100000;
84
wire    [`WB_DAT_RNG]   wb_dat = {24'b0, dat};
85
reg     [`ADDR_WIDTH:0] addr = 0;
86
wire    [`WB_ADDR_RNG]  wb_addr = {24'b0, addr};
87
wire    [`WB_DAT_RNG]   status;
88
wire                    busy = status[0];
89
wire cs;
90
wire we;
91
wire ack;
92
 
93
wb_lcd lcd  (
94
        //
95
        // I/O Ports
96
        //
97
        .wb_clk_i       ( clk ),
98
        .wb_rst_i       ( reset),
99
 
100
        //
101
        // WB slave interface
102
        //
103
        .wb_dat_i       ( wb_dat ),
104
        .wb_dat_o       ( status ),
105
        .wb_adr_i       ( wb_addr ),
106
        .wb_sel_i       (  ),
107
        .wb_we_i        ( we ),
108
        .wb_cyc_i       ( cs  ),
109
        .wb_stb_i       ( cs ),
110
        .wb_ack_o       ( ack ),
111
 
112
        //
113
        // LCD interface
114
        //
115
        .SF_D   ( SF_D ),
116
        .LCD_E  ( LCD_E ),
117
        .LCD_RS ( LCD_RS ),
118
        .LCD_RW ( LCD_RW )
119
        );
120
 
121
//----------------------------------------------------------------------------
122
// Behavioural description
123
//----------------------------------------------------------------------------
124
assign SF_CE0 = 1'b1; // disable intel strataflash
125
 
126
// Handles "start displaying character" shift
127
reg [`DAT_RNG]  start_dat = 8'b00100000;
128
 
129
integer i = 0;
130
assign we = (i < 104) & ~busy;
131
assign cs = (i < 104);
132
 
133
// Handles transfers to the display
134
always @(posedge clk)
135
begin
136
        if(reset) begin
137
                led <= 8'b00100000;
138
                start_dat <= 8'b00100000;
139
 
140
                i <= 0;
141
                addr <= 0;
142
                dat <= start_dat;
143
        end else begin
144
                if (i < 105 && !busy) begin
145
                        i <= i + 1;
146
                        addr <= addr + 1;
147
                        dat <= dat + 1;
148
                end else if (rot_event && rot_left && !busy) begin
149
                        led <= led - 1;
150
                        start_dat <= start_dat - 1;
151
 
152
                        i <= 0;
153
                        addr <= 0;
154
                        dat <= start_dat - 1;
155
                end else if (rot_event && !busy) begin
156
                        led <= led + 1;
157
                        start_dat <= start_dat + 1;
158
 
159
                        i <= 0;
160
                        addr <= 0;
161
                        dat <= start_dat + 1;
162
                end
163
        end
164
end
165
 
166
endmodule

powered by: WebSVN 2.1.0

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