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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [system/] [boot_mem128.v] - Blame information for rev 76

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

Line No. Rev Author Line
1 2 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  8KBytes SRAM configured with boot software                  //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Holds just enough software to get the system going.         //
10
//  The boot loader fits into this 8KB embedded SRAM on the     //
11
//  FPGA and enables it to load large applications via the      //
12
//  serial port (UART) into the DDR3 memory                     //
13
//                                                              //
14
//  Author(s):                                                  //
15
//      - Conor Santifort, csantifort.amber@gmail.com           //
16
//                                                              //
17
//////////////////////////////////////////////////////////////////
18
//                                                              //
19
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
20
//                                                              //
21
// This source file may be used and distributed without         //
22
// restriction provided that this copyright statement is not    //
23
// removed from the file and that any derivative work contains  //
24
// the original copyright notice and the associated disclaimer. //
25
//                                                              //
26
// This source file is free software; you can redistribute it   //
27
// and/or modify it under the terms of the GNU Lesser General   //
28
// Public License as published by the Free Software Foundation; //
29
// either version 2.1 of the License, or (at your option) any   //
30
// later version.                                               //
31
//                                                              //
32
// This source is distributed in the hope that it will be       //
33
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
34
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
35
// PURPOSE.  See the GNU Lesser General Public License for more //
36
// details.                                                     //
37
//                                                              //
38
// You should have received a copy of the GNU Lesser General    //
39
// Public License along with this source; if not, download it   //
40
// from http://www.opencores.org/lgpl.shtml                     //
41
//                                                              //
42
//////////////////////////////////////////////////////////////////
43
 
44
 
45 36 csantifort
module boot_mem128 #(
46
parameter WB_DWIDTH   = 128,
47
parameter WB_SWIDTH   = 16,
48 61 csantifort
parameter MADDR_WIDTH = 10
49 35 csantifort
)(
50 2 csantifort
input                       i_wb_clk,     // WISHBONE clock
51
 
52
input       [31:0]          i_wb_adr,
53 35 csantifort
input       [WB_SWIDTH-1:0] i_wb_sel,
54 2 csantifort
input                       i_wb_we,
55 35 csantifort
output      [WB_DWIDTH-1:0] o_wb_dat,
56
input       [WB_DWIDTH-1:0] i_wb_dat,
57 2 csantifort
input                       i_wb_cyc,
58
input                       i_wb_stb,
59
output                      o_wb_ack,
60
output                      o_wb_err
61
 
62
);
63
 
64
 
65 36 csantifort
wire                    start_write;
66
wire                    start_read;
67
wire [WB_DWIDTH-1:0]    read_data;
68
wire [WB_DWIDTH-1:0]    write_data;
69
wire [WB_SWIDTH-1:0]    byte_enable;
70
wire [MADDR_WIDTH-1:0]  address;
71 35 csantifort
 
72 40 csantifort
`ifdef AMBER_WISHBONE_DEBUG
73
    reg  [7:0]              jitter_r = 8'h0f;
74
    reg  [1:0]              start_read_r = 'd0;
75
`else
76
    reg                     start_read_r = 'd0;
77
`endif
78 36 csantifort
 
79 2 csantifort
// Can't start a write while a read is completing. The ack for the read cycle
80
// needs to be sent first
81 40 csantifort
`ifdef AMBER_WISHBONE_DEBUG
82
    assign start_write = i_wb_stb &&  i_wb_we && !(|start_read_r) && jitter_r[0];
83
`else
84
    assign start_write = i_wb_stb &&  i_wb_we && !(|start_read_r);
85
`endif
86
assign start_read  = i_wb_stb && !i_wb_we && !(|start_read_r);
87 2 csantifort
 
88 40 csantifort
`ifdef AMBER_WISHBONE_DEBUG
89
    always @( posedge i_wb_clk )
90
        jitter_r <= {jitter_r[6:0], jitter_r[7] ^ jitter_r[4] ^ jitter_r[1]};
91
 
92
    always @( posedge i_wb_clk )
93
        if (start_read)
94
            start_read_r <= {3'd0, start_read};
95
        else if (o_wb_ack)
96
            start_read_r <= 'd0;
97
        else
98
            start_read_r <= {start_read_r[2:0], start_read};
99
`else
100
    always @( posedge i_wb_clk )
101
        start_read_r <= start_read;
102
`endif
103 2 csantifort
 
104
assign o_wb_err = 1'd0;
105
 
106 36 csantifort
assign write_data  = i_wb_dat;
107
assign byte_enable = i_wb_sel;
108
assign o_wb_dat    = read_data;
109
assign address     = i_wb_adr[MADDR_WIDTH+3:4];
110 35 csantifort
 
111 40 csantifort
`ifdef AMBER_WISHBONE_DEBUG
112
    assign o_wb_ack    = i_wb_stb && ( start_write || start_read_r[jitter_r[1]] );
113
`else
114
    assign o_wb_ack    = i_wb_stb && ( start_write || start_read_r );
115
`endif
116 35 csantifort
 
117 40 csantifort
 
118 2 csantifort
// ------------------------------------------------------
119
// Instantiate SRAMs
120
// ------------------------------------------------------
121
//         
122
`ifdef XILINX_FPGA
123
 
124 61 csantifort
    xs6_sram_1024x128_byte_en
125 2 csantifort
 
126
#(
127
// This file holds a software image used for FPGA simulations
128
// This pre-processor syntax works with both the simulator
129
// and ISE, which I couldn't get to work with giving it the
130
// file name as a define.
131
 
132
`ifdef BOOT_MEM_PARAMS_FILE
133
    `include `BOOT_MEM_PARAMS_FILE
134
`else
135 61 csantifort
    `ifdef BOOT_LOADER_ETHMAC
136
        `include "boot-loader-ethmac_memparams128.v"
137
    `else
138
        // default file
139
        `include "boot-loader_memparams128.v"
140
    `endif
141 2 csantifort
`endif
142
 
143
)
144
`endif
145
 
146
`ifndef XILINX_FPGA
147
generic_sram_byte_en
148
#(
149 36 csantifort
    .DATA_WIDTH     ( WB_DWIDTH         ),
150
    .ADDRESS_WIDTH  ( MADDR_WIDTH       )
151 2 csantifort
)
152
`endif
153
u_mem (
154 36 csantifort
    .i_clk          ( i_wb_clk          ),
155
    .i_write_enable ( start_write       ),
156
    .i_byte_enable  ( byte_enable       ),
157 61 csantifort
    .i_address      ( address           ),  // 1024 words, 128 bits
158 36 csantifort
    .o_read_data    ( read_data         ),
159
    .i_write_data   ( write_data        )
160 2 csantifort
);
161
 
162
 
163
// =======================================================================================
164
// =======================================================================================
165
// =======================================================================================
166
// Non-synthesizable debug code
167
// =======================================================================================
168
 
169
 
170
//synopsys translate_off
171
`ifdef XILINX_SPARTAN6_FPGA
172
    `ifdef BOOT_MEM_PARAMS_FILE
173
        initial
174
            $display("Boot mem file is %s", `BOOT_MEM_PARAMS_FILE );
175
    `endif
176
`endif
177
//synopsys translate_on
178
 
179
endmodule
180
 
181
 
182
 

powered by: WebSVN 2.1.0

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