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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_1_beta/] [rtl/] [vhdl/] [pmem_ctrl.vhd] - Blame information for rev 304

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Program Memory control unit.
4
-- All operations related to the Program Memory are managed here.
5
--
6 77 arniml
-- $Id: pmem_ctrl.vhd,v 1.2 2004-04-24 23:44:25 arniml Exp $
7 4 arniml
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41
--      http://www.opencores.org/cvsweb.shtml/t48/
42
--
43
-------------------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
 
48
use work.t48_pack.pmem_addr_t;
49
use work.t48_pack.word_t;
50
use work.pmem_ctrl_pack.pmem_addr_ident_t;
51
 
52
entity pmem_ctrl is
53
 
54
  port (
55
    -- Global Interface -------------------------------------------------------
56
    clk_i             : in  std_logic;
57
    res_i             : in  std_logic;
58
    en_clk_i          : in  boolean;
59
    -- T48 Bus Interface ------------------------------------------------------
60
    data_i            : in  word_t;
61
    data_o            : out word_t;
62
    write_pcl_i       : in  boolean;
63
    read_pcl_i        : in  boolean;
64
    write_pch_i       : in  boolean;
65
    read_pch_i        : in  boolean;
66
    inc_pc_i          : in  boolean;
67
    write_pmem_addr_i : in  boolean;
68
    addr_type_i       : in  pmem_addr_ident_t;
69
    read_pmem_i       : in  boolean;
70
    -- Porgram Memroy Interface -----------------------------------------------
71
    pmem_addr_o       : out pmem_addr_t;
72
    pmem_data_i       : in  word_t
73
  );
74
 
75
end pmem_ctrl;
76
 
77
 
78
library ieee;
79 77 arniml
use ieee.numeric_std.all;
80 4 arniml
 
81
use work.pmem_ctrl_pack.all;
82
use work.t48_pack.res_active_c;
83
use work.t48_pack.clk_active_c;
84
use work.t48_pack.bus_idle_level_c;
85
use work.t48_pack.pmem_addr_width_c;
86
use work.t48_pack.dmem_addr_width_c;
87
use work.t48_pack.page_t;
88
 
89
architecture rtl of pmem_ctrl is
90
 
91
  -- the Program Counter
92
  signal program_counter_q : unsigned(pmem_addr_t'range);
93
 
94
  -- the Program Memory address
95
  signal pmem_addr_s,
96
         pmem_addr_q       : std_logic_vector(pmem_addr_t'range);
97
 
98
begin
99
 
100
  -----------------------------------------------------------------------------
101
  -- Process program_counter
102
  --
103
  -- Purpose:
104
  --   Implements the Program Counter.
105
  --
106
  program_counter: process (res_i, clk_i)
107
  begin
108
    if res_i = res_active_c then
109
      program_counter_q <= (others => '0');
110
      pmem_addr_q       <= (others => '0');
111
 
112
    elsif clk_i'event and clk_i = clk_active_c then
113
      if en_clk_i then
114
 
115
        -- parallel load mode
116
        if write_pcl_i then
117
          program_counter_q(data_i'range) <= UNSIGNED(data_i);
118
        elsif write_pch_i then
119
          program_counter_q(pmem_addr_width_c-1 downto data_i'high+1) <=
120
            UNSIGNED(data_i(pmem_addr_width_c - dmem_addr_width_c - 1 downto 0));
121
        elsif inc_pc_i then
122
          -- increment mode
123
          program_counter_q <= program_counter_q + 1;
124
        end if;
125
 
126
        -- set pmem address
127
        if write_pmem_addr_i then
128
          pmem_addr_q <= pmem_addr_s;
129
        end if;
130
 
131
      end if;
132
 
133
    end if;
134
 
135
  end process program_counter;
136
  --
137
  -----------------------------------------------------------------------------
138
 
139
 
140
  -----------------------------------------------------------------------------
141
  -- Process pmem_addr
142
  --
143
  -- Purpose:
144
  --   Multiplex the Program Memory address.
145
  --
146
  pmem_addr: process (program_counter_q,
147
                      addr_type_i,
148
                      pmem_addr_q,
149
                      data_i)
150
  begin
151
    -- default assignment
152 77 arniml
    pmem_addr_s <= STD_LOGIC_VECTOR(program_counter_q);
153 4 arniml
 
154
    case addr_type_i is
155
      when PM_PC =>
156
        -- default is ok
157
        null;
158
 
159
      when PM_PAGE =>
160
        pmem_addr_s(word_t'range) <= data_i;
161
        -- take page address from program counter
162
        --   => important for JMPP, MOVP!
163
        --      they must wrap to next page when at FF!
164
 
165
      when PM_PAGE3 =>
166
        pmem_addr_s(word_t'range) <= data_i;
167
        -- page address is explicitely specified
168
        pmem_addr_s(page_t'range) <= "0011";
169
 
170
      when others =>
171
        null;
172
 
173
    end case;
174
 
175
  end process pmem_addr;
176
  --
177
  -----------------------------------------------------------------------------
178
 
179
 
180
  -----------------------------------------------------------------------------
181
  -- Process data_output
182
  --
183
  -- Purpose:
184
  --   Multiplex the data bus output.
185
  --
186
  data_output: process (read_pmem_i,
187
                        read_pcl_i,
188
                        read_pch_i,
189
                        pmem_data_i,
190
                        program_counter_q)
191
  begin
192
    data_o <= (others => bus_idle_level_c);
193
 
194
    if read_pmem_i then
195
      data_o <= pmem_data_i;
196
    elsif read_pcl_i then
197 77 arniml
      data_o <= STD_LOGIC_VECTOR(program_counter_q(data_o'range));
198 4 arniml
    elsif read_pch_i then
199 77 arniml
      data_o(3 downto 0) <= STD_LOGIC_VECTOR(program_counter_q(pmem_addr_width_c-1 downto data_o'high+1));
200 4 arniml
    end if;
201
 
202
  end process data_output;
203
  --
204
  -----------------------------------------------------------------------------
205
 
206
 
207
  -----------------------------------------------------------------------------
208
  -- Output Mapping.
209
  -----------------------------------------------------------------------------
210
  pmem_addr_o <= pmem_addr_q;
211
 
212
end rtl;
213
 
214
 
215
-------------------------------------------------------------------------------
216
-- File History:
217
--
218
-- $Log: not supported by cvs2svn $
219 77 arniml
-- Revision 1.1  2004/03/23 21:31:53  arniml
220
-- initial check-in
221 4 arniml
--
222 77 arniml
--
223 4 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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