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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_fsm_tb.v] - Blame information for rev 78

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

Line No. Rev Author Line
1 67 creep
////////////////////////////////////////////////////////////////////////////
2
////                                                                    ////
3
//// T6507LP IP Core                                                    ////
4
////                                                                    ////
5
//// This file is part of the T6507LP project                           ////
6
//// http://www.opencores.org/cores/t6507lp/                            ////
7
////                                                                    ////
8
//// Description                                                        ////
9
//// 6507 FSM                                                           ////
10
////                                                                    ////
11
//// TODO:                                                              ////
12
//// - Perform simple tests before going into serious verification      ////
13
////                                                                    ////
14
//// Author(s):                                                         ////
15
//// - Gabriel Oshiro Zardo, gabrieloshiro@gmail.com                    ////
16
//// - Samuel Nascimento Pagliarini (creep), snpagliarini@gmail.com     ////
17
////                                                                    ////
18
////////////////////////////////////////////////////////////////////////////
19
////                                                                    ////
20
//// Copyright (C) 2001 Authors and OPENCORES.ORG                       ////
21
////                                                                    ////
22
//// This source file may be used and distributed without               ////
23
//// restriction provided that this copyright statement is not          ////
24
//// removed from the file and that any derivative work contains        ////
25
//// the original copyright notice and the associated disclaimer.       ////
26
////                                                                    ////
27
//// This source file is free software; you can redistribute it         ////
28
//// and/or modify it under the terms of the GNU Lesser General         ////
29
//// Public License as published by the Free Software Foundation;       ////
30
//// either version 2.1 of the License, or (at your option) any         ////
31
//// later version.                                                     ////
32
////                                                                    ////
33
//// This source is distributed in the hope that it will be             ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied         ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ////
36
//// PURPOSE. See the GNU Lesser General Public License for more        ////
37
//// details.                                                           ////
38
////                                                                    ////
39
//// You should have received a copy of the GNU Lesser General          ////
40
//// Public License along with this source; if not, download it         ////
41
//// from http://www.opencores.org/lgpl.shtml                           ////
42
////                                                                    ////
43
////////////////////////////////////////////////////////////////////////////
44
 
45
 
46
`timescale 1ns / 1ps
47
 
48
module t6507lp_fsm_tb();
49 71 creep
        reg clk;
50
        reg reset_n;
51 67 creep
        reg [7:0] alu_result;
52
        reg [7:0] alu_status;
53
        reg [7:0] data_in;
54
 
55
        wire [12:0] address;
56
        wire control; // one bit is enough? read = 0, write = 1
57
        wire [7:0] data_out;
58
        wire [7:0] alu_opcode;
59
        wire [7:0] alu_a;
60
        wire alu_enable;
61
 
62
        `include "../T6507LP_Package.v"
63
 
64 71 creep
        t6507lp_fsm #(8,13) my_dut(clk, reset_n, alu_result, alu_status, data_in, address, control, data_out, alu_opcode, alu_a, alu_enable);
65 67 creep
 
66 71 creep
        always #10 clk = ~clk;
67 67 creep
 
68 76 creep
        reg[7:0] fake_mem[30:0];
69 71 creep
 
70 67 creep
        initial begin
71 71 creep
                clk = 0;
72
                reset_n = 1'b0;
73
                alu_result = 8'h01;
74 67 creep
                alu_status = 0;
75
 
76 71 creep
                fake_mem[0] = ASL_ACC; // testing ACC mode
77
                fake_mem[1] = ADC_IMM; // testing IMM mode
78
                fake_mem[2] = 8'h27;
79
                fake_mem[3] = JMP_ABS; // testing ABS mode, JMP type
80
                fake_mem[4] = 8'h09;
81
                fake_mem[5] = 8'h00;
82
                fake_mem[6] = ASL_ACC; // wont be executed
83
                fake_mem[7] = ASL_ACC; // wont be executed
84
                fake_mem[8] = ASL_ACC; // wont be executed
85
                fake_mem[9] = ASL_ACC; // wont be executed
86
                fake_mem[10] = LDA_ABS; // testing ABS mode, READ type. A = MEM[0002]. (a=27)
87
                fake_mem[11] = 8'h02;
88
                fake_mem[12] = 8'h00;
89
                fake_mem[13] = ASL_ABS; // testing ABS mode, READ_MODIFY_WRITE type. should overwrite the first ASL_ACC
90 76 creep
                fake_mem[14] = 8'h00;
91 71 creep
                fake_mem[15] = 8'h00;
92 76 creep
                fake_mem[16] = STA_ABS; // testing ABS mode, WRITE type. should write alu_result on MEM[1]
93
                fake_mem[17] = 8'h01;
94
                fake_mem[18] = 8'h00;
95
                fake_mem[19] = LDA_ZPG; // testing ZPG mode, READ type
96
                fake_mem[20] = 8'h00;
97 78 creep
                fake_mem[21] = ASL_ZPG; // testing ZPG mode, READ_MODIFY_WRITE type
98
                fake_mem[22] = 8'h00;
99
                fake_mem[23] = STA_ZPG; // testing ZPG mode, WRITE type
100
                fake_mem[24] = 8'h00;
101 67 creep
 
102 71 creep
                @(negedge clk) // will wait for next negative edge of the clock (t=20)
103
                reset_n=1'b1;
104
 
105 67 creep
 
106 78 creep
                #1000;
107 67 creep
                $finish; // to shut down the simulation
108
        end //initial
109
 
110 71 creep
        always @(clk) begin
111
                if (control == 0) begin // MEM_READ
112
                        data_in <= fake_mem[address];
113
                        $write("\nreading from mem position %h: %h", address, fake_mem[address]);
114
                end
115
                else if (control == 1'b1) begin // MEM_WRITE
116
                        fake_mem[address] <= data_out;
117
                        $write("\nreading from mem position %h: %h", address, fake_mem[address]);
118
                end
119
        end
120 67 creep
 
121
endmodule

powered by: WebSVN 2.1.0

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