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

Subversion Repositories pss

[/] [pss/] [trunk/] [pss/] [hdl/] [pss/] [zpu_uc/] [zpu_uc.v] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 AlexAntono
/*
2
 PSS
3
 
4
 Copyright (c) 2016 Alexander Antonov <153287@niuitmo.ru>
5
 All rights reserved.
6
 
7 5 AlexAntono
 Version 0.9.0
8 2 AlexAntono
 
9
 The FreeBSD license
10
 
11
 Redistribution and use in source and binary forms, with or without
12
 modification, are permitted provided that the following conditions
13
 are met:
14
 
15
 1. Redistributions of source code must retain the above copyright
16
    notice, this list of conditions and the following disclaimer.
17
 2. Redistributions in binary form must reproduce the above
18
    copyright notice, this list of conditions and the following
19
    disclaimer in the documentation and/or other materials
20
    provided with the distribution.
21
 
22
 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
23
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25
 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 PSS PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
 
36
 
37
module ZPU_uC
38
#(
39
        parameter CPU_PRESENT = 1,
40
        parameter CPU_RESET_DEFAULT = 1,
41 5 AlexAntono
        parameter A31_DEFAULT = 1,
42 2 AlexAntono
        parameter MEM_DATA = "data.bin",
43
        parameter MEM_SIZE_KB = 1
44
)
45
(
46 5 AlexAntono
        input  clk_i,
47 2 AlexAntono
 
48 5 AlexAntono
        input  arst_i,
49
        output srst_o,
50
        input  srst_i,
51
        output ext_rst_o,
52
 
53
        input [3:0] INT_bi,
54
 
55 2 AlexAntono
        // Expansion bus
56
        output xport_req_o,
57
        input  xport_ack_i,
58
        input  xport_err_i,
59
        output xport_we_o,
60
        output [31:0] xport_addr_bo,
61
        output [31:0] xport_wdata_bo,
62
        input  xport_resp_i,
63
        input  [31:0] xport_rdata_bi,
64
 
65
        //Debug interface
66
        input  dbg_enb_i,
67
        input  dbg_wr_i,
68
        input  [31:0] dbg_addr_bi,
69
        input  [31:0] dbg_data_bi,
70
        output dbg_resp_o,
71
        output [31:0] dbg_data_bo
72
);
73
 
74 5 AlexAntono
wire app_reset;
75
assign app_reset = srst_i | srst_o;
76
 
77
// CPU system bus
78 2 AlexAntono
wire            cpu_bus_enb;
79
wire            cpu_bus_we;
80
wire            cpu_bus_ack;
81
wire [31:0] cpu_bus_read;
82
wire [31:0] cpu_bus_write;
83
wire [31:0] cpu_bus_addr;
84
wire [3:0]  cpu_bus_writemask;
85
 
86
// MAU-RAM bus
87
wire [31:0] ram0_bus_addr;
88
wire            ram0_bus_we;
89
wire [31:0] ram0_bus_rddata;
90
wire [31:0] ram0_bus_wrdata;
91
 
92
wire [31:0] ram1_bus_addr;
93
wire            ram1_bus_we;
94
wire [31:0] ram1_bus_rddata;
95
wire [31:0] ram1_bus_wrdata;
96
 
97 5 AlexAntono
// CPU control
98 2 AlexAntono
wire cpu_present;
99
wire [63:0] zpu_status;
100
wire cpu_break;
101
wire [31:0] cpu_pc;
102
 
103
wire            cpu_interrupt;
104
wire            cpu_interrupt_ack;
105
wire            cpu_reset;
106
wire            cpu_enb;
107
 
108
generate
109
        if (CPU_PRESENT == 1)
110
 
111
// Processor core
112
zpu_core
113
#(
114
        .stack_address((MEM_SIZE_KB * 1024) - 8)
115
)
116
zpu_core
117
(
118
        .clk(clk_i),
119 5 AlexAntono
        .sreset(app_reset | cpu_reset),
120 2 AlexAntono
        .enable(cpu_enb),
121
        .cpu_present(cpu_present),
122
        .pc_bo(cpu_pc),
123
 
124
        .mem_req(cpu_bus_enb),
125
        .mem_we(cpu_bus_we),
126
        .mem_ack(cpu_bus_ack),
127
        .mem_read(cpu_bus_read),
128
        .mem_write(cpu_bus_write),
129
        .out_mem_addr(cpu_bus_addr),
130
        .mem_writeMask(cpu_bus_writemask),
131
 
132
        .interrupt(cpu_interrupt),
133
        .interrupt_ack(cpu_interrupt_ack),
134
        .break_o(cpu_break),
135
        .zpu_status(zpu_status)
136
);
137
 
138
        else
139
 
140
zpu_core_stub zpu_core
141
(
142
        .clk(clk_i),
143 5 AlexAntono
        .sreset(app_reset | cpu_reset),
144 2 AlexAntono
        .enable(cpu_enb),
145
        .cpu_present(cpu_present),
146
        .pc_bo(cpu_pc),
147
 
148
        .mem_req(cpu_bus_enb),
149
        .mem_we(cpu_bus_we),
150
        .mem_ack(cpu_bus_ack),
151
        .mem_read(cpu_bus_read),
152
        .mem_write(cpu_bus_write),
153
        .out_mem_addr(cpu_bus_addr),
154
        .mem_writeMask(cpu_bus_writemask),
155
 
156
        .interrupt(cpu_interrupt),
157
        .interrupt_ack(cpu_interrupt_ack),
158
        .break_o(cpu_break),
159
        .zpu_status(zpu_status)
160
);
161
 
162
endgenerate
163
 
164
 
165 5 AlexAntono
PSS_MotherBlock
166 2 AlexAntono
#(
167 5 AlexAntono
        .A31_DEFAULT(A31_DEFAULT),
168 2 AlexAntono
        .CPU_RESET_DEFAULT(CPU_RESET_DEFAULT),
169
        .MEM_SIZE_KB(MEM_SIZE_KB)
170
)
171 5 AlexAntono
MotherBlock
172 2 AlexAntono
(
173
        .clk_i(clk_i),
174 5 AlexAntono
 
175
        .arst_i(arst_i),
176
        .srst_o(srst_o),
177
        .srst_i(srst_i),
178
        .ext_rst_o(ext_rst_o),
179 2 AlexAntono
 
180 5 AlexAntono
        .INT_bi(INT_bi),
181
        .cpu_ireq_o(cpu_interrupt),
182
        .cpu_iack_i(cpu_interrupt_ack),
183
 
184 2 AlexAntono
        //// Masters ////
185
        // Debug bus //
186
        .dbg_enb_i(dbg_enb_i),
187
        .dbg_we_i(dbg_wr_i),
188
        .dbg_addr_bi(dbg_addr_bi),
189
        .dbg_wdata_bi(dbg_data_bi),
190
        .dbg_ack_o(dbg_resp_o),
191
        .dbg_rdata_bo(dbg_data_bo),
192
 
193
        // ZPU bus //
194
        .cpu_enb_i(cpu_bus_enb),
195
        .cpu_we_i(cpu_bus_we),
196
        .cpu_ack_o(cpu_bus_ack),
197
        .cpu_rdata_bo(cpu_bus_read),
198
        .cpu_wdata_bi(cpu_bus_write),
199
        .cpu_addr_bi(cpu_bus_addr),
200
        .cpu_writemask_bi(cpu_bus_writemask),
201
 
202
        //// Slaves ////
203
        // RAM0 bus //
204
        .ram0_addr_bo(ram0_bus_addr),
205
        .ram0_we_o(ram0_bus_we),
206
        .ram0_wdata_bo(ram0_bus_wrdata),
207
        .ram0_rdata_bi(ram0_bus_rddata),
208
 
209
        // RAM1 bus //
210
        .ram1_addr_bo(ram1_bus_addr),
211
        .ram1_we_o(ram1_bus_we),
212
        .ram1_wdata_bo(ram1_bus_wrdata),
213
        .ram1_rdata_bi(ram1_bus_rddata),
214
 
215
        // Expansion port //
216
        .xport_req_o(xport_req_o),
217
        .xport_ack_i(xport_ack_i),
218
        .xport_err_i(xport_err_i),
219
        .xport_we_o(xport_we_o),
220
        .xport_addr_bo(xport_addr_bo),
221
        .xport_wdata_bo(xport_wdata_bo),
222
        .xport_resp_i(xport_resp_i),
223
        .xport_rdata_bi(xport_rdata_bi),
224
 
225 5 AlexAntono
        .cpu_present_i(cpu_present),
226 2 AlexAntono
        .cpu_pc_bi(cpu_pc),
227
        .cpu_break_i(cpu_break),
228
        .cpu_reset_o(cpu_reset),
229 5 AlexAntono
        .cpu_enb_o(cpu_enb)
230 2 AlexAntono
);
231
 
232
ram_dual
233
#(
234
        .mem_data(MEM_DATA),
235
        .dat_width(32),
236
        .adr_width(32),
237
        .mem_size((MEM_SIZE_KB * 1024) / 4 )
238
)
239
ram_dual_port
240
(
241
        .clk(clk_i),
242
 
243
        .dat0_i(ram0_bus_wrdata),
244
    .adr0_i({2'h0, ram0_bus_addr[31:2]}),
245
    .we0_i(ram0_bus_we),
246
    .dat0_o(ram0_bus_rddata),
247
 
248
    .dat1_i(ram1_bus_wrdata),
249
    .adr1_i({2'h0, ram1_bus_addr[31:2]}),
250
    .we1_i(ram1_bus_we),
251
    .dat1_o(ram1_bus_rddata)
252
);
253
 
254
endmodule

powered by: WebSVN 2.1.0

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