OpenCores
URL https://opencores.org/ocsvn/6809_6309_compatible_core/6809_6309_compatible_core/trunk

Subversion Repositories 6809_6309_compatible_core

[/] [6809_6309_compatible_core/] [trunk/] [sim/] [tb_opcodes.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 14 ale500
/* MC6809/HD6309 Compatible core
2
 * (c) 2013 R.A. Paz Schmidt rapazschmidt@gmail.com
3
 *
4
 * Distributed under the terms of the Lesser GPL
5
 *
6
 * Opcode tester
7
 * taken from http://lennartb.home.xs4all.nl/m6809.html
8
 */
9
`timescale 1ns/1ns
10
 
11
module tb(output wire [15:0] addr_o, output wire [7:0] data_o_o);
12
 
13
reg clk, reset;
14
 
15
assign addr_o = addr;
16
assign data_o_o = data_o;
17
wire [15:0] addr;
18
wire [7:0] data_o, data_i;
19
wire oe, we;
20
always
21
        #5 clk = ~clk;
22
 
23
MC6809_cpu cpu(
24
        .cpu_clk(clk),
25
        .cpu_reset(reset),
26
        .cpu_we_o(we),
27
        .cpu_oe_o(oe),
28
        .cpu_addr_o(addr),
29
        .cpu_data_i(data_i),
30
        .cpu_data_o(data_o)
31
        );
32
 
33
memory imem(addr, !oe, !we, data_i, data_o);
34
 
35
initial
36
        begin
37
                $dumpvars;
38
                clk = 0;
39
                reset = 1;
40
                #0
41
                #46
42
                reset = 0;
43
                #111500
44
                $finish;
45
        end
46
 
47
endmodule
48
 
49
module memory(
50
        input wire [15:0] addr,
51
        input wire oe,
52
        input wire we,
53
        output wire [7:0] data_o,
54
        input wire [7:0] data_i
55
        );
56
 
57
reg [7:0] mem[65535:0];
58
reg [7:0] latecheddata;
59
wire [7:0] mem0, mem1, mem2, mem3;
60
 
61
assign mem0 = mem[0];
62
assign mem1 = mem[1];
63
assign mem2 = mem[2];
64
assign mem3 = mem[3];
65
 
66
assign data_o = latecheddata;
67
always @(negedge oe)
68
        latecheddata <= mem[addr];
69
 
70
always @(negedge we)
71
        begin
72
                mem[addr] <= data_i;
73
                $display("W %04x = %02x %t", addr, data_i, $time);
74
        end
75
 
76
always @(negedge oe)
77
        begin
78
                if (addr == 16'h0003)
79
                        begin
80
                                $display("*** Error ***");
81
                                $finish;
82
                        end
83
                if (addr == 16'h04db)
84
                        begin
85
                                $display("");
86
                                $display("*** All tests  OOOO   K  K ***");
87
                                $display("*** All tests O    O  K K  ***");
88
                                $display("*** All tests O    O  KK   ***");
89
                                $display("*** All tests O    O  K K  ***");
90
                                $display("*** All tests  OOOO   K  K ***");
91
                                $finish;
92
                        end
93
                $display("R %04x = %02x %t", addr, mem[addr], $time);
94
        end
95
`define READTESTBIN
96
integer i;
97
initial
98
        begin
99
                $readmemh("test09.hex", mem);
100
                $display("test09.hex read");
101
                mem[16'hfffe] = 8'h00; // setup reset
102
                mem[16'hffff] = 8'h00;
103
        end
104
 
105
endmodule

powered by: WebSVN 2.1.0

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