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

Subversion Repositories xulalx25soc

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

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 46 dgisselq
                o_tx_stb, o_tx_data, i_tx_busy);
44 2 dgisselq
        parameter       LGWATCHDOG=19;
45
        input                   i_clk;
46
        input                   i_rx_stb;
47
        input           [7:0]    i_rx_data;
48
        output  wire            o_wb_cyc, o_wb_stb, o_wb_we;
49
        output  wire    [31:0]   o_wb_addr, o_wb_data;
50
        input                   i_wb_ack, i_wb_stall, i_wb_err;
51
        input           [31:0]   i_wb_data;
52
        input                   i_interrupt;
53
        output  wire            o_tx_stb;
54
        output  wire    [7:0]    o_tx_data;
55
        input                   i_tx_busy;
56
        // output       wire    [31:0]  o_dbg;
57
 
58
 
59
        reg             r_wdt_reset;
60
 
61
        // Decode ASCII input requests into WB bus cycle requests
62
        wire            in_stb;
63
        wire    [35:0]   in_word;
64
        wbuinput        getinput(i_clk, i_rx_stb, i_rx_data, in_stb, in_word);
65
 
66
        wire    w_bus_busy, fifo_in_stb, exec_stb, w_bus_reset;
67
        wire    [35:0]   fifo_in_word, exec_word;
68
// `define      NO_INPUT_FIFO
69
`ifdef  NO_INPUT_FIFO
70
        assign  fifo_in_stb = in_stb;
71
        assign  fifo_in_word = in_word;
72
        assign  w_bus_reset = 1'b0;
73
`else
74
        wire            ififo_empty_n, ififo_err;
75
        assign  fifo_in_stb = (~w_bus_busy)&&(ififo_empty_n);
76
        assign  w_bus_reset = r_wdt_reset;
77
        wbufifo #(36,6) padififo(i_clk, w_bus_reset,
78
                                in_stb, in_word, fifo_in_stb, fifo_in_word,
79
                                ififo_empty_n, ififo_err);
80
`endif
81
 
82
        // Take requests in, Run the bus, send results out
83
        // This only works if no requests come in while requests
84
        // are pending.
85
        wbuexec runwb(i_clk, r_wdt_reset, fifo_in_stb, fifo_in_word, w_bus_busy,
86
                o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
87
                i_wb_ack, i_wb_stall, i_wb_err, i_wb_data,
88
                exec_stb, exec_word);
89
 
90
        /*
91
        wire    [31:0]  cyc_debug;
92
        assign  cyc_debug = { 1'b0, o_wb_cyc, o_wb_stb, o_wb_we, i_wb_ack, i_wb_stall,
93
                                (i_wb_err||r_wdt_reset), o_wb_addr[14:0],
94
                                o_wb_data[4:0], i_wb_data[4:0] };
95
        assign  o_dbg = cyc_debug;
96
        */
97
 
98
        /*
99
        wire    [31:0]  fif_debug;
100
        assign  fif_debug = {
101
                        (exec_stb)&&(exec_word[35:30] == 6'h05),// 1
102
                        fifo_in_stb, fifo_in_word[35:30],       // 7
103
                        exec_stb, exec_word[35:30],             // 7
104
                        o_wb_cyc, o_wb_stb, o_wb_we,
105
                                i_wb_ack, i_wb_stall,           // 5
106
                        w_bus_busy, ififo_empty_n, w_bus_reset, // 3
107
                        i_rx_stb, o_wb_addr[7:0] };             // 9
108
        assign  o_dbg = fif_debug;
109
        */
110
 
111
        wire            ofifo_err;
112
        // wire [30:0]  out_dbg;
113
        wbuoutput       wroutput(i_clk, w_bus_reset,
114
                        exec_stb, exec_word,
115
                        o_wb_cyc, i_interrupt, exec_stb,
116
                        o_tx_stb, o_tx_data, i_tx_busy, ofifo_err);
117
 
118
        // Add in a watchdog timer to the bus
119
        reg     [(LGWATCHDOG-1):0]       r_wdt_timer;
120
        initial r_wdt_reset = 1'b0;
121
        initial r_wdt_timer = 0;
122
        always @(posedge i_clk)
123
                if ((~o_wb_cyc)||(i_wb_ack))
124
                begin
125
                        r_wdt_timer <= 0;
126
                        r_wdt_reset <= 1'b0;
127
                end else if (&r_wdt_timer)
128
                begin
129
                        r_wdt_reset <= 1'b1;
130
                        r_wdt_timer <= 0;
131
                end else begin
132 9 dgisselq
                        r_wdt_timer <= r_wdt_timer+{{(LGWATCHDOG-1){1'b0}},1'b1};
133 2 dgisselq
                        r_wdt_reset <= 1'b0;
134
                end
135
 
136
endmodule
137
 

powered by: WebSVN 2.1.0

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