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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [sim/] [top.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 ultra_embe
//-----------------------------------------------------------------
2
//                           AltOR32 
3
//                Alternative Lightweight OpenRisc 
4
//                            V2.0
5
//                     Ultra-Embedded.com
6
//                   Copyright 2011 - 2013
7
//
8
//               Email: admin@ultra-embedded.com
9
//
10
//                       License: LGPL
11
//-----------------------------------------------------------------
12
//
13
// Copyright (C) 2011 - 2013 Ultra-Embedded.com
14
//
15
// This source file may be used and distributed without         
16
// restriction provided that this copyright statement is not    
17
// removed from the file and that any derivative work contains  
18
// the original copyright notice and the associated disclaimer. 
19
//
20
// This source file is free software; you can redistribute it   
21
// and/or modify it under the terms of the GNU Lesser General   
22
// Public License as published by the Free Software Foundation; 
23
// either version 2.1 of the License, or (at your option) any   
24
// later version.
25
//
26
// This source is distributed in the hope that it will be       
27
// useful, but WITHOUT ANY WARRANTY; without even the implied   
28
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
29
// PURPOSE.  See the GNU Lesser General Public License for more 
30
// details.
31
//
32
// You should have received a copy of the GNU Lesser General    
33
// Public License along with this source; if not, write to the 
34
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
35
// Boston, MA  02111-1307  USA
36
//-----------------------------------------------------------------
37
 
38
//-----------------------------------------------------------------
39
// Module
40
//-----------------------------------------------------------------
41
module top
42
(
43
    // Clocking & Reset
44
    input clk_i,
45
    input rst_i,
46
    // Fault Output
47
    output fault_o,
48
    // Break Output 
49
    output break_o,
50
    // Interrupt Input
51
    input intr_i
52
);
53
 
54
//-----------------------------------------------------------------
55
// Params
56
//-----------------------------------------------------------------
57
parameter           CLK_KHZ              = 8192;
58
parameter           BOOT_VECTOR          = 32'h10000000;
59
parameter           ISR_VECTOR           = 32'h10000000;
60
 
61
//-----------------------------------------------------------------
62
// Registers / Wires
63
//-----------------------------------------------------------------
64
wire [31:0]         soc_addr;
65
wire [31:0]         soc_data_w;
66
wire [31:0]         soc_data_r;
67
wire [3:0]          soc_wr;
68
wire                soc_rd;
69
wire                soc_irq;
70
 
71
wire[31:0]          dmem_address;
72
wire[31:0]          dmem_data_w;
73
wire[31:0]          dmem_data_r;
74
wire[3:0]           dmem_wr;
75
wire                dmem_rd;
76
wire                dmem_burst;
77
wire                dmem_ack;
78
reg                 dmem_req_r;
79
 
80
wire[31:0]          imem_addr;
81
wire[31:0]          imem_data;
82
wire                imem_rd;
83
wire                imem_burst;
84
wire                imem_ack;
85
reg                 imem_req_r;
86
 
87
//-----------------------------------------------------------------
88
// Instantiation
89
//-----------------------------------------------------------------
90
 
91
// BlockRAM
92
ram
93
#(
94
    .block_count(128) // 1MB
95
)
96
u_ram
97
(
98
    .clka_i(clk_i),
99
    .ena_i(1'b1),
100
    .wea_i(4'b0),
101
    .addra_i(imem_addr[31:2]),
102
    .dataa_i(32'b0),
103
    .dataa_o(imem_data),
104
 
105
    .clkb_i(clk_i),
106
    .enb_i(1'b1),
107
    .web_i(dmem_wr),
108
    .addrb_i(dmem_address[31:2]),
109
    .datab_i(dmem_data_w),
110
    .datab_o(dmem_data_r)
111
);
112
 
113
 
114
// CPU
115
cpu_if
116
#(
117
    .CLK_KHZ(CLK_KHZ),
118
    .BOOT_VECTOR(32'h10000000),
119
    .ISR_VECTOR(32'h10000000),
120
    .ENABLE_ICACHE("ENABLED"),
121
    .ENABLE_DCACHE("ENABLED"),
122
    .REGISTER_FILE_TYPE("SIMULATION")
123
)
124
u_cpu
125
(
126
    // General - clocking & reset
127
    .clk_i(clk_i),
128
    .rst_i(rst_i),
129
    .fault_o(fault_o),
130
    .break_o(break_o),
131
    .nmi_i(1'b0),
132
    .intr_i(soc_irq),
133
 
134
    // Instruction Memory 0 (0x10000000 - 0x10FFFFFF)
135
    .imem0_addr_o(imem_addr),
136
    .imem0_rd_o(imem_rd),
137
    .imem0_burst_o(imem_burst),
138
    .imem0_data_in_i(imem_data),
139
    .imem0_accept_i(1'b1),
140
    .imem0_ack_i(imem_ack),
141
 
142
    // Data Memory 0 (0x10000000 - 0x10FFFFFF)
143
    .dmem0_addr_o(dmem_address),
144
    .dmem0_data_o(dmem_data_w),
145
    .dmem0_data_i(dmem_data_r),
146
    .dmem0_wr_o(dmem_wr),
147
    .dmem0_rd_o(dmem_rd),
148
    .dmem0_accept_i(1'b1),
149
    .dmem0_burst_o(dmem_burst),
150
    .dmem0_ack_i(dmem_ack),
151
 
152
    // Data Memory 1 (0x11000000 - 0x11FFFFFF)
153
    .dmem1_addr_o(),
154
    .dmem1_data_o(),
155
    .dmem1_data_i(32'b0),
156
    .dmem1_wr_o(),
157
    .dmem1_rd_o(),
158
    .dmem1_accept_i(1'b1),
159
    .dmem1_burst_o(/*open*/),
160
    .dmem1_ack_i(1'b1),
161
 
162
    // Data Memory 2 (0x12000000 - 0x12FFFFFF)
163
    .dmem2_addr_o(soc_addr),
164
    .dmem2_data_o(soc_data_w),
165
    .dmem2_data_i(soc_data_r),
166
    .dmem2_wr_o(soc_wr),
167
    .dmem2_rd_o(soc_rd),
168
    .dmem2_accept_i(1'b1),
169
    .dmem2_burst_o(/*open*/),
170
    .dmem2_ack_i(1'b1)
171
);
172
 
173
// CPU SOC
174
soc
175
#(
176
    .CLK_KHZ(CLK_KHZ),
177
    .ENABLE_SYSTICK_TIMER("ENABLED"),
178
    .ENABLE_HIGHRES_TIMER("ENABLED"),
179
    .EXTERNAL_INTERRUPTS(1)
180
)
181
u_soc
182
(
183
    // General - clocking & reset
184
    .clk_i(clk_i),
185
    .rst_i(rst_i),
186
    .ext_intr_i(1'b0),
187
    .intr_o(soc_irq),
188
 
189
    // Memory Port
190
    .io_addr_i(soc_addr),
191
    .io_data_i(soc_data_w),
192
    .io_data_o(soc_data_r),
193
    .io_wr_i(soc_wr),
194
    .io_rd_i(soc_rd)
195
);
196
 
197
// Ack
198
always @(posedge clk_i or posedge rst_i)
199
begin
200
    if (rst_i == 1'b1)
201
    begin
202
        imem_req_r  <= 1'b0;
203
    end
204
    else
205
    begin
206
        imem_req_r  <= imem_rd;
207
    end
208
end
209
 
210
assign imem_ack = imem_req_r;
211
 
212
// Ack
213
always @(posedge clk_i or posedge rst_i)
214
begin
215
    if (rst_i == 1'b1)
216
    begin
217
        dmem_req_r  <= 1'b0;
218
    end
219
    else
220
    begin
221
        dmem_req_r  <= dmem_rd | (|dmem_wr);
222
    end
223
end
224
 
225
assign dmem_ack = dmem_req_r;
226
 
227
endmodule

powered by: WebSVN 2.1.0

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