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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [peripherals/] [mem/] [wprot.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
 
2
 
3
 
4
 
5
----------------------------------------------------------------------------
6
--  This file is a part of the LEON VHDL model
7
--  Copyright (C) 1999  European Space Agency (ESA)
8
--
9
--  This library is free software; you can redistribute it and/or
10
--  modify it under the terms of the GNU Lesser General Public
11
--  License as published by the Free Software Foundation; either
12
--  version 2 of the License, or (at your option) any later version.
13
--
14
--  See the file COPYING.LGPL for the full details of the license.
15
 
16
 
17
-----------------------------------------------------------------------------
18
-- Entity:      wprot
19
-- File:        wprot.vhd
20
-- Author:      Jiri Gaisler - ESA/ESTEC
21
-- Description: RAM write protection
22
------------------------------------------------------------------------------
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
use work.leon_config.all;
27
use work.peri_mem_comp.all;
28
use work.amba.all;
29
 
30
entity wprot is
31
  port (
32
    rst    : in  std_logic;
33
    clk    : in  std_logic;
34
    wpo    : out wprot_out_type;
35
    ahbsi  : in  ahb_slv_in_type;
36
    apbi   : in  apb_slv_in_type;
37
    apbo   : out apb_slv_out_type
38
  );
39
end;
40
 
41
architecture rtl of wprot is
42
 
43
type wprottype is record
44
  addr    : std_logic_vector(14 downto 0);
45
  mask    : std_logic_vector(14 downto 0);
46
  enable  : std_logic;
47
  ablock  : std_logic;
48
end record;
49
 
50
type wprotregs is record
51
  wprot1, wprot2   : wprottype;
52
  haddr            : std_logic_vector(31 downto 15);
53
  hwrite           : std_logic;
54
end record;
55
 
56
signal r, rin : wprotregs;
57
 
58
begin
59
 
60
  ctrl : process(rst, ahbsi, apbi, r)
61
  variable wprothit, wprothit1, wprothit2 : std_logic;
62
  variable wprothitx : std_logic;
63
  variable aprot   : std_logic_vector(14 downto 0); -- 
64
  variable v : wprotregs;
65
  variable regsd : std_logic_vector(31 downto 0);   -- data from registers
66
 
67
  begin
68
 
69
    v := r; regsd := (others => '0');
70
 
71
    if (ahbsi.hready = '1') then
72
      v.hwrite := ahbsi.hwrite; v.haddr  := ahbsi.haddr(31 downto 15);
73
    end if;
74
 
75
    wprothit := '0'; wprothit1 := '0'; wprothit2 := '0';
76
    if WPROTEN then
77
      aprot := (r.haddr(29 downto 15) xor r.wprot1.addr) and r.wprot1.mask;
78
      if (aprot = "000000000000000") then wprothit1 := '1'; end if;
79
      aprot := (r.haddr(29 downto 15) xor r.wprot2.addr) and r.wprot2.mask;
80
      if (aprot = "000000000000000") then wprothit2 := '1'; end if;
81
      if (r.hwrite = '1') and (r.haddr(31 downto 30) = "01") then
82
        wprothit :=
83
          ((r.wprot1.enable and (not wprothit1) and (not r.wprot1.ablock)) or
84
          (r.wprot2.enable and (not wprothit2) and (not r.wprot2.ablock))) or
85
          (((r.wprot1.enable and wprothit1 and r.wprot1.ablock) or
86
          (r.wprot2.enable and wprothit2 and r.wprot2.ablock)) and not
87
          ((r.wprot1.enable and wprothit1 and (not r.wprot1.ablock)) or
88
          (r.wprot2.enable and wprothit2 and (not r.wprot2.ablock))));
89
      end if;
90
    end if;
91
 
92
 
93
    case apbi.paddr(2 downto 2) is
94
    when "1" =>
95
        if WPROTEN then
96
          regsd := r.wprot1.enable & r.wprot1.ablock &
97
                   r.wprot1.addr & r.wprot1.mask;
98
        end if;
99
    when "0" =>
100
        if WPROTEN then
101
          regsd := r.wprot2.enable & r.wprot2.ablock &
102
                   r.wprot2.addr & r.wprot2.mask;
103
        end if;
104
    when others => null;
105
    end case;
106
 
107
    apbo.prdata <= regsd;
108
 
109
    if (apbi.psel and apbi.penable and apbi.pwrite) = '1' then
110
      case apbi.paddr(2 downto 2) is
111
      when "1" =>
112
        v.wprot1.enable := apbi.pwdata(31);
113
        v.wprot1.ablock := apbi.pwdata(30);
114
        v.wprot1.addr   := apbi.pwdata(29 downto 15);
115
        v.wprot1.mask   := apbi.pwdata(14 downto 0);
116
      when "0" =>
117
        v.wprot2.enable := apbi.pwdata(31);
118
        v.wprot2.ablock := apbi.pwdata(30);
119
        v.wprot2.addr   := apbi.pwdata(29 downto 15);
120
        v.wprot2.mask   := apbi.pwdata(14 downto 0);
121
      when others => null;
122
      end case;
123
    end if;
124
 
125
    if rst = '0' then
126
      v.wprot1.enable        := '0';
127
      v.wprot2.enable        := '0';
128
    end if;
129
 
130
    rin <= v;
131
    wpo.wprothit <= wprothit;
132
 
133
  end process;
134
 
135
 
136
  wpreggen : if WPROTEN generate
137
    wpregs : process(clk)
138
    begin if rising_edge(clk) then r <= rin; end if; end process;
139
  end generate;
140
 
141
end;
142
 
143
 

powered by: WebSVN 2.1.0

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