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 3

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
module BRAM_592KB_Wrapper(
20
    input  clock,
21
    input  reset,
22
    input         rea,
23
    input  [3:0]  wea,
24
    input  [17:0] addra,
25
    input  [31:0] dina,
26
    output [31:0] douta,
27
    output reg       dreadya,
28
    input         reb,
29
    input  [3:0]  web,
30
    input  [17:0] addrb,
31
    input  [31:0] dinb,
32
    output [31:0] doutb,
33
    output reg       dreadyb
34
    );
35
 
36
    /* Four-Way Memory Handshake Protocol:
37
          1. Read/Write request goes high.
38
          2. Ack goes high when data is available.
39
          3. Read/Write request goes low.
40
          4. Ack signal goes low.
41
                  ____
42
          R/W: __|    |____
43
                     ____
44
          Ack: _____|    |____
45
 
46
    */
47
 
48
 
49
    // Writes require one clock cycle, and reads require 2 or 3 clock cycles (registered output).
50
    // The following logic controls the Ready signal based on these latencies.
51
    reg [1:0] delay_A, delay_B;
52
 
53
    always @(posedge clock) begin
54
        delay_A <= (reset | ~rea) ? 2'b00 : ((delay_A == 2'b10) ? delay_A : delay_A + 1);
55
        delay_B <= (reset | ~reb) ? 2'b00 : ((delay_B == 2'b10) ? delay_B : delay_B + 1);
56
    end
57
 
58
    always @(posedge clock) begin
59
        dreadya <= (reset) ? 0 : ((wea != 4'b0000) || ((delay_A == 2'b10) && rea)) ? 1 : 0;
60
        dreadyb <= (reset) ? 0 : ((web != 4'b0000) || ((delay_B == 2'b10) && reb)) ? 1 : 0;
61
    end
62
 
63
    BRAM_592KB_2R RAM (
64
        .clka   (clock),    // input clka
65
        .rsta   (reset),    // input rsta
66
        .wea    (wea),      // input [3 : 0] wea
67
        .addra  (addra),    // input [17 : 0] addra
68
        .dina   (dina),     // input [31 : 0] dina
69
        .douta  (douta),    // output [31 : 0] douta
70
        .clkb   (clock),    // input clkb
71
        .rstb   (reset),    // input rstb
72
        .web    (web),      // input [3 : 0] web
73
        .addrb  (addrb),    // input [17 : 0] addrb
74
        .dinb   (dinb),     // input [31 : 0] dinb
75
        .doutb  (doutb)     // output [31 : 0] doutb
76
    );
77
 
78
endmodule
79 3 ayersg
 

powered by: WebSVN 2.1.0

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