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

Subversion Repositories ae18

[/] [ae18/] [trunk/] [sim/] [verilog/] [testbench.v] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 sybreon
/*
2
 * $Id: testbench.v,v 1.1 2007-04-13 22:18:52 sybreon Exp $
3
 *
4
 * AE18 Core Simulation Testbench
5
 * Copyright (C) 2006-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
6
 *
7
 * This library is free software; you can redistribute it and/or modify it
8
 * under the terms of the GNU Lesser General Public License as published by
9
 * the Free Software Foundation; either version 2.1 of the License,
10
 * or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
 * USA
21
 *
22
 * DESCRIPTION
23
 * Simple unit test with fake ROM and fake RAM contents. It loads the ROM
24
 * from the ae18_core.rom file.
25
 *
26
 * HISTORY
27
 * $Log: not supported by cvs2svn $
28
 * Revision 1.3  2007/04/03 22:10:52  sybreon
29
 * Minor simulation changes.
30
 *
31
 * Revision 1.2  2006/12/29 18:08:11  sybreon
32
 * Minor clean up
33
 *
34
 */
35
 
36
module tb (/*AUTOARG*/);
37
   parameter ISIZ = 16;
38
   parameter DSIZ = 16;
39
 
40
   wire [ISIZ-1:0] iwb_adr_o;
41
   wire [DSIZ-1:0] dwb_adr_o;
42
   wire [7:0]       dwb_dat_o;
43
   wire [7:0]       dwb_dat_i;
44
   wire [15:0]      iwb_dat_o;
45
   wire [1:0]       iwb_sel_o;
46
   wire            iwb_stb_o, iwb_we_o, dwb_stb_o, dwb_we_o;
47
   wire [1:0]       qfsm_o, qmod_o;
48
   wire [3:0]       qena_o;
49
 
50
   reg             clk_i, rst_i;
51
   reg [1:0]        int_i;
52
   reg [7:6]       inte_i;
53
   reg             dwb_ack_i, iwb_ack_i;
54
   reg [15:0]       iwb_dat_i;
55
 
56
   // Log File
57
   integer         fileno;
58
   initial begin
59
      //fileno = $fopen ("ae18_core.log");      
60
   end
61
 
62
   // Dump Files
63
   initial begin
64
      $dumpfile("ae18_core.vcd");
65
      $dumpvars(1, iwb_adr_o,iwb_dat_i,iwb_stb_o,iwb_we_o,iwb_sel_o);
66
      $dumpvars(1, dwb_adr_o,dwb_dat_i,dwb_dat_o,dwb_we_o,dwb_stb_o);
67
      $dumpvars(1, clk_i,int_i,wb_rst_o);
68
      //$dumpvars(1, dut);      
69
   end
70
 
71
   initial begin
72
      clk_i = 0;
73
      rst_i = 0;
74
      int_i = 2'b00;
75
 
76
      #50 rst_i = 1;
77
      #30000 int_i = 2'b10;
78
      #50 int_i = 2'b00;
79
   end
80
 
81
   // Test Points
82
   initial fork
83
      #80000
84
        $finish;
85
   join
86
 
87
   always #5 clk_i = ~clk_i;
88
 
89
   reg [15:0]  rom [0:65535];
90
 
91
   // Fake Memory Signals
92
   always @(posedge clk_i) begin
93
      iwb_ack_i <= iwb_stb_o;
94
      if (iwb_stb_o) iwb_dat_i <= rom[iwb_adr_o[ISIZ-1:1]];
95
   end
96
 
97
   reg [DSIZ-1:0] dadr;
98
   reg [7:0] ram [(1<<DSIZ)-1:0];
99
 
100
   assign    dwb_dat_i = ram[dadr];
101
   always @(posedge clk_i) begin
102
      dwb_ack_i <= dwb_stb_o;
103
      dadr <= dwb_adr_o;
104
      if (dwb_we_o & dwb_stb_o)
105
        ram[dwb_adr_o] <= dwb_dat_o;
106
   end
107
 
108
   // Load ROM contents
109
   integer     i;
110
   initial begin
111
      for (i=0;i<65536;i=i+1) rom[i] <= 0;
112
      for (i=0;i<65536;i=i+1) ram[i] <= $random;
113
      #1 $readmemh ("ae18_core.rom", rom);
114
   end
115
 
116
   // LOG
117
   always @(negedge clk_i) begin
118
      $write("\nT:",$stime);
119
      if (iwb_stb_o & iwb_ack_i & !iwb_we_o & dut.rQCLK[0])
120
        $writeh("\tIWB:0x",iwb_adr_o,"=0x",iwb_dat_i);
121
   end
122
 
123
   // AE18 test core   
124
   ae18_core #(ISIZ,DSIZ,32)
125
     dut (/*AUTOINST*/
126
          // Outputs
127
          .wb_clk_o                     (wb_clk_o),
128
          .wb_rst_o                     (wb_rst_o),
129
          .iwb_adr_o                    (iwb_adr_o[ISIZ-1:0]),
130
          .iwb_dat_o                    (iwb_dat_o[15:0]),
131
          .iwb_stb_o                    (iwb_stb_o),
132
          .iwb_we_o                     (iwb_we_o),
133
          .iwb_sel_o                    (iwb_sel_o[1:0]),
134
          .dwb_adr_o                    (dwb_adr_o[DSIZ-1:0]),
135
          .dwb_dat_o                    (dwb_dat_o[7:0]),
136
          .dwb_stb_o                    (dwb_stb_o),
137
          .dwb_we_o                     (dwb_we_o),
138
          // Inputs
139
          .iwb_dat_i                    (iwb_dat_i[15:0]),
140
          .iwb_ack_i                    (iwb_ack_i),
141
          .dwb_dat_i                    (dwb_dat_i[7:0]),
142
          .dwb_ack_i                    (dwb_ack_i),
143
          .int_i                        (int_i[1:0]),
144
          .inte_i                       (inte_i[7:6]),
145
          .clk_i                        (clk_i),
146
          .rst_i                        (rst_i));
147
 
148
endmodule // ae18_core_tb
149
 
150
// Local Variables:
151
// verilog-library-directories:("." "../../rtl/verilog/")
152
// End:

powered by: WebSVN 2.1.0

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