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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [w11a/] [pdp11_bram_memctl.vhd] - Blame information for rev 36

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

Line No. Rev Author Line
1 29 wfjm
-- $Id: pdp11_bram_memctl.vhd 644 2015-02-08 22:56:54Z mueller $
2
--
3
-- Copyright 2015- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    pdp11_bram_memctl - syn
16
-- Description:    pdp11: BRAM based memctl
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: 7-Series
21
-- Tool versions:  ise 14.7; viv 2014.4; ghdl 0.31
22
--
23
-- Revision History: 
24
-- Date         Rev Version  Comment
25
-- 2015-02-08   644   1.0    Initial version 
26
------------------------------------------------------------------------------
27
 
28
library ieee;
29
use ieee.std_logic_1164.all;
30
use ieee.numeric_std.all;
31
 
32
library unisim;
33
use unisim.vcomponents.all;
34
library unimacro;
35
use unimacro.vcomponents.all;
36
 
37
use work.slvtypes.all;
38
use work.pdp11.all;
39
 
40
-- ----------------------------------------------------------------------------
41
 
42
entity pdp11_bram_memctl is             -- BRAM based memctl
43
  generic (
44
    MAWIDTH : positive := 4;            -- mux address width
45
    NBLOCK : positive := 11);           -- write delay in clock cycles
46
  port (
47
    CLK : in slbit;                     -- clock
48
    RESET : in slbit;                   -- reset
49
    REQ   : in slbit;                   -- request
50
    WE    : in slbit;                   -- write enable
51
    BUSY : out slbit;                   -- controller busy
52
    ACK_R : out slbit;                  -- acknowledge read
53
    ACK_W : out slbit;                  -- acknowledge write
54
    ACT_R : out slbit;                  -- signal active read
55
    ACT_W : out slbit;                  -- signal active write
56
    ADDR : in slv20;                    -- address
57
    BE : in slv4;                       -- byte enable
58
    DI : in slv32;                      -- data in  (memory view)
59
    DO : out slv32                      -- data out (memory view)
60
  );
61
end pdp11_bram_memctl;
62
 
63
architecture syn of pdp11_bram_memctl is
64
 
65
  type state_type is (
66
    s_idle,                             -- s_idle: wait for req
67
    s_read0,                            -- s_read0
68
    s_read1,                            -- s_read1
69
    s_write                             -- s_write
70
  );
71
 
72
  type regs_type is record
73
    state : state_type;                 -- state
74
    muxaddr : slv(MAWIDTH-1 downto 0);  -- mux  addr buffer
75
    celladdr : slv12;                   -- cell addr buffer
76
    cellen : slv(2**MAWIDTH-1 downto 0);-- cell enables
77
    cellwe : slv4;                      -- write enables
78
    dibuf : slv32;                      -- data in buffer
79
    dobuf : slv32;                      -- data out buffer
80
    ackr : slbit;                       -- signal ack_r
81
  end record regs_type;
82
 
83
  constant muxaddrzero : slv(MAWIDTH-1 downto 0) := (others=>'0');
84
  constant cellenzero : slv(2**MAWIDTH-1 downto 0) := (others=>'0');
85
  constant regs_init : regs_type := (
86
    s_idle,                             -- state
87
    muxaddrzero,                        -- muxaddr
88
    (others=>'0'),                      -- celladdr
89
    cellenzero,                         -- cellen
90
    (others=>'0'),                      -- cellwe
91
    (others=>'0'),                      -- dibuf
92
    (others=>'0'),                      -- dobuf
93
    '0'                                 -- ackr
94
  );
95
 
96
  signal R_REGS : regs_type := regs_init;  -- state registers
97
  signal N_REGS : regs_type := regs_init;  -- next value state regs
98
 
99
  type mem_do_type is array (NBLOCK-1 downto 0) of slv32;
100
  signal MEM_DO : mem_do_type := (others=> (others => '0'));
101
 
102
begin
103
 
104
  assert MAWIDTH <= 8
105
    report "assert(MAWIDTH <= 8)" severity failure;
106
  assert NBLOCK <= 2**MAWIDTH
107
    report "assert(NBLOCK <= 2**MAWIDTH)" severity failure;
108
 
109
  -- generate memory array
110
  --   4 colums, one for each byte of the 32 bit word
111
  --   NBLOCK rows, as many as one can afford ...
112
 
113
  MARRAY: for row in NBLOCK-1 downto 0 generate
114
    MROW: for col in 3 downto 0 generate
115
      signal WE : slv(0 downto 0) := "0";
116
    begin
117
      WE(0) <= R_REGS.cellwe(col);
118
      MCELL : BRAM_SINGLE_MACRO
119
        generic map (
120
          BRAM_SIZE   => "36Kb",
121
          DEVICE      => "7SERIES",
122
          WRITE_WIDTH => 8,
123
          READ_WIDTH  => 8,
124
          WRITE_MODE  => "WRITE_FIRST")
125
        port map (
126
          CLK   => CLK,
127
          RST   => '0',
128
          REGCE => '1',
129
          ADDR  => R_REGS.celladdr,
130
          EN    => R_REGS.cellen(row),
131
          WE    => WE,
132
          DI    => R_REGS.dibuf(8*col+7 downto 8*col),
133
          DO    => MEM_DO(row)(8*col+7 downto 8*col)
134
        );
135
    end generate MROW;
136
  end generate MARRAY;
137
 
138
  proc_regs: process (CLK)
139
  begin
140
 
141
    if rising_edge(CLK) then
142
      if RESET = '1' then
143
        R_REGS <= regs_init;
144
      else
145
        R_REGS <= N_REGS;
146
      end if;
147
    end if;
148
 
149
  end process proc_regs;
150
 
151
  proc_next: process (R_REGS, ADDR, DI, REQ, WE, BE, MEM_DO)
152
 
153
    variable r : regs_type := regs_init;
154
    variable n : regs_type := regs_init;
155
    variable ibusy : slbit := '0';
156
    variable iackw : slbit := '0';
157
    variable iactr : slbit := '0';
158
    variable iactw : slbit := '0';
159
  begin
160
 
161
    r := R_REGS;
162
    n := R_REGS;
163
    n.ackr := '0';
164
 
165
    ibusy := '0';
166
    iackw := '0';
167
    iactr := '0';
168
    iactw := '0';
169
 
170
    case r.state is
171
      when s_idle =>                    -- s_idle: wait for req
172
        n.cellen   := (others=>'0');
173
        n.cellwe   := (others=>'0');
174
        if REQ = '1' then
175
          n.muxaddr  := ADDR(MAWIDTH-1+12 downto 12);
176
          n.celladdr := ADDR(11 downto 0);
177
          n.dibuf    := DI;
178
          n.cellen(to_integer(unsigned(ADDR(MAWIDTH-1+12 downto 12)))) := '1';
179
          if WE = '1' then
180
            n.cellwe := BE;
181
            n.state := s_write;
182
          else
183
            n.state := s_read0;
184
          end if;
185
        end if;
186
 
187
      when s_read0 =>                   -- s_read0
188
        ibusy   := '1';
189
        iactr   := '1';
190
        n.state := s_read1;
191
 
192
      when s_read1 =>                   -- s_read1
193
        ibusy   := '1';
194
        iactr   := '1';
195
        n.dobuf := MEM_DO(to_integer(unsigned(r.muxaddr)));
196
        n.ackr  := '1';
197
        n.state := s_idle;
198
 
199
      when s_write =>                   -- s_write
200
        ibusy   := '1';
201
        iactw   := '1';
202
        iackw   := '1';
203
        n.cellwe   := (others=>'0');
204
        n.state := s_idle;
205
 
206
      when others => null;
207
    end case;
208
 
209
    N_REGS <= n;
210
 
211
    BUSY  <= ibusy;
212
    ACK_R <= r.ackr;
213
    ACK_W <= iackw;
214
    ACT_R <= iactr;
215
    ACT_W <= iactw;
216
    DO    <= r.dobuf;
217
  end process proc_next;
218
 
219
end syn;

powered by: WebSVN 2.1.0

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