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/] [sui/] [apbsui.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:      sui
14
-- File:        apbsui.vhd
15
-- Author:      Antti Lukats, OpenChip
16
-- Description: Simple User Interface
17
--
18
-- Single Peripheral containting the following:
19
-- Input:
20
--  Switches 0..31
21
--  Buttons 0..31
22
-- Output
23
--  LED 7 Segment, 4 digits non multiplexed, 32 digits in multiplexed mode
24
--  Single LED 0..31
25
--  Buzzer
26
--  Character LCD
27
--
28
-- Version 0: All functions are software assisted, IP Core has minimal
29
--  intelligence providing bit-bang access to all the connected hardware
30
--
31
--
32
--
33
--
34
--
35
--
36
--
37
--
38
------------------------------------------------------------------------------
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
library grlib;
43
use grlib.amba.all;
44
use grlib.stdlib.all;
45
use grlib.devices.all;
46
 
47
library openchip;
48
use openchip.sui.all;
49
 
50
--pragma translate_off
51
use std.textio.all;
52
--pragma translate_on
53
 
54
entity apbsui is
55
  generic (
56
    pindex  : integer := 0;
57
    paddr   : integer := 0;
58
    pmask   : integer := 16#fff#;
59
    pirq    : integer := 0;
60
 
61
 
62
-- active level for Segment LED segments
63
    led7act : integer := 1;
64
-- active level for single LED's
65
    ledact  : integer := 1);
66
 
67
  port (
68
    rst    : in  std_ulogic;
69
    clk    : in  std_ulogic;
70
    apbi   : in  apb_slv_in_type;
71
    apbo   : out apb_slv_out_type;
72
    suii   : in  sui_in_type;
73
    suio   : out sui_out_type);
74
end;
75
 
76
architecture rtl of apbsui is
77
 
78
constant REVISION : integer := 0;
79
 
80
constant pconfig : apb_config_type := (
81
 
82
  1 => apb_iobar(paddr, pmask));
83
 
84
type suiregs is record
85
  ledreg        :  std_logic_vector(31 downto 0); -- Output Latch, single LEDs
86
  led7reg       :  std_logic_vector(31 downto 0); -- Output Latch, 7 Seg LEDs
87
  lcdreg        :  std_logic_vector(15 downto 0); -- Output Latch LCD
88
  buzreg        :  std_logic_vector(0 downto 0);  -- Buzzer
89
 
90
  sw_inreg      :  std_logic_vector(31 downto 0); -- Switches in
91
  btn_inreg     :  std_logic_vector(31 downto 0); -- Buttons in
92
 
93
 
94
  irq           :  std_ulogic;  -- interrupt (internal), not used
95
end record;
96
 
97
signal r, rin : suiregs;
98
 
99
begin
100
 
101
  comb : process(rst, r, apbi, suii )
102
 
103
  variable rdata : std_logic_vector(31 downto 0);
104
  variable irq   : std_logic_vector(NAHBIRQ-1 downto 0);
105
  variable v : suiregs;
106
 
107
 
108
 
109
  begin
110
    v := r;
111
    v.sw_inreg := suii.switch_in;
112
    v.btn_inreg := suii.button_in;
113
 
114
    irq := (others => '0');
115
    --irq(pirq) := r.irq;
116
    v.irq := '0';
117
    rdata := (others => '0');
118
 
119
-- read/write registers
120
 
121
    case apbi.paddr(4 downto 2) is
122
    when "100" =>
123
      rdata(31 downto 0) := r.sw_inreg;  -- read switches
124
    when "101" =>
125
      rdata(31 downto 0) := r.btn_inreg; -- read buttons
126
    when others =>
127
    end case;
128
 
129
    if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
130
      case apbi.paddr(4 downto 2) is
131
      when "000" =>
132
        v.ledreg := apbi.pwdata(31 downto 0);
133
      when "001" =>
134
        v.led7reg := apbi.pwdata(31 downto 0);
135
      when "010" =>
136
        v.lcdreg(15 downto 0) := apbi.pwdata(15 downto 0);
137
      when "011" =>
138
        v.buzreg(0) := apbi.pwdata(0);
139
 
140
      when others =>
141
      end case;
142
    end if;
143
 
144
-- reset operation
145
 
146
    if rst = '0' then
147
      v.ledreg := (others => '0');
148
      v.led7reg := (others => '0');
149
    end if;
150
 
151
-- update registers
152
 
153
    rin <= v;
154
 
155
-- drive outputs
156
 
157
    suio.lcd_out       <= r.lcdreg(7 downto 0);
158
    suio.lcd_en        <= r.lcdreg(11 downto 8);
159
    suio.lcd_rs        <= r.lcdreg(12);
160
    suio.lcd_r_wn      <= r.lcdreg(13);
161
    suio.lcd_backlight <= r.lcdreg(14);
162
    suio.lcd_oe        <= r.lcdreg(15);
163
 
164
    suio.buzzer        <= r.buzreg(0);
165
    suio.led_out <= r.ledreg;
166
 
167
 
168
 
169
    suio.led_a_out(0)  <= r.led7reg(0);
170
    suio.led_b_out(0)  <= r.led7reg(1);
171
    suio.led_c_out(0)  <= r.led7reg(2);
172
    suio.led_d_out(0)  <= r.led7reg(3);
173
    suio.led_e_out(0)  <= r.led7reg(4);
174
    suio.led_f_out(0)  <= r.led7reg(5);
175
    suio.led_g_out(0)  <= r.led7reg(6);
176
    suio.led_dp_out(0) <= r.led7reg(7);
177
 
178
    suio.led_a_out(1)  <= r.led7reg(8);
179
    suio.led_b_out(1)  <= r.led7reg(9);
180
    suio.led_c_out(1)  <= r.led7reg(10);
181
    suio.led_d_out(1)  <= r.led7reg(11);
182
    suio.led_e_out(1)  <= r.led7reg(12);
183
    suio.led_f_out(1)  <= r.led7reg(13);
184
    suio.led_g_out(1)  <= r.led7reg(14);
185
    suio.led_dp_out(1) <= r.led7reg(15);
186
 
187
    suio.led_a_out(2)  <= r.led7reg(16);
188
    suio.led_b_out(2)  <= r.led7reg(17);
189
    suio.led_c_out(2)  <= r.led7reg(18);
190
    suio.led_d_out(2)  <= r.led7reg(19);
191
    suio.led_e_out(2)  <= r.led7reg(20);
192
    suio.led_f_out(2)  <= r.led7reg(21);
193
    suio.led_g_out(2)  <= r.led7reg(22);
194
    suio.led_dp_out(2) <= r.led7reg(23);
195
 
196
    suio.led_a_out(3)  <= r.led7reg(24);
197
    suio.led_b_out(3)  <= r.led7reg(25);
198
    suio.led_c_out(3)  <= r.led7reg(26);
199
    suio.led_d_out(3)  <= r.led7reg(27);
200
    suio.led_e_out(3)  <= r.led7reg(28);
201
    suio.led_f_out(3)  <= r.led7reg(29);
202
    suio.led_g_out(3)  <= r.led7reg(30);
203
    suio.led_dp_out(3) <= r.led7reg(31);
204
 
205
 
206
 
207
 
208
 
209
 
210
    apbo.prdata <= rdata;
211
    apbo.pirq <= irq;
212
    apbo.pindex <= pindex;
213
 
214
  end process;
215
 
216
  apbo.pconfig <= pconfig;
217
 
218
  regs : process(clk)
219
  begin
220
    if rising_edge(clk) then
221
      r <= rin;
222
    end if;
223
  end process;
224
 
225
-- pragma translate_off
226
    bootmsg : report_version
227
    generic map ("apbsui" & tost(pindex) &
228
        ": SUI rev " & tost(REVISION) & ", irq " & tost(pirq));
229
-- pragma translate_on
230
 
231
end;

powered by: WebSVN 2.1.0

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