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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [openchip/] [charlcd/] [apbcharlcd.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
----------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2004 GAISLER RESEARCH
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  See the file COPYING for the full details of the license.
11
--
12
-----------------------------------------------------------------------------
13
-- Entity:      charlcd
14
-- File:        apbcharlcd.vhd
15
-- Author:      Antti Lukats, OpenChip
16
-- Description: Character LCD
17
--
18
------------------------------------------------------------------------------
19
 
20
library ieee;
21
use ieee.std_logic_1164.all;
22
library grlib;
23
use grlib.amba.all;
24
use grlib.stdlib.all;
25
use grlib.devices.all;
26
 
27
library openchip;
28
use openchip.charlcd.all;
29
 
30
--pragma translate_off
31
use std.textio.all;
32
--pragma translate_on
33
 
34
entity apbcharlcd is
35
  generic (
36
    pindex  : integer := 0;
37
    paddr   : integer := 0;
38
    pmask   : integer := 16#fff#;
39
    pirq    : integer := 0);
40
  port (
41
    rst    : in  std_ulogic;
42
    clk    : in  std_ulogic;
43
    apbi   : in  apb_slv_in_type;
44
    apbo   : out apb_slv_out_type;
45
    lcdi  : in  charlcd_in_type;
46
    lcdo  : out charlcd_out_type);
47
end;
48
 
49
architecture rtl of apbcharlcd is
50
 
51
constant REVISION : integer := 0;
52
 
53
constant pconfig : apb_config_type := (
54
 
55
  1 => apb_iobar(paddr, pmask));
56
 
57
type charlcdregs is record
58
  outreg        :  std_logic_vector(31 downto 0); -- Output Latch Data/Control
59
  inreg         :  std_logic_vector(7 downto 0);  -- Input Latch, not used
60
  irq           :  std_ulogic;  -- interrupt (internal), not used
61
end record;
62
 
63
signal r, rin : charlcdregs;
64
 
65
begin
66
 
67
  comb : process(rst, r, apbi, lcdi )
68
 
69
  variable rdata : std_logic_vector(31 downto 0);
70
  variable irq   : std_logic_vector(NAHBIRQ-1 downto 0);
71
  variable v : charlcdregs;
72
 
73
  begin
74
    v := r;
75
    v.inreg := lcdi.d_in;
76
 
77
    irq := (others => '0');
78
    --irq(pirq) := r.irq;
79
    v.irq := '0';
80
    rdata := (others => '0');
81
 
82
-- read/write registers
83
 
84
    case apbi.paddr(3 downto 2) is
85
    when "00" =>
86
      rdata(31 downto 0) := r.outreg;  -- read Control Reg
87
    when "01" =>
88
      rdata(7 downto 0) := r.inreg; -- read back if bidir?
89
    when others =>
90
    end case;
91
 
92
    if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
93
      case apbi.paddr(3 downto 2) is
94
      when "00" =>
95
        v.outreg := apbi.pwdata(31 downto 0);
96
      when others =>
97
      end case;
98
    end if;
99
 
100
-- reset operation
101
 
102
    if rst = '0' then
103
      v.outreg := (others => '0');
104
    end if;
105
 
106
-- update registers
107
 
108
    rin <= v;
109
 
110
-- drive outputs
111
 
112
    lcdo.d_out <= r.outreg(7 downto 0);
113
    lcdo.en <= r.outreg(11 downto 8);
114
    lcdo.rs <= r.outreg(12);
115
    lcdo.r_wn <= r.outreg(13);
116
    lcdo.backlight_en <= r.outreg(14);
117
    lcdo.d_out_oe <= r.outreg(15);
118
 
119
    apbo.prdata <= rdata;
120
    apbo.pirq <= irq;
121
    apbo.pindex <= pindex;
122
 
123
  end process;
124
 
125
  apbo.pconfig <= pconfig;
126
 
127
  regs : process(clk)
128
  begin
129
    if rising_edge(clk) then
130
      r <= rin;
131
    end if;
132
  end process;
133
 
134
-- pragma translate_off
135
    bootmsg : report_version
136
    generic map ("apbcharlcd" & tost(pindex) &
137
        ": Character LCD rev " & tost(REVISION) & ", irq " & tost(pirq));
138
-- pragma translate_on
139
 
140
end;

powered by: WebSVN 2.1.0

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