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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [cpu/] [busdelay.v] - Blame information for rev 113

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

Line No. Rev Author Line
1 21 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.
8
//
9
//      When the first Zip System would not meet the timing requirements of
10
//      the board it was placed upon, this bus delay was added to help out.
11
//      It may no longer be necessary, having cleaned some other problems up
12
//      first, but it will remain here as a means of alleviating timing
13
//      problems.
14
//
15
//      The specific problem takes place on the stall line: a wishbone master
16
//      *must* know on the first clock whether or not the bus will stall.
17
//
18
//
19
//
20
//
21
// Creator:     Dan Gisselquist, Ph.D.
22
//              Gisselquist Technology, LLC
23
//
24
///////////////////////////////////////////////////////////////////////////
25
//
26 113 dgisselq
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
27 21 dgisselq
//
28
// This program is free software (firmware): you can redistribute it and/or
29
// modify it under the terms of  the GNU General Public License as published
30
// by the Free Software Foundation, either version 3 of the License, or (at
31
// your option) any later version.
32
//
33
// This program is distributed in the hope that it will be useful, but WITHOUT
34
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
35
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36
// for more details.
37
//
38
// License:     GPL, v3, as defined and found on www.gnu.org,
39
//              http://www.gnu.org/licenses/gpl.html
40
//
41
//
42
///////////////////////////////////////////////////////////////////////////
43
//
44
module  busdelay(i_clk,
45
                // The input bus
46
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
47
                        o_wb_ack, o_wb_stall, o_wb_data, o_wb_err,
48
                // The delayed bus
49
                o_dly_cyc, o_dly_stb, o_dly_we, o_dly_addr, o_dly_data,
50
                        i_dly_ack, i_dly_stall, i_dly_data, i_dly_err);
51
        parameter       AW=32, DW=32;
52
        input   i_clk;
53
        // Input/master bus
54
        input                           i_wb_cyc, i_wb_stb, i_wb_we;
55
        input           [(AW-1):0]       i_wb_addr;
56
        input           [(DW-1):0]       i_wb_data;
57
        output  reg                     o_wb_ack;
58 113 dgisselq
        output  reg                     o_wb_stall;
59 21 dgisselq
        output  reg     [(DW-1):0]       o_wb_data;
60 113 dgisselq
        output  reg                     o_wb_err;
61 21 dgisselq
        // Delayed bus
62 113 dgisselq
        output  reg                     o_dly_cyc, o_dly_we;
63
        output  wire                    o_dly_stb;
64 21 dgisselq
        output  reg     [(AW-1):0]       o_dly_addr;
65
        output  reg     [(DW-1):0]       o_dly_data;
66
        input                           i_dly_ack;
67
        input                           i_dly_stall;
68
        input           [(DW-1):0]       i_dly_data;
69
        input                           i_dly_err;
70
 
71 113 dgisselq
        reg     loaded;
72 21 dgisselq
        initial o_dly_cyc = 1'b0;
73 113 dgisselq
        initial loaded    = 1'b0;
74 21 dgisselq
 
75
        always @(posedge i_clk)
76 113 dgisselq
                o_wb_stall <= (loaded)&&(i_dly_stall);
77
 
78
        initial o_dly_cyc = 1'b0;
79
        always @(posedge i_clk)
80
                o_dly_cyc <= (i_wb_cyc);
81 21 dgisselq
        // Add the i_wb_cyc criteria here, so we can simplify the o_wb_stall
82
        // criteria below, which would otherwise *and* these two.
83
        always @(posedge i_clk)
84 113 dgisselq
                loaded <= (i_wb_stb)||((loaded)&&(i_dly_stall)&&(~i_dly_err)&&(i_wb_cyc));
85
        assign  o_dly_stb = loaded;
86 21 dgisselq
        always @(posedge i_clk)
87 113 dgisselq
                if (~i_dly_stall)
88 21 dgisselq
                        o_dly_we  <= i_wb_we;
89
        always @(posedge i_clk)
90 113 dgisselq
                if (~i_dly_stall)
91 21 dgisselq
                        o_dly_addr<= i_wb_addr;
92
        always @(posedge i_clk)
93 113 dgisselq
                if (~i_dly_stall)
94 21 dgisselq
                        o_dly_data <= i_wb_data;
95
        always @(posedge i_clk)
96
                o_wb_ack  <= (i_dly_ack)&&(o_dly_cyc)&&(i_wb_cyc);
97
        always @(posedge i_clk)
98
                o_wb_data <= i_dly_data;
99
 
100 113 dgisselq
        always @(posedge i_clk)
101
                o_wb_err <= (i_dly_err)&&(o_dly_cyc)&&(i_wb_cyc);
102 21 dgisselq
 
103
endmodule

powered by: WebSVN 2.1.0

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