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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [wbubus.v] - Blame information for rev 38

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

Line No. Rev Author Line
1 3 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbubus.v
4
//
5
// Project:     FPGA library
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-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
//
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
                o_tx_stb, o_tx_data, i_tx_busy);
44
        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            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
        // assign       o_dbg = (i_wb_ack)&&(i_wb_cyc);
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
        wire    [31:0]  fif_debug;
101
        assign  fif_debug = {
102
                        (exec_stb)&&(exec_word[35:30] == 6'h05),// 1
103
                        fifo_in_stb, fifo_in_word[35:30],       // 7
104
                        exec_stb, exec_word[35:30],             // 7
105
                        o_wb_cyc, o_wb_stb, o_wb_we,
106
                                i_wb_ack, i_wb_stall,           // 5
107
                        w_bus_busy, ififo_empty_n, w_bus_reset, // 3
108
                        i_rx_stb, o_wb_addr[7:0] };             // 9
109
        assign  o_dbg = fif_debug;
110
        */
111
 
112
        wire            ofifo_err;
113
        // wire [30:0]  out_dbg;
114
        wbuoutput       wroutput(i_clk, w_bus_reset,
115
                        exec_stb, exec_word,
116
                        o_wb_cyc, i_interrupt, exec_stb,
117
                        o_tx_stb, o_tx_data, i_tx_busy, ofifo_err);
118
 
119
        // Add in a watchdog timer to the bus
120
        reg     [(LGWATCHDOG-1):0]       r_wdt_timer;
121
        initial r_wdt_reset = 1'b0;
122
        initial r_wdt_timer = 0;
123
        always @(posedge i_clk)
124
                if ((~o_wb_cyc)||(i_wb_ack))
125
                begin
126
                        r_wdt_timer <= 0;
127
                        r_wdt_reset <= 1'b0;
128
                end else if (&r_wdt_timer)
129
                begin
130
                        r_wdt_reset <= 1'b1;
131
                        r_wdt_timer <= 0;
132
                end else begin
133
                        r_wdt_timer <= r_wdt_timer+{{(LGWATCHDOG-1){1'b0}},1'b1};
134
                        r_wdt_reset <= 1'b0;
135
                end
136
 
137
endmodule
138
 

powered by: WebSVN 2.1.0

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