OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_peripheral/] [display/] [lcd_2x16/] [lcd_2x16.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
 
2
/**********************************************************************
3
**      File:  lcd_2x16.v
4
**
5
**
6
**      Copyright (C) 2014-2017  Alireza Monemi
7
**
8
**      This file is part of ProNoC
9
**
10
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
11
**      you can redistribute it and/or modify it under the terms of the GNU
12
**      Lesser General Public License as published by the Free Software Foundation,
13
**      either version 2 of the License, or (at your option) any later version.
14
**
15
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
16
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
18
**      Public License for more details.
19
**
20
**      You should have received a copy of the GNU Lesser General Public
21
**      License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
22
**
23
**
24
**      Description:
25
**      Alphabet lcd wishbone bus interface
26
**
27
*******************************************************************/
28
 
29
 
30
 
31
// synthesis translate_off
32
`timescale 1ns / 1ps
33
// synthesis translate_on
34
 
35
 
36
module lcd_2x16 #(
37
        parameter CLK_MHZ= 50,
38
        parameter Dw  = 8,   // wishbone bus data width
39
        parameter Aw  = 2
40
 
41
)(
42
        clk,
43
        reset,
44
 
45
        //wishbone bus interface
46
        s_dat_i,
47
        s_addr_i,
48
        s_stb_i,
49
        s_cyc_i,
50
        s_we_i,
51
        s_dat_o,
52
        s_ack_o,
53
 
54
        //lcd interface
55
        lcd_en,
56
        lcd_rs,
57
        lcd_rw,
58
        lcd_data
59
);
60
 
61
 
62
         function integer log2;
63
      input integer number; begin
64
         log2=0;
65
         while(2**log2<number) begin
66
            log2=log2+1;
67
         end
68
      end
69
   endfunction // log2 
70
 
71
 
72
 
73
   localparam Cw=log2(CLK_MHZ);
74
 
75
 
76
 
77
        input                       clk;
78
        input                       reset;
79
 
80
        //wishbone bus interface
81
        input       [Dw-1       :   0]      s_dat_i;
82
        input       [Aw-1       :   0]      s_addr_i;
83
        input                               s_stb_i;
84
        input                               s_cyc_i;
85
        input                               s_we_i;
86
 
87
        output      [Dw-1       :   0]      s_dat_o;
88
        output  reg                         s_ack_o;
89
 
90
 
91
 
92
 
93
        output           lcd_en;
94
        output           lcd_rs;
95
        output           lcd_rw;
96
        inout   [  7: 0] lcd_data;
97
 
98
 
99
   reg [Cw-1:0]cnt;
100
 
101
 
102
        assign lcd_rw = s_addr_i[0];
103
        assign lcd_rs = s_addr_i[1];
104
 
105
 
106
 
107
        assign lcd_en = (cnt>0);
108
        assign lcd_data = (s_addr_i[0]) ? 8'bz : s_dat_i;
109
        assign s_dat_o  = lcd_data;
110
 
111
`ifdef SYNC_RESET_MODE
112
    always @ (posedge clk )begin
113
`else
114
    always @ (posedge clk or posedge reset)begin
115
`endif
116
                if(reset) begin
117
                        s_ack_o <=      1'b0;
118
                        cnt=6'd0;
119
                end else begin
120
                        s_ack_o <=      s_stb_i & (cnt==2);
121
                        if(s_stb_i && cnt==0) cnt={Cw{1'b1}}; // minimum 1 ms delay for holfing lcd en signal
122
                        else if(lcd_en)cnt=cnt-1'b1;
123
                end
124
        end
125
 
126
 
127
endmodule
128
 

powered by: WebSVN 2.1.0

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