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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [rtl/] [wbdeppsimple.v] - Blame information for rev 33

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

Line No. Rev Author Line
1 8 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbdeppsimple.v
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     This is a very simple DEPP to Wishbone driver.  It cannot handle
8
//              pipeline reads or writes, it cannot compress anything being
9
//      transmitted, however it can read/write a 32-bit wishbone bus with a 
10
//      proper software driver.
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
//
40
//
41
module wbdeppsimple(i_clk,
42
        i_astb_n, i_dstb_n, i_write_n,i_depp, o_depp, o_wait,
43
        o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
44
                i_wb_ack, i_wb_stall, i_wb_err, i_wb_data, i_int);
45
        input   i_clk;
46
        // DEPP interface
47
        input                   i_astb_n, i_dstb_n, i_write_n;
48
        input           [7:0]    i_depp;
49
        output  reg     [7:0]    o_depp;
50
        output  wire            o_wait;
51
        // Wishbone master interface
52
        output  reg     o_wb_cyc, o_wb_stb, o_wb_we;
53
        output  reg     [31:0]   o_wb_addr, o_wb_data;
54
        input                   i_wb_ack, i_wb_stall, i_wb_err;
55
        input           [31:0]   i_wb_data;
56
        input                   i_int;
57
 
58
        // Synchronize the incoming signals
59
        reg     x_dstb_n, x_astb_n, x_write_n,
60
                r_dstb_n, r_astb_n, r_write_n,
61
                l_dstb_n, l_astb_n;
62
        reg     [7:0]    x_depp, r_depp;
63
        initial x_dstb_n = 1'b1;
64
        initial r_dstb_n = 1'b1;
65
        initial l_dstb_n = 1'b1;
66
        initial x_astb_n = 1'b1;
67
        initial r_astb_n = 1'b1;
68
        initial l_astb_n = 1'b1;
69
        always @(posedge i_clk)
70
        begin
71
                { x_dstb_n, x_astb_n, x_write_n, x_depp }
72
                        <= { i_dstb_n, i_astb_n, i_write_n, i_depp };
73
                { r_dstb_n, r_astb_n, r_write_n, r_depp }
74
                        <= { x_dstb_n, x_astb_n, x_write_n, x_depp };
75
                { l_dstb_n, l_astb_n } <= { r_dstb_n, r_astb_n };
76
        end
77
 
78
        wire    w_wait;
79
        assign  w_wait = ~(&{x_dstb_n, x_astb_n,
80
                                r_dstb_n, r_astb_n,
81
                                l_dstb_n, l_astb_n});
82
 
83
        reg     [7:0]    addr;
84
        reg     [31:0]   r_data;
85
 
86
        wire    astb, dstb, w_write;
87
        assign  astb = (~r_astb_n)&&(l_astb_n);
88
        assign  dstb = (~r_dstb_n)&&(l_dstb_n);
89
        assign  w_write= (~r_write_n);
90
 
91
        initial o_wb_cyc = 1'b0;
92
        initial o_wb_stb = 1'b0;
93
        initial addr = 8'h00;
94
        always @(posedge i_clk)
95
        begin
96
                if ((w_write)&&(astb))
97
                        addr <= r_depp;
98
 
99
                if ((w_write)&&(dstb)&&(addr[7:3]==5'h00))
100
                begin
101
                        case(addr[2:0])
102
                        //
103
                        3'b000: o_wb_addr[31:24] <= r_depp;
104
                        3'b001: o_wb_addr[23:16] <= r_depp;
105
                        3'b010: o_wb_addr[15: 8] <= r_depp;
106
                        3'b011: o_wb_addr[ 7: 0] <= r_depp;
107
                        //
108
                        3'b100: o_wb_data[31:24] <= r_depp;
109
                        3'b101: o_wb_data[23:16] <= r_depp;
110
                        3'b110: o_wb_data[15: 8] <= r_depp;
111
                        3'b111: o_wb_data[ 7: 0] <= r_depp;
112
                        //
113
                        endcase
114
                end
115
                if ((o_wb_cyc)&&(i_wb_ack)&&(~o_wb_we))
116
                        r_data <= i_wb_data;
117
 
118
                // Direct BUS control
119
                if ((w_write)&&(dstb)&&(|addr[7:3]))
120
                begin
121
                        o_wb_cyc <= r_depp[0];
122
                        o_wb_stb <= r_depp[0];
123
                        o_wb_we  <= r_depp[1];
124
                end else begin
125
                        o_wb_stb <= 1'b0;
126
                        if ((o_wb_cyc)&&(i_wb_ack))
127
                                o_wb_cyc <= 1'b0;
128
                end
129
        end
130
 
131
        assign  o_wait = (w_wait);
132
 
133
        reg     r_int, r_err;
134
        initial r_int = 1'b0;
135
        initial r_err = 1'b0;
136
        always @(posedge i_clk)
137
        begin
138
                if (addr[4])
139
                        o_depp <= { 5'h0, o_wb_cyc, r_int, r_err };
140
                else case(addr[2:0])
141
                3'b000: o_depp <= o_wb_addr[31:24];
142
                3'b001: o_depp <= o_wb_addr[23:16];
143
                3'b010: o_depp <= o_wb_addr[15: 8];
144
                3'b011: o_depp <= o_wb_addr[ 7: 0];
145
                3'b100: o_depp <= r_data[31:24];
146
                3'b101: o_depp <= r_data[23:16];
147
                3'b110: o_depp <= r_data[15: 8];
148
                3'b111: o_depp <= r_data[ 7: 0];
149
                endcase
150
 
151
                r_int <= (i_int)   ||((r_int)&&((~dstb)||(w_write)||(~addr[4])));
152
                r_err <= (i_wb_err)||((r_err)&&((~dstb)||(w_write)||(~addr[4])));
153
        end
154
 
155
endmodule

powered by: WebSVN 2.1.0

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