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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [rtl/] [sp3dk_simulator.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 toni32
/*      MODULE: openfire simulator
2
        DESCRIPTION: Contains top-level simulator of the Openfire SOC
3
 
4
AUTHOR:
5
Antonio J. Anton
6
Anro Ingenieros (www.anro-ingenieros.com)
7
aj@anro-ingenieros.com
8
 
9
REVISION HISTORY:
10
Revision 1.0, 26/03/2007
11
Initial release
12
 
13
COPYRIGHT:
14
Copyright (c) 2007 Antonio J. Anton
15
 
16
Permission is hereby granted, free of charge, to any person obtaining a copy of
17
this software and associated documentation files (the "Software"), to deal in
18
the Software without restriction, including without limitation the rights to
19
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
20
of the Software, and to permit persons to whom the Software is furnished to do
21
so, subject to the following conditions:
22
 
23
The above copyright notice and this permission notice shall be included in all
24
copies or substantial portions of the Software.
25
 
26
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
SOFTWARE.*/
33
 
34
`timescale 1ns / 1ps
35
`include "openfire_define.v"
36
 
37
module sp3dk_simulator();
38
 
39
reg                             clk;
40
reg                             rst;
41
 
42
`ifdef SP3SK_USERIO
43
reg     [7:0]            switches;
44
reg     [3:0]            pushbuttons;
45
wire    [7:0]            leds;
46
wire    [3:0]            drivers_n;
47
wire    [7:0]            segments_n;
48
`endif
49
`ifdef UART1_ENABLE
50
wire                            tx1;
51
reg                             rx1;
52
`endif
53
`ifdef UART2_ENABLE
54
wire                            tx2;
55
reg                             rx2;
56
`endif
57
`ifdef SP3SK_PROM_DATA
58
reg                             prom_din;
59
wire                            prom_cclk;
60
wire                            prom_reset_n;
61
`endif
62
`ifdef SP3SK_SRAM
63
wire    [17:0]   ram_addr;               // SRAM ADDR (256K @)
64
wire                            ram_oe_n;               // OE_N shared by 2 IC
65
wire                            ram_we_n;               //      WE_N shared by 2 IC
66
wire    [15:0]   ram1_io;                        //      I/O data port SRAM1
67
wire                            ram1_ce_n;              // SRAM1 CE_N   chip enable
68
wire                            ram1_ub_n;              // UB_N upper byte select
69
wire                            ram1_lb_n;              // LB_N  lower byte select
70
wire    [15:0]   ram2_io;                        //      I/O data port SRAM2
71
wire                            ram2_ce_n;              // SRAM2 CE_N   chip enable
72
wire                            ram2_ub_n;              // UB_N upper byte select
73
wire                            ram2_lb_n;              // LB_N  lower byte select`endif
74
`endif
75
`ifdef SP3SK_VGA
76
wire                            r, g, b;                        // VGA components (1 bit per component)
77
wire                            hsync_n;                        // VGA hsync_n
78
wire                            vsync_n;                        // VGA vsync_n
79
`endif
80
 
81
// --- simulation statments ---
82
// Toggle clock every time unit
83
always #20 clk = ~clk;
84
 
85
`define TIMEOUT         1000000
86
initial begin
87
`ifdef SP3SK_USERIO
88
        pushbuttons <= 0;
89
        switches           <= 0;
90
`endif
91
        clk   = 1;
92
        rst   = 1;      // reset the processor (active high)
93
 
94
`ifdef UART1_ENABLE
95
        rx1     = 1;
96
`endif
97
`ifdef UART2_ENABLE
98
        rx2   = 1;
99
`endif
100
`ifdef SP3SK_PROM_DATA
101
        prom_din = 1;
102
`endif
103
 
104
        #70 rst = 0;
105
        #`TIMEOUT;
106
        //$finish;      // finish after TIMEOUT
107
end
108
 
109
// ---------- device under test ----------
110
openfire_soc DUT(
111
`ifndef SP3SK_USERIO
112
   .rst( rst ),
113
`endif
114
`ifdef SP3SK_USERIO
115
        .leds( leds ),
116
        .drivers_n( drivers_n ),
117
        .segments_n( segments_n ),
118
        .pushbuttons( {rst, pushbuttons[2:0]} ),                 // 3rd push button is the RESET
119
        .switches( switches ),
120
`endif
121
`ifdef SP3SK_SRAM
122
        .ram_addr(ram_addr), .ram_oe_n(ram_oe_n),   .ram_we_n(ram_we_n),
123
        .ram1_io(ram1_io),   .ram1_ce_n(ram1_ce_n), .ram1_ub_n(ram1_ub_n), .ram1_lb_n(ram1_lb_n),
124
        .ram2_io(ram2_io),   .ram2_ce_n(ram2_ce_n), .ram2_ub_n(ram2_ub_n), .ram2_lb_n(ram2_lb_n),
125
`endif
126
`ifdef UART1_ENABLE
127
        .tx1(tx1), .rx1(rx1),
128
`endif
129
`ifdef UART2_ENABLE
130
        .tx2(tx2), .rx2(rx2),
131
`endif
132
`ifdef SP3SK_PROM_DATA
133
        .prom_din(prom_din), .prom_cclk(prom_cclk), .prom_reset_n(prom_reset_n),
134
`endif
135
`ifdef SP3SK_VGA
136
        .r(r), .g(g), .b(b),
137
        .hsync_n(hsync_n), .vsync_n(vsync_n),
138
`endif
139
        .clk_50mhz( clk )
140
);
141
 
142
`ifdef SP3SK_SRAM                       // used as a whole 256Kx32
143
SRAM256KX16 sram1(              // 256K x 16 #1
144
        .ce_n(ram1_ce_n), .we_n(ram_we_n), .oe_n(ram_oe_n),
145
        .ub_n(ram1_ub_n), .lb_n(ram1_lb_n), .addr(ram_addr),
146
        .io(ram1_io)
147
);
148
SRAM256KX16 sram2(              // 256K x 16 #2
149
        .ce_n(ram2_ce_n), .we_n(ram_we_n), .oe_n(ram_oe_n),
150
        .ub_n(ram2_ub_n), .lb_n(ram2_lb_n), .addr(ram_addr),
151
        .io(ram2_io)
152
);
153
 
154
// ---- load program/data in external SRAM -----------
155
`ifdef DEBUG_FILE_SRAM
156
reg     [31:0] addr;
157
reg     [31:0] memory[`MAX_SIMULATION_SRAM];     // temporary load here
158
reg     [31:0] word;
159
 
160
initial begin
161
  #1                    // wait SRAM initialization
162
  $display("Loading ROM file...");      // file should be rows of 32 bit hex dump (in ascii)
163
  $readmemh(`DEBUG_FILE_SRAM, memory);
164
  $display("File loaded");
165
 
166
  $display("Populating SRAM...");
167
  addr = 0;
168
  word = memory[0];
169
  while( addr < `MAX_SIMULATION_SRAM && word !== 32'bX )        // populate only until
170
  begin                                                                         // the end of valid data
171
   word = memory[addr];
172
        sram1.memh[addr] = word[31:24];
173
        sram1.meml[addr] = word[23:16];
174
        sram2.memh[addr] = word[15:8];
175
        sram2.meml[addr] = word[7:0];
176
        // $display(" SRAM[%x]=%x", addr, word);
177
        addr = addr + 1;
178
  end
179
  $display("SRAM Populated with %d bytes", addr * 4);
180
end
181
`endif
182
 
183
`endif
184
 
185
endmodule

powered by: WebSVN 2.1.0

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