Top level Atosm chip and its initial firmware
[AtosmChip.git] / memory_tb.v
blob1ab14624ebf01b137a0e9ecc872a8e5216f12df7
1 // Atosm Chip
2 // Copyright (C) 2008 Tomasz Malesinski <tmal@mimuw.edu.pl>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 `include "memory.v"
20 module ram_tb();
21 reg clk_o;
22 reg [15:0] adr_o;
23 reg [7:0] dat_o;
24 reg rst_o;
25 reg stb_o;
26 reg we_o;
28 wire ack_i;
29 wire [7:0] dat_i;
31 initial begin
32 $readmemh("rom.list", u_memory.u_rom.memory);
34 $display("time\t clk rst stb we adr do di");
35 $monitor("%g\t %b %b %b %b %b %b %b",
36 $time, clk_o, rst_o, stb_o, we_o, adr_o, dat_o, dat_i);
37 clk_o = 1;
38 rst_o = 0;
39 stb_o = 0;
40 we_o = 0;
41 #5 rst_o = 1;
43 #10 rst_o = 0;
44 we_o = 1;
45 stb_o = 1;
46 adr_o = 'h10;
47 dat_o = 'h55;
49 #10 adr_o = 'h20;
50 dat_o = 'haa;
52 #10 we_o = 0;
53 adr_o = 'h10;
55 #10 adr_o = 'h20;
57 #10 adr_o = 'hfc00;
58 #10 adr_o = 'hfc01;
59 #10 adr_o = 'hfc02;
60 #10 adr_o = 'hfc03;
61 #10 adr_o = 'hfc04;
63 #10 $finish;
64 end
66 always begin
67 #5 clk_o = ~clk_o;
68 end
70 memory u_memory(.clk_i(clk_o),
71 .adr_i(adr_o),
72 .dat_i(dat_o),
73 .rst_i(rst_o),
74 .stb_i(stb_o),
75 .we_i(we_o),
76 .ack_o(ack_i),
77 .dat_o(dat_i));
79 endmodule // ram_tb