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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [cpu/] [busdelay.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:    busdelay.v
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU soft core
6
//
7
// Purpose:     Delay any access to the wishbone bus by a single clock.  This
8
//              particular version of the busdelay builds off of some previous
9
//      work, but also delays and buffers the stall line as well.  It is
10
//      designed to allow pipelined accesses (1 access/clock) to still work,
11
//      while also providing for single accesses.
12
//
13
//
14
// Creator:     Dan Gisselquist, Ph.D.
15
//              Gisselquist Technology, LLC
16
//
17
///////////////////////////////////////////////////////////////////////////
18
//
19
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
20
//
21
// This program is free software (firmware): you can redistribute it and/or
22
// modify it under the terms of  the GNU General Public License as published
23
// by the Free Software Foundation, either version 3 of the License, or (at
24
// your option) any later version.
25
//
26
// This program is distributed in the hope that it will be useful, but WITHOUT
27
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
28
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
29
// for more details.
30
//
31
// License:     GPL, v3, as defined and found on www.gnu.org,
32
//              http://www.gnu.org/licenses/gpl.html
33
//
34
//
35
///////////////////////////////////////////////////////////////////////////
36
//
37
module  busdelay(i_clk,
38
                // The input bus
39
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
40
                        o_wb_ack, o_wb_stall, o_wb_data, o_wb_err,
41
                // The delayed bus
42
                o_dly_cyc, o_dly_stb, o_dly_we, o_dly_addr, o_dly_data,
43
                        i_dly_ack, i_dly_stall, i_dly_data, i_dly_err);
44
        parameter       AW=32, DW=32;
45
        input   i_clk;
46
        // Input/master bus
47
        input                           i_wb_cyc, i_wb_stb, i_wb_we;
48
        input           [(AW-1):0]       i_wb_addr;
49
        input           [(DW-1):0]       i_wb_data;
50
        output  reg                     o_wb_ack;
51
        output  reg                     o_wb_stall;
52
        output  reg     [(DW-1):0]       o_wb_data;
53
        output  reg                     o_wb_err;
54
        // Delayed bus
55
        output  reg                     o_dly_cyc, o_dly_we;
56
        output  wire                    o_dly_stb;
57
        output  reg     [(AW-1):0]       o_dly_addr;
58
        output  reg     [(DW-1):0]       o_dly_data;
59
        input                           i_dly_ack;
60
        input                           i_dly_stall;
61
        input           [(DW-1):0]       i_dly_data;
62
        input                           i_dly_err;
63
 
64
        reg     loaded;
65
        initial o_dly_cyc = 1'b0;
66
        initial loaded    = 1'b0;
67
 
68
        always @(posedge i_clk)
69
                o_wb_stall <= (loaded)&&(i_dly_stall);
70
 
71
        initial o_dly_cyc = 1'b0;
72
        always @(posedge i_clk)
73
                o_dly_cyc <= (i_wb_cyc);
74
        // Add the i_wb_cyc criteria here, so we can simplify the o_wb_stall
75
        // criteria below, which would otherwise *and* these two.
76
        always @(posedge i_clk)
77
                loaded <= (i_wb_stb)||((loaded)&&(i_dly_stall)&&(~i_dly_err)&&(i_wb_cyc));
78
        assign  o_dly_stb = loaded;
79
        always @(posedge i_clk)
80
                if (~i_dly_stall)
81
                        o_dly_we  <= i_wb_we;
82
        always @(posedge i_clk)
83
                if (~i_dly_stall)
84
                        o_dly_addr<= i_wb_addr;
85
        always @(posedge i_clk)
86
                if (~i_dly_stall)
87
                        o_dly_data <= i_wb_data;
88
        always @(posedge i_clk)
89
                o_wb_ack  <= (i_dly_ack)&&(o_dly_cyc)&&(i_wb_cyc);
90
        always @(posedge i_clk)
91
                o_wb_data <= i_dly_data;
92
 
93
        always @(posedge i_clk)
94
                o_wb_err <= (i_dly_err)&&(o_dly_cyc)&&(i_wb_cyc);
95
 
96
endmodule

powered by: WebSVN 2.1.0

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