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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [rtl/] [aux/] [busdelay.v] - Blame information for rev 34

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

Line No. Rev Author Line
1 2 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 Tecnology, LLC
23
//
24
///////////////////////////////////////////////////////////////////////////
25
//
26
// Copyright (C) 2015, Gisselquist Technology, LLC
27
//
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,
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);
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
        output  wire                    o_wb_stall;
59
        output  reg     [(DW-1):0]       o_wb_data;
60
        // Delayed bus
61
        output  reg                     o_dly_cyc, o_dly_stb, o_dly_we;
62
        output  reg     [(AW-1):0]       o_dly_addr;
63
        output  reg     [(DW-1):0]       o_dly_data;
64
        input                           i_dly_ack;
65
        input                           i_dly_stall;
66
        input           [(DW-1):0]       i_dly_data;
67
 
68
        initial o_dly_cyc = 1'b0;
69
        initial o_dly_stb = 1'b0;
70
 
71
        always @(posedge i_clk)
72
                o_dly_cyc <= i_wb_cyc;
73
        always @(posedge i_clk)
74
                if (~o_wb_stall)
75
                        o_dly_stb <= i_wb_stb;
76
        always @(posedge i_clk)
77
                if (~o_wb_stall)
78
                        o_dly_we  <= i_wb_we;
79
        always @(posedge i_clk)
80
                if (~o_wb_stall)
81
                        o_dly_addr<= i_wb_addr;
82
        always @(posedge i_clk)
83
                if (~o_wb_stall)
84
                        o_dly_data <= i_wb_data;
85
        always @(posedge i_clk)
86
                o_wb_ack  <= (i_dly_ack)&&(o_dly_cyc)&&(i_wb_cyc);
87
        always @(posedge i_clk)
88
                o_wb_data <= i_dly_data;
89
 
90 15 dgisselq
        // Our only non-delayed line, yet still really delayed.  Perhaps
91
        // there's a way to register this?
92
        // o_wb_stall <= (i_wb_cyc)&&(i_wb_stb) ... or some such?
93 34 dgisselq
        assign  o_wb_stall = ((i_wb_cyc)&&(o_dly_cyc)&&(i_dly_stall)&&(o_dly_stb));
94 2 dgisselq
 
95
endmodule

powered by: WebSVN 2.1.0

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