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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [rtl/] [verilog/] [rtf65002_tb.v] - Blame information for rev 35

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

Line No. Rev Author Line
1 5 robfinch
module rtf65002_tb();
2
 
3
integer n;
4
reg rst;
5
reg clk;
6
reg nmi;
7
wire wr;
8
wire [5:0] bl;
9
wire [3:0] sel;
10
wire [33:0] a;
11
tri [31:0] d;
12
wire [31:0] dato;
13
wire [31:0] dati;
14 20 robfinch
wire [2:0] cti;
15 5 robfinch
wire cyc;
16
wire stb;
17
wire ack;
18
wire [7:0] udo;
19 20 robfinch
wire btrm_ack;
20
wire [31:0] btrm_dato;
21 5 robfinch
 
22
initial begin
23
        clk = 1;
24
        rst = 0;
25
        nmi = 0;
26
        #100 rst = 1;
27
        #100 rst = 0;
28
        #500 nmi = 1;
29
        #10 nmi = 0;
30
end
31
 
32
always #1 clk = ~clk;   // 500 MHz
33
 
34
rtf65002d cpu0 (
35
        .rst_i(rst),
36
        .clk_i(clk),
37
        .nmi_i(nmi),
38
        .irq_i(1'b0),
39
        .bte_o(),
40 20 robfinch
        .cti_o(cti),
41 5 robfinch
        .bl_o(bl),
42
        .lock_o(),
43
        .cyc_o(cyc),
44
        .stb_o(stb),
45 20 robfinch
        .ack_i(ack),
46 5 robfinch
        .we_o(wr),
47
        .sel_o(sel),
48
        .adr_o(a),
49
        .dat_i(dati),
50
        .dat_o(dato)
51
);
52
 
53
wire uartcs = cyc && stb && a[33:8]==26'h00000CF;
54
wire romcs = ~(cyc && stb && a[33:28]==6'h0F);
55 20 robfinch
wire ramcs = ~(cyc && stb && (a[33:15]==19'h00 || (a[33:28]!=6'hF && a[33:28]!=6'h0)));
56 5 robfinch
wire romcs1 = ~(cyc && stb && a[33:13]==21'h07);        // E000
57
 
58
assign d = wr ? dato : 32'bz;
59 20 robfinch
assign dati = ~romcs ? btrm_dato : 32'bz;
60 5 robfinch
assign dati = ~ramcs ? d : 32'bz;
61
assign dati = uartcs ? {4{udo}} : 32'bz;
62
assign dati = ~romcs1 ? d : 32'bz;
63
 
64 20 robfinch
assign ack =
65
        btrm_ack |
66
        ~ramcs |
67
        ~romcs1 |
68
        uartcs
69
        ;
70
 
71
//rom2Kx32 #(.MEMFILE("t65c.mem")) rom0(.ce(romcs), .oe(wr), .addr(a[12:2]), .d(d));
72 5 robfinch
rom2Kx32 #(.MEMFILE("t65c.mem")) rom1(.ce(romcs1), .oe(wr), .addr(a[12:2]), .d(d));
73
ram8Kx32 ram0 (.clk(clk), .ce(ramcs), .oe(wr), .we(~wr), .sel(sel), .addr(a[14:2]), .d(d));
74
uart uart0(.clk(clk), .cs(uartcs), .wr(wr), .a(a[2:0]), .di(dato[7:0]), .do(udo));
75 20 robfinch
bootrom ubr1 (.rst_i(rst), .clk_i(clk), .cti_i(cti), .cyc_i(cyc), .stb_i(stb), .ack_o(btrm_ack), .adr_i(a), .dat_o(btrm_dato), .perr());
76 5 robfinch
 
77
always @(posedge clk) begin
78
        if (rst)
79
                n = 0;
80
        else
81
                n = n + 1;
82
        if ((n & 7)==0)
83
                $display("t   n  cti cyc we   addr din adnx do re vma wr ird sync vma nmi irq  PC  IR A  X  Y  SP nvmdizcb\n");
84 20 robfinch
        $display("%d %d %b  %b  %b  %h %h %h %h %h %h %h %h %h %h %h %h %b%b%b%b%b%b%b%b %d %b %b %b %b %b %b",
85 5 robfinch
                $time, n, cpu0.cti_o, cpu0.cyc_o, cpu0.we_o, cpu0.adr_o, cpu0.dat_i, cpu0.dat_o, cpu0.res, cpu0.res8, cpu0.pc, cpu0.ir,
86
                cpu0.acc, cpu0.x, cpu0.y, cpu0.isp, cpu0.sp,
87 20 robfinch
                cpu0.nf, cpu0.vf, cpu0.df, cpu0.im, cpu0.zf, cpu0.cf, cpu0.bf, cpu0.em, cpu0.state, cpu0.imiss, cpu0.ihit,cpu0.hit0,cpu0.hit1,cpu0.imiss,ubr1.cs);
88 5 robfinch
end
89
 
90
endmodule
91
 
92
/* ---------------------------------------------------------------
93
        rom2kx32.v -- external async 8Kx8 ROM Verilog model
94
        (simulation only)
95
 
96
        Note this module is a functional model, with no timing, and
97
  is only suitable for simulation, not synthesis.
98
--------------------------------------------------------------- */
99
 
100
module rom2Kx32(ce, oe, addr, d);
101
parameter MEMFILE = "t65002d.mem";
102
        input                   ce;     // active low chip enable
103
        input                   oe;     // active low output enable
104
        input   [10:0]   addr;   // byte address
105
        output  [31:0]   d;              // tri-state data I/O
106
        tri [31:0] d;
107
 
108
        reg             [7:0]    mem [0:8191];
109
 
110
        initial begin
111
                $readmemh (MEMFILE, mem);
112
//              $readmemh ("t65c.mem", mem);
113
                $display ("Loaded t65002d.mem");
114
                $display (" 000000: %h %h %h %h %h %h %h %h",
115
                        mem[0], mem[1], mem[2], mem[3], mem[4], mem[5], mem[6], mem[7]);
116
        end
117
 
118
        assign d = (~oe & ~ce) ? {mem[{addr,2'b11}],mem[{addr,2'b10}],mem[{addr,2'b01}],mem[{addr,2'b00}]} : 32'bz;
119
/*
120
        always @(oe or ce or addr) begin
121
//              $display (" 000000: %h %h %h %h %h %h %h %h %h %h",
122
//                      mem[0], mem[1], mem[2], mem[3], mem[4], mem[5], mem[6], mem[7], mem[8], mem[9]);
123
                $display (" read %h: %h", addr, mem[addr]);
124
        end
125
*/
126
endmodule
127
 
128
/* ---------------------------------------------------------------
129
        ram32kx8.v -- external sync 32Kx8 RAM Verilog model
130
        (simulation only)
131
 
132
        Note this module is a functional model, with no timing, and
133
  is only suitable for simulation, not synthesis.
134
--------------------------------------------------------------- */
135
 
136
module ram8Kx32(clk, ce, oe, we, sel, addr, d);
137
        input clk;
138
        input                   ce;             // active low chip enable
139
        input                   oe;             // active low output enable
140
        input                   we;             // active low write enable
141
        input [3:0] sel;         // byte lane selects
142
        input   [12:0]   addr;   // byte address
143
        output  [31:0]   d;              // tri-state data I/O
144
        tri [31:0] d;
145
 
146
        reg             [31:0]   mem [0:8191];
147
        integer nn;
148
 
149
        initial begin
150
                for (nn = 0; nn < 8192; nn = nn + 1)
151
                        mem[nn] <= 32'b0;
152
        end
153
 
154
        assign d = (~oe & ~ce & we) ? mem[addr] : 32'bz;
155
 
156
        always @(posedge clk) begin
157
                if (clk) begin
158
                        if (~ce & ~we) begin
159
                                if (sel[0]) mem[addr][7:0] <= d[7:0];
160
                                if (sel[1]) mem[addr][15:8] <= d[15:8];
161
                                if (sel[2]) mem[addr][23:16] <= d[23:16];
162
                                if (sel[3]) mem[addr][31:24] <= d[31:24];
163
                                $display (" wrote: %h with %h", addr, d);
164
                        end
165
                        if (~ce & we & ~oe)
166
                                $display (" read: %h val %h", addr, d);
167
                end
168
        end
169
/*
170
        always @(we or oe or ce or addr) begin
171
                if (ce==0)
172
                        $display (" 000000: %h %h %h %h %h %h %h %h %h %h",
173
                                mem[0], mem[1], mem[2], mem[3], mem[4], mem[5], mem[6], mem[7], mem[8], mem[9]);
174
        end
175
*/
176
endmodule
177
 
178
module uart(clk, cs, wr, a, di, do);
179
        input clk;
180
        input cs;
181
        input wr;
182
        input [2:0] a;
183
        input [7:0] di;
184
        output reg [7:0] do;
185
//      reg [7:0] do;
186
 
187
        reg [127:0] msg;
188
        integer msgn;
189
        integer logf,r;
190
 
191
        initial begin
192
                msgn <= 0;
193
        end
194
 
195
        always @(posedge clk)
196
                if (cs & wr) begin
197
                        if (di==8'h0A) begin
198
                                $display(" ");
199
                                $display("%s", msg);
200
                                $display (" ");
201
                                $stop;
202
                                msgn <= 0;
203
                                msg <= 0;
204
                        end
205
                        else begin
206
                                case(msgn)
207
                                0: msg[127:120] <= di;
208
                                1: msg[119:112] <= di;
209
                                2:      msg[111:104] <= di;
210
                                3:      msg[103:96] <= di;
211
                                4:      msg[95:88] <= di;
212
                                5:      msg[87:80] <= di;
213
                                6:      msg[79:72] <= di;
214
                                7:      msg[71:64] <= di;
215
                                endcase
216
                                msgn <= msgn + 1;
217
                        end
218
                end
219
 
220
//      always @(posedge clk)
221
//              if (cs & wr) begin
222
//                      logf = $fopen("uart_in", "a");
223
//                      r = $fdisplay(logf, "%h", di);
224
//                      $fclose(logf);
225
//              end
226
 
227
        always @(a)
228
        begin
229
                case(a)
230
                default:
231
                        do <= 8'h00;
232
                endcase
233
        end
234
 
235
//      assign do = 8'h00;
236
 
237
endmodule

powered by: WebSVN 2.1.0

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