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

Subversion Repositories openarty

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

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

Line No. Rev Author Line
1 3 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
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
///////////////////////////////////////////////////////////////////////////
20
//
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
///////////////////////////////////////////////////////////////////////////
38
//
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
        parameter       AW=15, DW=32;
43
        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
        reg             last_wstb, last_stb;
51
        always @(posedge i_clk)
52
                last_wstb <= (i_wb_stb)&&(i_wb_we);
53
        always @(posedge i_clk)
54
                last_stb <= (i_wb_stb);
55
 
56
        reg     [(DW-1):0]       last_data;
57
        reg     [(AW-1):0]       last_addr;
58
        always @(posedge i_clk)
59
                last_data <= i_wb_data;
60
        always @(posedge i_clk)
61
                last_addr <= i_wb_addr;
62
 
63
        reg     [(DW-1):0]       mem     [0:((1<<AW)-1)];
64
        always @(posedge i_clk)
65
                o_wb_data <= mem[last_addr];
66
        always @(posedge i_clk)
67
                if (last_wstb)
68
                        mem[last_addr] <= last_data;
69
        always @(posedge i_clk)
70
                o_wb_ack <= (last_stb);
71
        assign  o_wb_stall = 1'b0;
72
 
73
endmodule

powered by: WebSVN 2.1.0

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