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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc-sim/] [src/] [eco32/] [eco32.v] - Blame information for rev 302

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

Line No. Rev Author Line
1 301 hellwig
//
2
// eco32.v -- ECO32 top-level description
3
//
4
 
5
 
6
`timescale 1ns/10ps
7
`default_nettype none
8
 
9
 
10
module eco32(clk_in, rst_in_n);
11
    input clk_in;                       // clock input
12
    input rst_in_n;                     // reset input
13
 
14
  // clk_rst
15
  wire clk;                             // system clock
16
  wire rst;                             // system reset
17
  // cpu
18
  wire bus_stb;                         // bus strobe
19
  wire bus_we;                          // bus write enable
20
  wire [31:2] bus_addr;                 // bus address (word address)
21
  wire [31:0] bus_addr32;                // bus address (byte address)
22
  wire [31:0] bus_din;                   // bus data input, for reads
23
  wire [31:0] bus_dout;                  // bus data output, for writes
24
  wire bus_ack;                         // bus acknowledge
25
  wire [15:0] bus_irq;                   // bus interrupt requests
26
  // ram
27
  wire ram_stb;                         // ram strobe
28
  wire [31:0] ram_dout;                  // ram data output
29
  wire ram_ack;                         // ram acknowledge
30
  // rom
31
  wire rom_stb;                         // rom strobe
32
  wire [31:0] rom_dout;                  // rom data output
33
  wire rom_ack;                         // rom acknowledge
34
  // i/o
35
  wire i_o_stb;                         // i/o strobe
36
  // tmr0
37
  wire tmr0_stb;                        // tmr 0 strobe
38
  wire [31:0] tmr0_dout;         // tmr 0 data output
39
  wire tmr0_ack;                        // tmr 0 acknowledge
40
  wire tmr0_irq;                        // tmr 0 interrupt request
41
  // tmr1
42
  wire tmr1_stb;                        // tmr 1 strobe
43
  wire [31:0] tmr1_dout;         // tmr 1 data output
44
  wire tmr1_ack;                        // tmr 1 acknowledge
45
  wire tmr1_irq;                        // tmr 1 interrupt request
46
  // dsp
47
  wire dsp_stb;                         // dsp strobe
48
  wire [15:0] dsp_dout;                  // dsp data output
49
  wire dsp_ack;                         // dsp acknowledge
50
  // kbd
51
  wire kbd_stb;                         // kbd strobe
52
  wire [7:0] kbd_dout;                   // kbd data output
53
  wire kbd_ack;                         // kbd acknowledge
54
  wire kbd_irq;                         // kbd interrupt request
55
  // ser0
56
  wire ser0_stb;                        // ser 0 strobe
57
  wire [7:0] ser0_dout;                  // ser 0 data output
58
  wire ser0_ack;                        // ser 0 acknowledge
59
  wire ser0_irq_r;                      // ser 0 rcv interrupt request
60
  wire ser0_irq_t;                      // ser 0 xmt interrupt request
61
  // ser1
62
  wire ser1_stb;                        // ser 1 strobe
63
  wire [7:0] ser1_dout;                  // ser 1 data output
64
  wire ser1_ack;                        // ser 1 acknowledge
65
  wire ser1_irq_r;                      // ser 1 rcv interrupt request
66
  wire ser1_irq_t;                      // ser 1 xmt interrupt request
67
 
68
  //--------------------------------------
69
  // module instances
70
  //--------------------------------------
71
 
72
  clk_rst clk_rst_1(
73
    .clk_in(clk_in),
74
    .rst_in_n(rst_in_n),
75
    .clk(clk),
76
    .rst(rst)
77
  );
78
 
79
  cpu cpu_1(
80
    .clk(clk),
81
    .rst(rst),
82
    .bus_stb(bus_stb),
83
    .bus_we(bus_we),
84
    .bus_addr(bus_addr[31:2]),
85
    .bus_din(bus_din[31:0]),
86
    .bus_dout(bus_dout[31:0]),
87
    .bus_ack(bus_ack),
88
    .bus_irq(bus_irq[15:0])
89
  );
90
 
91
  // show the full 32-bit address in the simulation results
92
  assign bus_addr32[31:0] = { bus_addr[31:2], 2'b00 };
93
 
94
  ram ram_1(
95
    .clk(clk),
96
    .rst(rst),
97
    .stb(ram_stb),
98
    .we(bus_we),
99
    .addr(bus_addr[24:2]),
100
    .data_in(bus_dout[31:0]),
101
    .data_out(ram_dout[31:0]),
102
    .ack(ram_ack)
103
  );
104
 
105
  rom rom_1(
106
    .clk(clk),
107
    .rst(rst),
108
    .stb(rom_stb),
109
    .we(bus_we),
110
    .addr(bus_addr[15:2]),
111
    .data_out(rom_dout[31:0]),
112
    .ack(rom_ack)
113
  );
114
 
115
  tmr tmr_1(
116
    .clk(clk),
117
    .rst(rst),
118
    .stb(tmr0_stb),
119
    .we(bus_we),
120
    .addr(bus_addr[3:2]),
121
    .data_in(bus_dout[31:0]),
122
    .data_out(tmr0_dout[31:0]),
123
    .ack(tmr0_ack),
124
    .irq(tmr0_irq)
125
  );
126
 
127
  tmr tmr_2(
128
    .clk(clk),
129
    .rst(rst),
130
    .stb(tmr1_stb),
131
    .we(bus_we),
132
    .addr(bus_addr[3:2]),
133
    .data_in(bus_dout[31:0]),
134
    .data_out(tmr1_dout[31:0]),
135
    .ack(tmr1_ack),
136
    .irq(tmr1_irq)
137
  );
138
 
139
  dsp dsp_1(
140
    .clk(clk),
141
    .rst(rst),
142
    .stb(dsp_stb),
143
    .we(bus_we),
144
    .addr(bus_addr[13:2]),
145
    .data_in(bus_dout[15:0]),
146
    .data_out(dsp_dout[15:0]),
147
    .ack(dsp_ack)
148
  );
149
 
150
  kbd kbd_1(
151
    .clk(clk),
152
    .rst(rst),
153
    .stb(kbd_stb),
154
    .we(bus_we),
155
    .addr(bus_addr[2]),
156
    .data_in(bus_dout[7:0]),
157
    .data_out(kbd_dout[7:0]),
158
    .ack(kbd_ack),
159
    .irq(kbd_irq)
160
  );
161
 
162
  ser ser_1(
163
    .i(0),
164
    .clk(clk),
165
    .rst(rst),
166
    .stb(ser0_stb),
167
    .we(bus_we),
168
    .addr(bus_addr[3:2]),
169
    .data_in(bus_dout[7:0]),
170
    .data_out(ser0_dout[7:0]),
171
    .ack(ser0_ack),
172
    .irq_r(ser0_irq_r),
173
    .irq_t(ser0_irq_t)
174
  );
175
 
176
  ser ser_2(
177
    .i(1),
178
    .clk(clk),
179
    .rst(rst),
180
    .stb(ser1_stb),
181
    .we(bus_we),
182
    .addr(bus_addr[3:2]),
183
    .data_in(bus_dout[7:0]),
184
    .data_out(ser1_dout[7:0]),
185
    .ack(ser1_ack),
186
    .irq_r(ser1_irq_r),
187
    .irq_t(ser1_irq_t)
188
  );
189
 
190
  //--------------------------------------
191
  // address decoder
192
  //--------------------------------------
193
 
194
  // RAM: architectural limit  = 512 MB
195
  //      implementation limit =  32 MB
196
  assign ram_stb =
197
    (bus_stb == 1 && bus_addr[31:29] == 3'b000
198
                  && bus_addr[28:25] == 4'b0000) ? 1 : 0;
199
 
200
  // ROM: architectural limit  = 256 MB
201
  //      implementation limit =  64 KB
202
  assign rom_stb =
203
    (bus_stb == 1 && bus_addr[31:28] == 4'b0010
204
                  && bus_addr[27:16] == 12'b000000000000) ? 1 : 0;
205
 
206
  // I/O: architectural limit  = 256 MB
207
  assign i_o_stb =
208
    (bus_stb == 1 && bus_addr[31:28] == 4'b0011) ? 1 : 0;
209
  assign tmr0_stb =
210
    (i_o_stb == 1 && bus_addr[27:20] == 8'h00
211
                  && bus_addr[19:12] == 8'h00) ? 1 : 0;
212
  assign tmr1_stb =
213
    (i_o_stb == 1 && bus_addr[27:20] == 8'h00
214
                  && bus_addr[19:12] == 8'h01) ? 1 : 0;
215
  assign dsp_stb =
216
    (i_o_stb == 1 && bus_addr[27:20] == 8'h01) ? 1 : 0;
217
  assign kbd_stb =
218
    (i_o_stb == 1 && bus_addr[27:20] == 8'h02) ? 1 : 0;
219
  assign ser0_stb =
220
    (i_o_stb == 1 && bus_addr[27:20] == 8'h03
221
                  && bus_addr[19:12] == 8'h00) ? 1 : 0;
222
  assign ser1_stb =
223
    (i_o_stb == 1 && bus_addr[27:20] == 8'h03
224
                  && bus_addr[19:12] == 8'h01) ? 1 : 0;
225
 
226
  //--------------------------------------
227
  // data and acknowledge multiplexers
228
  //--------------------------------------
229
 
230
  assign bus_din[31:0] =
231
    (ram_stb == 1)  ? ram_dout[31:0] :
232
    (rom_stb == 1)  ? rom_dout[31:0] :
233
    (tmr0_stb == 1) ? tmr0_dout[31:0] :
234
    (tmr1_stb == 1) ? tmr1_dout[31:0] :
235
    (dsp_stb == 1)  ? { 16'h0000, dsp_dout[15:0] } :
236
    (kbd_stb == 1)  ? { 24'h000000, kbd_dout[7:0] } :
237
    (ser0_stb == 1) ? { 24'h000000, ser0_dout[7:0] } :
238
    (ser1_stb == 1) ? { 24'h000000, ser1_dout[7:0] } :
239
    32'h00000000;
240
 
241
  assign bus_ack =
242
    (ram_stb == 1)  ? ram_ack :
243
    (rom_stb == 1)  ? rom_ack :
244
    (tmr0_stb == 1) ? tmr0_ack :
245
    (tmr1_stb == 1) ? tmr1_ack :
246
    (dsp_stb == 1)  ? dsp_ack :
247
    (kbd_stb == 1)  ? kbd_ack :
248
    (ser0_stb == 1) ? ser0_ack :
249
    (ser1_stb == 1) ? ser1_ack :
250
    0;
251
 
252
  //--------------------------------------
253
  // bus interrupt request assignments
254
  //--------------------------------------
255
 
256
  assign bus_irq[15] = tmr1_irq;
257
  assign bus_irq[14] = tmr0_irq;
258
  assign bus_irq[13] = 0;
259
  assign bus_irq[12] = 0;
260
  assign bus_irq[11] = 0;
261
  assign bus_irq[10] = 0;
262
  assign bus_irq[ 9] = 0;
263
  assign bus_irq[ 8] = 0;
264
  assign bus_irq[ 7] = 0;
265
  assign bus_irq[ 6] = 0;
266
  assign bus_irq[ 5] = 0;
267
  assign bus_irq[ 4] = kbd_irq;
268
  assign bus_irq[ 3] = ser1_irq_r;
269
  assign bus_irq[ 2] = ser1_irq_t;
270
  assign bus_irq[ 1] = ser0_irq_r;
271
  assign bus_irq[ 0] = ser0_irq_t;
272
 
273
endmodule

powered by: WebSVN 2.1.0

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