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

Subversion Repositories aemb

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

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

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

powered by: WebSVN 2.1.0

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