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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Hardware/] [XUPV5-LX110T_SoC/] [MIPS32-Pipelined-Hw/] [src/] [BRAM/] [BRAM_592KB_Wrapper.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : BRAM_592KB_Wrapper.v
4
 * Project      : University of Utah, XUM Project MIPS32 core
5
 * Creator(s)   : Grant Ayers (ayers@cs.utah.edu)
6
 *
7
 * Modification History:
8
 *   Rev   Date         Initials  Description of Change
9
 *   1.0   6-Jun-2012   GEA       Initial design.
10
 *
11
 * Standards/Formatting:
12
 *   Verilog 2001, 4 soft tab, wide column.
13
 *
14
 * Description:
15
 *   Provides access to Block Memory through a 4-way handshaking protocol,
16
 *   which allows for multi-cycle and variably-timed operations on the
17
 *   data bus.
18
 */
19
 
20
 
21
module BRAM_592KB_Wrapper(
22
    input  clock,
23
    input  reset,
24
    input         rea,
25
    input  [3:0]  wea,
26
    input  [17:0] addra,
27
    input  [31:0] dina,
28
    output [31:0] douta,
29
    output reg       dreadya,
30
    input         reb,
31
    input  [3:0]  web,
32
    input  [17:0] addrb,
33
    input  [31:0] dinb,
34
    output [31:0] doutb,
35
    output reg       dreadyb
36
    );
37
 
38
    /* Four-Way Memory Handshake Protocol:
39
          1. Read/Write request goes high.
40
          2. Ack goes high when data is available.
41
          3. Read/Write request goes low.
42
          4. Ack signal goes low.
43
                  ____
44
          R/W: __|    |____
45
                     ____
46
          Ack: _____|    |____
47
 
48
    */
49
 
50
 
51
    // Writes require one clock cycle, and reads require 2 or 3 clock cycles (registered output).
52
    // The following logic controls the Ready signal based on these latencies.
53
    reg [1:0] delay_A, delay_B;
54
 
55
    always @(posedge clock) begin
56
        delay_A <= (reset | ~rea) ? 2'b00 : ((delay_A == 2'b10) ? delay_A : delay_A + 1);
57
        delay_B <= (reset | ~reb) ? 2'b00 : ((delay_B == 2'b10) ? delay_B : delay_B + 1);
58
    end
59
 
60
    always @(posedge clock) begin
61
        dreadya <= (reset) ? 0 : ((wea != 4'b0000) || ((delay_A == 2'b10) && rea)) ? 1 : 0;
62
        dreadyb <= (reset) ? 0 : ((web != 4'b0000) || ((delay_B == 2'b10) && reb)) ? 1 : 0;
63
    end
64
 
65
    BRAM_592KB_2R RAM (
66
        .clka   (clock),    // input clka
67
        .rsta   (reset),    // input rsta
68
        .wea    (wea),      // input [3 : 0] wea
69
        .addra  (addra),    // input [17 : 0] addra
70
        .dina   (dina),     // input [31 : 0] dina
71
        .douta  (douta),    // output [31 : 0] douta
72
        .clkb   (clock),    // input clkb
73
        .rstb   (reset),    // input rstb
74
        .web    (web),      // input [3 : 0] web
75
        .addrb  (addrb),    // input [17 : 0] addrb
76
        .dinb   (dinb),     // input [31 : 0] dinb
77
        .doutb  (doutb)     // output [31 : 0] doutb
78
    );
79
 
80
endmodule

powered by: WebSVN 2.1.0

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