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/] [gleichmann/] [spi/] [spi_oc_ea.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
--------------------------------------------------------------------
2
--  Entity:         SPI_OC
3
--  File:           spi_oc.vhd
4
--  Author:         Thomas Ameseder, Gleichmann Electronics
5
--
6
--  Description:    VHDL wrapper for the Opencores SPI core with APB
7
--                  interface
8
--------------------------------------------------------------------
9
--  CVS Entries:
10
--  $Date: 2006/12/04 14:44:05 $
11
--  $Author: tame $
12
--  $Log: spi_oc.vhd,v $
13
--  Revision 1.3  2006/12/04 14:44:05  tame
14
--  Changed interrupt output to LEON from a level (that is active until it is reset) to
15
--  a short pulse.
16
--
17
--  Revision 1.1  2006/11/17 12:28:56  tame
18
--  Added SPI files: Simple SPI package and a wrapper for the (modified)
19
--  OpenCores Simple SPI Core with APB interface.
20
--
21
--------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
 
26
library grlib;
27
use grlib.amba.all;
28
use grlib.stdlib.all;
29
use grlib.devices.all;
30
 
31
library opencores;
32
use opencores.occomp.all;
33
 
34
library gleichmann;
35
use gleichmann.sspi.all;
36
 
37
--  pragma translate_off
38
use std.textio.all;
39
--  pragma translate_on
40
 
41
 
42
entity spi_oc is
43
  generic (
44
    pindex : integer := 0;              -- Leon-Index
45
    paddr  : integer := 0;              -- Leon-Address
46
    pmask  : integer := 16#FFF#;        -- Leon-Mask
47
    pirq   : integer := 0               -- Leon-IRQ
48
    );
49
  port (
50
    rstn    : in  std_ulogic;           -- global Reset, active low
51
    clk     : in  std_ulogic;           -- global Clock
52
    apbi    : in  apb_slv_in_type;      -- APB-Input
53
    apbo    : out apb_slv_out_type;     -- APB-Output
54
    spi_in  : in  sspi_in_type;          -- MultIO-Inputs
55
    spi_out : out sspi_out_type          -- Spi-Outputs
56
    );
57
end entity spi_oc;
58
 
59
 
60
architecture implementation of spi_oc is
61
 
62
  constant data_width    : integer := 8;
63
  constant address_width : integer := 3;
64
  constant REVISION      : integer := 0;
65
 
66
  constant pconfig : apb_config_type := (
67
 
68
    1 => apb_iobar(paddr, pmask)
69
    );
70
 
71
  signal irq       : std_ulogic;
72
  signal irq_1t    : std_ulogic;
73
  signal irq_adapt : std_ulogic;        -- registered and converted to rising edge activity
74
 
75
begin
76
 
77
  simple_spi_top_1 : simple_spi_top
78
    port map (
79
      prdata_o  => apbo.prdata(data_width-1 downto 0),
80
      pirq_o    => irq,
81
      sck_o     => spi_out.sck,
82
      mosi_o    => spi_out.mosi,
83
      ssn_o     => spi_out.ssn,
84
      pclk_i    => clk,
85
      prst_i    => rstn,
86
      psel_i    => apbi.psel(pindex),
87
      penable_i => apbi.penable,
88
      paddr_i   => apbi.paddr(address_width+1 downto 2),  -- 32-bit addresses
89
      pwrite_i  => apbi.pwrite,
90
      pwdata_i  => apbi.pwdata(data_width-1 downto 0),
91
      miso_i    => spi_in.miso);
92
 
93
  -- drive selected interrupt, remaining bits with zeroes
94
  apbo.pirq(NAHBIRQ-1 downto pirq+1) <= (others => '0');
95
  -- apbo.pirq(pirq)                    <= irq;  -- corrected by MH, 28.11.2006
96
  apbo.pirq(pirq)                    <= irq_adapt;
97
  apbo.pirq(pirq-1 downto 0)         <= (others => '0');
98
 
99
  -- drive unused data bits with don't cares
100
  apbo.prdata(31 downto data_width) <= (others => '0');
101
  -- drive index for diagnostic use
102
  apbo.pindex                       <= pindex;
103
  -- drive slave configuration
104
  apbo.pconfig                      <= pconfig;
105
 
106
 
107
  ---------------------------------------------------------------------------------------
108
  -- Synchronous process to convert the high level interrupt from the core to
109
  -- to an rising edge triggered interrupt to be suitable for the Leon IRQCTL
110
  --    asynchronous low active reset like the open core simple SPI module !!!
111
  ---------------------------------------------------------------------------------------
112
  irq_adaption: process (clk, rstn)  -- added by MH, 28.11.2006
113
  begin  -- process irq_adaption)
114
    if rstn = '0' then
115
      irq_adapt <= '0';
116
      irq_1t    <= '0';
117
    elsif clk'event and clk = '1' then
118
      irq_1t    <= irq;
119
      irq_adapt <= irq and not irq_1t;
120
    end if;
121
  end process irq_adaption;
122
 
123
 
124
 
125
 
126
  ---------------------------------------------------------------------------------------
127
  -- DEBUG SECTION
128
  ---------------------------------------------------------------------------------------
129
 
130
--  pragma translate_off
131
  assert (pirq < 15 and pirq > 0 ) report
132
    "Simple SPI Controller interrupt warning: " &
133
    "0 does not exist, 15 is unmaskable, 16 to 31 are unused"
134
    severity warning;
135
 
136
  bootmsg : report_version
137
    generic map ("SPI_OC: Simple SPI Controller rev " & tost(REVISION) &
138
                 ", IRQ " & tost(pirq) &
139
                 ", APB slave " & tost(pindex));
140
--  pragma translate_on
141
 
142
end architecture implementation;

powered by: WebSVN 2.1.0

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