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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [memdev.v] - Blame information for rev 30

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

Line No. Rev Author Line
1 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
2 3 dgisselq
//
3
// Filename:    memdev.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     This file is really simple: it creates an on-chip memory,
8
//              accessible via the wishbone bus, that can be used in this
9
//      project.  The memory has single cycle pipeline access, although the
10
//      memory pipeline here still costs a cycle and there may be other cycles
11
//      lost between the ZipCPU (or whatever is the master of the bus) and this,
12
//      thus costing more cycles in access.  Either way, operations can be
13
//      pipelined for single cycle access on subsequent transactions.
14
//
15
//
16
// Creator:     Dan Gisselquist, Ph.D.
17
//              Gisselquist Technology, LLC
18
//
19 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
20 3 dgisselq
//
21
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
22
//
23
// This program is free software (firmware): you can redistribute it and/or
24
// modify it under the terms of  the GNU General Public License as published
25
// by the Free Software Foundation, either version 3 of the License, or (at
26
// your option) any later version.
27
//
28
// This program is distributed in the hope that it will be useful, but WITHOUT
29
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
30
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
31
// for more details.
32
//
33
// License:     GPL, v3, as defined and found on www.gnu.org,
34
//              http://www.gnu.org/licenses/gpl.html
35
//
36
//
37 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
38 3 dgisselq
//
39
//
40
module  memdev(i_clk, i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
41
                o_wb_ack, o_wb_stall, o_wb_data);
42 25 dgisselq
        parameter       AW=15, DW=32, EXTRACLOCK= 0;
43 3 dgisselq
        input                           i_clk, i_wb_cyc, i_wb_stb, i_wb_we;
44
        input           [(AW-1):0]       i_wb_addr;
45
        input           [(DW-1):0]       i_wb_data;
46
        output  reg                     o_wb_ack;
47
        output  wire                    o_wb_stall;
48
        output  reg     [(DW-1):0]       o_wb_data;
49
 
50 25 dgisselq
        wire                    w_wstb, w_stb;
51
        wire    [(DW-1):0]       w_data;
52
        wire    [(AW-1):0]       w_addr;
53 3 dgisselq
 
54 25 dgisselq
        generate
55
        if (EXTRACLOCK == 0)
56
        begin
57 3 dgisselq
 
58 25 dgisselq
                assign  w_wstb = (i_wb_stb)&&(i_wb_we);
59
                assign  w_stb  = i_wb_stb;
60
                assign  w_addr = i_wb_addr;
61
                assign  w_data = i_wb_data;
62
 
63
        end else begin
64
 
65
                reg             last_wstb, last_stb;
66
                always @(posedge i_clk)
67
                        last_wstb <= (i_wb_stb)&&(i_wb_we);
68
                always @(posedge i_clk)
69
                        last_stb <= (i_wb_stb);
70
 
71
                reg     [(DW-1):0]       last_data;
72
                reg     [(AW-1):0]       last_addr;
73
                always @(posedge i_clk)
74
                        last_data <= i_wb_data;
75
                always @(posedge i_clk)
76
                        last_addr <= i_wb_addr;
77
 
78
                assign  w_wstb = last_wstb;
79
                assign  w_stb  = last_stb;
80
                assign  w_addr = last_addr;
81
                assign  w_data = last_data;
82
        end endgenerate
83
 
84 3 dgisselq
        reg     [(DW-1):0]       mem     [0:((1<<AW)-1)];
85
        always @(posedge i_clk)
86 25 dgisselq
                o_wb_data <= mem[w_addr];
87 3 dgisselq
        always @(posedge i_clk)
88 25 dgisselq
                if (w_wstb)
89
                        mem[w_addr] <= w_data;
90 3 dgisselq
        always @(posedge i_clk)
91 25 dgisselq
                o_wb_ack <= (w_stb);
92 3 dgisselq
        assign  o_wb_stall = 1'b0;
93
 
94
endmodule

powered by: WebSVN 2.1.0

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