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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbubus.v] - Blame information for rev 43

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

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbubus.v
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     This is the top level file for the entire JTAG-USB to Wishbone
8
//              bus conversion.  (It's also the place to start debugging, should
9
//      things not go as planned.)  Bytes come into this routine, bytes go out,
10
//      and the wishbone bus (external to this routine) is commanded in between.
11
//
12
//
13
//
14
// Creator:     Dan Gisselquist, Ph.D.
15
//              Gisselquist Technology, LLC
16
//
17
////////////////////////////////////////////////////////////////////////////////
18
//
19
// Copyright (C) 2015, 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
//
38
//
39
module  wbubus(i_clk, i_rx_stb, i_rx_data,
40
                o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
41
                i_wb_ack, i_wb_stall, i_wb_err, i_wb_data,
42
                i_interrupt,
43 43 dgisselq
                o_tx_stb, o_tx_data, i_tx_busy,
44
                // o_dbg
45
                );
46 2 dgisselq
        parameter       LGWATCHDOG=19;
47
        input                   i_clk;
48
        input                   i_rx_stb;
49
        input           [7:0]    i_rx_data;
50
        output  wire            o_wb_cyc, o_wb_stb, o_wb_we;
51
        output  wire    [31:0]   o_wb_addr, o_wb_data;
52
        input                   i_wb_ack, i_wb_stall, i_wb_err;
53
        input           [31:0]   i_wb_data;
54
        input                   i_interrupt;
55
        output  wire            o_tx_stb;
56
        output  wire    [7:0]    o_tx_data;
57
        input                   i_tx_busy;
58
        // output       wire    [31:0]  o_dbg;
59
 
60
 
61
        reg             r_wdt_reset;
62
 
63
        // Decode ASCII input requests into WB bus cycle requests
64
        wire            in_stb;
65
        wire    [35:0]   in_word;
66
        wbuinput        getinput(i_clk, i_rx_stb, i_rx_data, in_stb, in_word);
67
 
68
        wire    w_bus_busy, fifo_in_stb, exec_stb, w_bus_reset;
69
        wire    [35:0]   fifo_in_word, exec_word;
70
// `define      NO_INPUT_FIFO
71
`ifdef  NO_INPUT_FIFO
72
        assign  fifo_in_stb = in_stb;
73
        assign  fifo_in_word = in_word;
74
        assign  w_bus_reset = 1'b0;
75
`else
76
        wire            ififo_empty_n, ififo_err;
77
        assign  fifo_in_stb = (~w_bus_busy)&&(ififo_empty_n);
78
        assign  w_bus_reset = r_wdt_reset;
79
        wbufifo #(36,6) padififo(i_clk, w_bus_reset,
80
                                in_stb, in_word, fifo_in_stb, fifo_in_word,
81
                                ififo_empty_n, ififo_err);
82
`endif
83
 
84
        // Take requests in, Run the bus, send results out
85
        // This only works if no requests come in while requests
86
        // are pending.
87
        wbuexec runwb(i_clk, r_wdt_reset, fifo_in_stb, fifo_in_word, w_bus_busy,
88
                o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
89
                i_wb_ack, i_wb_stall, i_wb_err, i_wb_data,
90
                exec_stb, exec_word);
91
 
92
        /*
93
        wire    [31:0]  cyc_debug;
94
        assign  cyc_debug = { 1'b0, o_wb_cyc, o_wb_stb, o_wb_we, i_wb_ack, i_wb_stall,
95
                                (i_wb_err||r_wdt_reset), o_wb_addr[14:0],
96
                                o_wb_data[4:0], i_wb_data[4:0] };
97
        assign  o_dbg = cyc_debug;
98
        */
99
 
100
        /*
101
        wire    [31:0]  fif_debug;
102
        assign  fif_debug = {
103
                        (exec_stb)&&(exec_word[35:30] == 6'h05),// 1
104
                        fifo_in_stb, fifo_in_word[35:30],       // 7
105
                        exec_stb, exec_word[35:30],             // 7
106
                        o_wb_cyc, o_wb_stb, o_wb_we,
107
                                i_wb_ack, i_wb_stall,           // 5
108
                        w_bus_busy, ififo_empty_n, w_bus_reset, // 3
109
                        i_rx_stb, o_wb_addr[7:0] };             // 9
110
        assign  o_dbg = fif_debug;
111
        */
112
 
113
        wire            ofifo_err;
114
        // wire [30:0]  out_dbg;
115
        wbuoutput       wroutput(i_clk, w_bus_reset,
116
                        exec_stb, exec_word,
117
                        o_wb_cyc, i_interrupt, exec_stb,
118
                        o_tx_stb, o_tx_data, i_tx_busy, ofifo_err);
119
 
120
        // Add in a watchdog timer to the bus
121
        reg     [(LGWATCHDOG-1):0]       r_wdt_timer;
122
        initial r_wdt_reset = 1'b0;
123
        initial r_wdt_timer = 0;
124
        always @(posedge i_clk)
125
                if ((~o_wb_cyc)||(i_wb_ack))
126
                begin
127
                        r_wdt_timer <= 0;
128
                        r_wdt_reset <= 1'b0;
129
                end else if (&r_wdt_timer)
130
                begin
131
                        r_wdt_reset <= 1'b1;
132
                        r_wdt_timer <= 0;
133
                end else begin
134 9 dgisselq
                        r_wdt_timer <= r_wdt_timer+{{(LGWATCHDOG-1){1'b0}},1'b1};
135 2 dgisselq
                        r_wdt_reset <= 1'b0;
136
                end
137
 
138
endmodule
139
 

powered by: WebSVN 2.1.0

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