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

Subversion Repositories thor

[/] [thor/] [trunk/] [bench/] [bootrom.v] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2012-2013  Robert Finch, Stratford
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@opencores.org
7
//       ||
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//
22
// ============================================================================
23
//
24
module bootrom(rst_i, clk_i, cti_i, cyc_i, stb_i, ack_o, adr_i, dat_o, perr);
25
parameter DBW=64;
26
parameter MAGIC1=32'hAAAAAAAA;
27
parameter MAGIC2=32'h55555555;
28
input rst_i;
29
input clk_i;
30
input [2:0] cti_i;
31
input cyc_i;
32
input stb_i;
33
output ack_o;
34
input [31:0] adr_i;
35
output [DBW-1:0] dat_o;
36
reg [DBW-1:0] dat_o;
37
output perr;
38
reg perr;
39
 
40
wire ne_cs;
41
wire cs;
42
reg ack0,ack1,ack2,ack3;
43
always @(posedge clk_i)
44
begin
45
        if (ne_cs)
46
                ack0 <= cs;
47
        else if (!cs)
48
                ack0 <= 1'b0;
49
        ack1 <= ack0 & cs;
50
        ack2 <= ack1 & cs;
51
        ack3 <= ack2 & cs;
52
end
53
assign cs = cyc_i && stb_i && adr_i[31:16]==16'hFFFF;
54
assign ack_o = cs & ack0;
55
 
56
reg [DBW:0] rommem0 [0:8191];
57
reg [DBW:0] rommem1 [0:8191];
58
reg [DBW:0] rommem2 [0:8191];
59
initial begin
60
if (DBW==32) begin
61
`include "..\..\software\A64\bin\boot.ve0"
62
`include "..\..\software\A64\bin\boot.ve1"
63
`include "..\..\software\A64\bin\boot.ve2"
64
end
65
else begin
66
`include "..\..\software\a64\bin\boot.ve0"
67
`include "..\..\software\A64\bin\boot.ve1"
68
`include "..\..\software\A64\bin\boot.ve2"
69
end
70
end
71
 
72
wire pe_cs;
73
edge_det u1 (.rst(rst_i), .clk(clk_i), .ce(1'b1), .i(cs), .pe(pe_cs), .ne(), .ee());
74
edge_det u2 (.rst(rst_i), .clk(clk_i), .ce(1'b1), .i(pe_cs), .pe(), .ne(ne_cs), .ee());
75
 
76
reg [14:2] radr;
77
reg [14:2] ctr;
78
 
79
always @(posedge clk_i)
80
        if (pe_cs) begin
81
                if (DBW==32)
82
                        ctr <= adr_i[14:2] + 13'd1;
83
                else
84
                        ctr <= adr_i[14:3] + 13'd1;
85
        end
86
        else if (cs)
87
                ctr <= ctr + 13'd1;
88
 
89
always @(posedge clk_i)
90
        if (DBW==32)
91
                radr <= pe_cs ? adr_i[14:2] : ctr;
92
        else
93
                radr <= pe_cs ? adr_i[14:3] : ctr;
94
 
95
wire [31:0] d0 = rommem0[radr][DBW-1:0];
96
wire [31:0] d1 = rommem1[radr][DBW-1:0]^MAGIC1;
97
wire [31:0] d2 = rommem2[radr][DBW-1:0]^MAGIC2;
98
wire [31:0] d4 = (d0&d1)|(d0&d2)|(d1&d2);
99
 
100
always @(posedge clk_i)
101
        if (cs) begin
102
                dat_o <= d4;
103
                $display("br read: %h %h", radr,d4);
104
        end
105
        else
106
                dat_o <= {DBW{1'b0}};
107
 
108
always @(posedge clk_i)
109
        if (cs)
110
                perr <= ^rommem0[radr][DBW-1:0]!=rommem0[radr][DBW];
111
        else
112
                perr <= 1'd0;
113
 
114
endmodule

powered by: WebSVN 2.1.0

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