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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sim/] [verilog/] [edk62.v] - Blame information for rev 157

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

Line No. Rev Author Line
1 157 sybreon
/* $Id: edk62.v,v 1.3 2008-05-01 08:33:20 sybreon Exp $
2 138 sybreon
**
3
** AEMB2 EDK 6.2 COMPATIBLE CORE
4
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
20
*/
21
 
22
/**
23
 Simulation Test Bench
24
 @file edk62.v
25
 
26
*/
27
 
28
module edk62();
29 143 sybreon
   localparam AEMB_DWB = 18;
30 138 sybreon
   localparam AEMB_XWB = 5;
31 143 sybreon
   localparam AEMB_IWB = 18;
32 138 sybreon
   localparam AEMB_ICH = 11;
33
   localparam AEMB_IDX = 6;
34
   localparam AEMB_HTX = 1;
35
   localparam AEMB_BSF = 1;
36
   localparam AEMB_MUL = 1;
37
   localparam AEMB_XSL = 1;
38 157 sybreon
   localparam AEMB_DIV = 0;
39
   localparam AEMB_FPU = 0;
40
 
41 138 sybreon
   /*AUTOREGINPUT*/
42
   // Beginning of automatic reg inputs (for undeclared instantiated-module inputs)
43
   reg                  dwb_ack_i;              // To uut of aeMB2_edk62.v
44
   reg                  iwb_ack_i;              // To uut of aeMB2_edk62.v
45
   reg                  sys_clk_i;              // To uut of aeMB2_edk62.v
46
   reg                  sys_ena_i;              // To uut of aeMB2_edk62.v
47 157 sybreon
   reg                  sys_int_i;              // To uut of aeMB2_edk62.v
48 138 sybreon
   reg                  sys_rst_i;              // To uut of aeMB2_edk62.v
49
   reg                  xwb_ack_i;              // To uut of aeMB2_edk62.v
50
   // End of automatics
51
 
52
   always #5 sys_clk_i <= !sys_clk_i;
53
 
54
   initial begin
55
      `ifdef VCD_DUMP
56
      $dumpfile ("dump.vcd");
57 143 sybreon
      $dumpvars (1,uut);
58 138 sybreon
      `endif
59
 
60
      sys_clk_i = 0;
61
      sys_rst_i = 1;
62
      sys_ena_i = 1;
63 157 sybreon
      sys_int_i = 1;
64
 
65 138 sybreon
      xwb_ack_i = 0;
66
 
67
      #50 sys_rst_i = 0;
68 143 sybreon
      #4000000 $displayh("\n*** TIMEOUT ", $stime, " ***"); $finish;
69 138 sybreon
 
70
   end // initial begin
71
 
72
   /*AUTOWIRE*/
73
   // Beginning of automatic wires (for undeclared instantiated-module outputs)
74
   wire [AEMB_DWB-1:2]  dwb_adr_o;              // From uut of aeMB2_edk62.v
75
   wire                 dwb_cyc_o;              // From uut of aeMB2_edk62.v
76
   wire [31:0]           dwb_dat_o;              // From uut of aeMB2_edk62.v
77
   wire [3:0]            dwb_sel_o;              // From uut of aeMB2_edk62.v
78
   wire                 dwb_stb_o;              // From uut of aeMB2_edk62.v
79
   wire                 dwb_tag_o;              // From uut of aeMB2_edk62.v
80
   wire                 dwb_wre_o;              // From uut of aeMB2_edk62.v
81
   wire [AEMB_IWB-1:2]  iwb_adr_o;              // From uut of aeMB2_edk62.v
82
   wire                 iwb_cyc_o;              // From uut of aeMB2_edk62.v
83
   wire [3:0]            iwb_sel_o;              // From uut of aeMB2_edk62.v
84
   wire                 iwb_stb_o;              // From uut of aeMB2_edk62.v
85 157 sybreon
   wire                 iwb_tag_o;              // From uut of aeMB2_edk62.v
86 138 sybreon
   wire                 iwb_wre_o;              // From uut of aeMB2_edk62.v
87
   wire [AEMB_XWB-1:2]  xwb_adr_o;              // From uut of aeMB2_edk62.v
88
   wire                 xwb_cyc_o;              // From uut of aeMB2_edk62.v
89
   wire [31:0]           xwb_dat_o;              // From uut of aeMB2_edk62.v
90
   wire [3:0]            xwb_sel_o;              // From uut of aeMB2_edk62.v
91
   wire                 xwb_stb_o;              // From uut of aeMB2_edk62.v
92
   wire                 xwb_tag_o;              // From uut of aeMB2_edk62.v
93
   wire                 xwb_wre_o;              // From uut of aeMB2_edk62.v
94
   // End of automatics
95
 
96
   // FAKE MEMORY ////////////////////////////////////////////////////////
97
 
98 157 sybreon
   reg [31:0]            rom[0:65535];
99
   reg [31:0]            ram[0:65535];
100
   reg [31:0]            dwblat;
101
   reg [31:0]            xwblat;
102
   reg [31:2]           dadr, iadr;
103 143 sybreon
 
104 157 sybreon
   wire [31:0]           dwb_dat_t = ram[dwb_adr_o];
105
   wire [31:0]           iwb_dat_i = rom[iadr];
106
   wire [31:0]           dwb_dat_i = ram[dadr];
107
   wire [31:0]           xwb_dat_i = xwblat;
108
 
109 138 sybreon
   always @(posedge sys_clk_i)
110
     if (sys_rst_i) begin
111
        /*AUTORESET*/
112
        // Beginning of autoreset for uninitialized flops
113
        dwb_ack_i <= 1'h0;
114
        iwb_ack_i <= 1'h0;
115
        xwb_ack_i <= 1'h0;
116
        // End of automatics
117
     end else begin
118
        iwb_ack_i <= #1 iwb_stb_o & !iwb_ack_i;
119
        dwb_ack_i <= #1 dwb_stb_o & !dwb_ack_i;
120
        xwb_ack_i <= #1 xwb_stb_o & !xwb_ack_i;
121
     end // else: !if(sys_rst_i)
122
 
123
   always @(posedge sys_clk_i) begin
124
      iadr <= #1 iwb_adr_o;
125
      dadr <= #1 dwb_adr_o;
126
 
127 143 sybreon
      if (xwb_wre_o & xwb_stb_o & xwb_ack_i) begin
128
         xwblat <= #1 xwb_dat_o;
129
      end
130
 
131 138 sybreon
      // SPECIAL PORTS
132
      if (dwb_wre_o & dwb_stb_o & dwb_ack_i) begin
133
         case ({dwb_adr_o,2'o0})
134
           32'hFFFFFFD0: $displayh(dwb_dat_o);
135 157 sybreon
           32'hFFFFFFC0: $write("%c",dwb_dat_o[31:24]);
136
           32'hFFFFFFE0: sys_int_i <= #1 !sys_int_i;
137 138 sybreon
         endcase // case ({dwb_adr_o,2'o0})
138
 
139
         case (dwb_sel_o)
140
           4'h1: ram[dwb_adr_o] <= {dwb_dat_t[31:8], dwb_dat_o[7:0]};
141
           4'h2: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:8], dwb_dat_t[7:0]};
142
           4'h4: ram[dwb_adr_o] <= {dwb_dat_t[31:24], dwb_dat_o[23:16], dwb_dat_t[15:0]};
143
           4'h8: ram[dwb_adr_o] <= {dwb_dat_o[31:24], dwb_dat_t[23:0]};
144
           4'h3: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:0]};
145
           4'hC: ram[dwb_adr_o] <= {dwb_dat_o[31:16], dwb_dat_t[15:0]};
146
           4'hF: ram[dwb_adr_o] <= {dwb_dat_o};
147
           default: begin
148 143 sybreon
              $displayh("\n*** INVALID WRITE ",{dwb_adr_o,2'o0}, " ***");
149 138 sybreon
              $finish;
150
           end
151
         endcase // case (dwb_sel_o)
152
      end // if (dwb_wre_o & dwb_stb_o & dwb_ack_i)
153
 
154
      if (dwb_stb_o & !dwb_wre_o & dwb_ack_i) begin
155
         case (dwb_sel_o)
156
           4'h1,4'h2,4'h4,4'h8,4'h3,4'hC,4'hF: begin
157
           end
158
           default: begin
159 143 sybreon
              $displayh("\n*** INVALID READ ",{dwb_adr_o,2'd0}, " ***");
160 138 sybreon
              $finish;
161
           end
162
         endcase // case (dwb_sel_o)     
163
      end
164
 
165
   end // always @ (posedge sys_clk_i)
166
 
167
   integer i;
168
   initial begin
169
      for (i=0;i<65535;i=i+1) begin
170
         ram[i] <= $random;
171
      end
172
      #1 $readmemh("dump.vmem",rom);
173
      #1 $readmemh("dump.vmem",ram);
174
   end
175
 
176
   // DUMP CYCLES   
177
   always @(posedge sys_clk_i)
178
     if (uut.dena) begin
179
     //begin
180
`ifdef AEMB2_SIM_KERNEL
181
        $displayh("TME=",($stime/10),
182
                  ",PHA=",uut.gpha,
183
                  ",IWB=",{uut.rpc_if,2'o0},
184
                  ",ASM=",uut.ich_dat,
185
                  ",OPA=",uut.opa_of,
186
                  ",OPB=",uut.opb_of,
187
                  ",OPD=",uut.opd_of,
188
                  ",MSR=",uut.msr_ex,
189
                  ",MEM=",{uut.mem_ex,2'o0},
190
                  ",BRA=",uut.bra_ex,
191
                  ",BPC=",{uut.bpc_ex,2'o0},
192
                  ",MUX=",uut.mux_ex,
193
                  ",ALU=",uut.alu_mx,
194
                  //",WRE=",dwb_wre_o,
195
                  ",SEL=",dwb_sel_o,
196
                  //",DWB=",dwb_dat_o,
197 143 sybreon
                  ",REG=",uut.regs0.gprf0.wRW0,
198 138 sybreon
                  //",DAT=",uut.regs0.gprf0.regd,
199
                  ",MUL=",uut.mul_mx,
200
                  ",BSF=",uut.bsf_mx,
201
                  ",DWB=",uut.dwb_mx,
202
                  ",LNK=",{uut.rpc_mx,2'o0},
203
                  ",SFR=",uut.sfr_mx,
204
                  ",E"
205
                  );
206
`endif
207
        if (uut.ich_dat == 32'hB8000000) begin
208 143 sybreon
           $displayh("\n*** EXIT ", $stime, " ***");
209 138 sybreon
           $finish;
210
        end
211
     end // if (uut.dena)
212
 
213
   aeMB2_edk62
214
     #(/*AUTOINSTPARAM*/
215
       // Parameters
216
       .AEMB_IWB                        (AEMB_IWB),
217
       .AEMB_DWB                        (AEMB_DWB),
218
       .AEMB_XWB                        (AEMB_XWB),
219
       .AEMB_ICH                        (AEMB_ICH),
220
       .AEMB_IDX                        (AEMB_IDX),
221
       .AEMB_BSF                        (AEMB_BSF),
222
       .AEMB_MUL                        (AEMB_MUL),
223 157 sybreon
       .AEMB_DIV                        (AEMB_DIV),
224
       .AEMB_FPU                        (AEMB_FPU))
225 138 sybreon
   uut
226
     (/*AUTOINST*/
227
      // Outputs
228
      .dwb_adr_o                        (dwb_adr_o[AEMB_DWB-1:2]),
229
      .dwb_cyc_o                        (dwb_cyc_o),
230
      .dwb_dat_o                        (dwb_dat_o[31:0]),
231
      .dwb_sel_o                        (dwb_sel_o[3:0]),
232
      .dwb_stb_o                        (dwb_stb_o),
233
      .dwb_tag_o                        (dwb_tag_o),
234
      .dwb_wre_o                        (dwb_wre_o),
235
      .iwb_adr_o                        (iwb_adr_o[AEMB_IWB-1:2]),
236
      .iwb_cyc_o                        (iwb_cyc_o),
237
      .iwb_sel_o                        (iwb_sel_o[3:0]),
238
      .iwb_stb_o                        (iwb_stb_o),
239 157 sybreon
      .iwb_tag_o                        (iwb_tag_o),
240 138 sybreon
      .iwb_wre_o                        (iwb_wre_o),
241
      .xwb_adr_o                        (xwb_adr_o[AEMB_XWB-1:2]),
242
      .xwb_cyc_o                        (xwb_cyc_o),
243
      .xwb_dat_o                        (xwb_dat_o[31:0]),
244
      .xwb_sel_o                        (xwb_sel_o[3:0]),
245
      .xwb_stb_o                        (xwb_stb_o),
246
      .xwb_tag_o                        (xwb_tag_o),
247
      .xwb_wre_o                        (xwb_wre_o),
248
      // Inputs
249
      .dwb_ack_i                        (dwb_ack_i),
250
      .dwb_dat_i                        (dwb_dat_i[31:0]),
251
      .iwb_ack_i                        (iwb_ack_i),
252
      .iwb_dat_i                        (iwb_dat_i[31:0]),
253
      .sys_clk_i                        (sys_clk_i),
254
      .sys_ena_i                        (sys_ena_i),
255 157 sybreon
      .sys_int_i                        (sys_int_i),
256 138 sybreon
      .sys_rst_i                        (sys_rst_i),
257
      .xwb_ack_i                        (xwb_ack_i),
258
      .xwb_dat_i                        (xwb_dat_i[31:0]));
259
 
260
endmodule // edk62
261
 
262
// $Log: not supported by cvs2svn $
263 157 sybreon
// Revision 1.2  2008/04/27 16:28:19  sybreon
264
// Fixed minor typos.
265
//
266 143 sybreon
// Revision 1.1  2008/04/26 18:09:16  sybreon
267
// initial import
268
//
269 138 sybreon
 
270
// Local Variables:
271
// verilog-library-directories:("." "../../rtl/verilog/")
272
// verilog-library-files:("")
273
// End:

powered by: WebSVN 2.1.0

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