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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [env/] [tb_top.v] - Blame information for rev 56

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

Line No. Rev Author Line
1 31 ghutchis
`define TV80_CORE_PATH tb_top.tv80s_inst.i_tv80_core
2
 
3 2 ghutchis
module tb_top;
4
 
5
  reg         clk;
6
  reg         reset_n;
7
  reg         wait_n;
8
  reg         int_n;
9
  reg         nmi_n;
10
  reg         busrq_n;
11
  wire        m1_n;
12
  wire        mreq_n;
13
  wire        iorq_n;
14
  wire        rd_n;
15
  wire        wr_n;
16
  wire        rfsh_n;
17
  wire        halt_n;
18
  wire        busak_n;
19
  wire [15:0] A;
20
  wire [7:0]  di;
21
  wire [7:0]  do;
22
  wire        ram_rd_cs, ram_wr_cs, rom_rd_cs;
23 56 ghutchis
  reg         tx_clk;
24 2 ghutchis
 
25
  always
26
    begin
27
      clk = 1;
28
      #5;
29
      clk = 0;
30
      #5;
31
    end
32
 
33 56 ghutchis
  always
34
    begin
35
      tx_clk = 0;
36
      #8;
37
      tx_clk = 1;
38
      #8;
39
    end
40
 
41 2 ghutchis
  assign rom_rd_cs = !mreq_n & !rd_n & !A[15];
42
  assign ram_rd_cs = !mreq_n & !rd_n & A[15];
43
  assign ram_wr_cs = !mreq_n & !wr_n & A[15];
44
 
45
  tv80s tv80s_inst
46
    (
47
     // Outputs
48
     .m1_n                              (m1_n),
49
     .mreq_n                            (mreq_n),
50
     .iorq_n                            (iorq_n),
51
     .rd_n                              (rd_n),
52
     .wr_n                              (wr_n),
53
     .rfsh_n                            (rfsh_n),
54
     .halt_n                            (halt_n),
55
     .busak_n                           (busak_n),
56
     .A                                 (A[15:0]),
57
     .do                                (do[7:0]),
58
     // Inputs
59
     .reset_n                           (reset_n),
60
     .clk                               (clk),
61
     .wait_n                            (wait_n),
62
     .int_n                             (int_n),
63
     .nmi_n                             (nmi_n),
64
     .busrq_n                           (busrq_n),
65
     .di                                (di[7:0]));
66
 
67
  async_mem ram
68
    (
69
     // Outputs
70
     .rd_data                           (di),
71
     // Inputs
72
     .wr_clk                            (clk),
73
     .wr_data                           (do),
74
     .wr_cs                             (ram_wr_cs),
75
     .addr                              (A[14:0]),
76
     .rd_cs                             (ram_rd_cs));
77
 
78
  async_mem rom
79
    (
80
     // Outputs
81
     .rd_data                           (di),
82
     // Inputs
83
     .wr_clk                            (),
84
     .wr_data                           (),
85
     .wr_cs                             (1'b0),
86
     .addr                              (A[14:0]),
87
     .rd_cs                             (rom_rd_cs));
88
 
89
  env_io env_io_inst
90
    (
91
     // Outputs
92
     .DI                                (di[7:0]),
93
     // Inputs
94
     .clk                               (clk),
95
     .iorq_n                            (iorq_n),
96
     .rd_n                              (rd_n),
97
     .wr_n                              (wr_n),
98
     .addr                              (A[7:0]),
99
     .DO                                (do[7:0]));
100
 
101 53 ghutchis
  wire   nwintf_sel = !iorq_n & (A[7:3] == 5'b00001);
102
  wire [7:0] rx_data, tx_data;
103
  wire       rx_clk, rx_dv, rx_er;
104
  wire       tx_dv, tx_er;
105
  wire [7:0] nw_data_out;
106
 
107
  // loopback config
108
  assign     rx_data = tx_data;
109
  assign     rx_dv = tx_dv;
110
  assign     rx_er = tx_er;
111
  assign     rx_clk = tx_clk;
112
 
113
  assign     di = (nwintf_sel & !rd_n) ? nw_data_out : 8'bz;
114
 
115
  simple_gmii nwintf
116
    (
117
     // Outputs
118
     .tx_dv                             (tx_dv),
119
     .tx_er                             (tx_er),
120
     .tx_data                           (tx_data),
121
     .tx_clk                            (tx_clk),
122
     .io_data_out                       (nw_data_out),
123
     // Inputs
124
     .clk                               (clk),
125
     .reset                             (!reset_n),
126
     .rx_data                           (rx_data),
127
     .rx_clk                            (rx_clk),
128
     .rx_dv                             (rx_dv),
129
     .rx_er                             (rx_er),
130
     .io_select                         (nwintf_sel),
131
     .rd_n                              (rd_n),
132
     .wr_n                              (wr_n),
133
     .io_addr                           (A[2:0]),
134
     .io_data_in                        (do));
135
 
136 2 ghutchis
  initial
137
    begin
138 28 ghutchis
      clear_ram;
139 2 ghutchis
      reset_n = 0;
140
      wait_n = 1;
141
      int_n  = 1;
142
      nmi_n  = 1;
143
      busrq_n = 1;
144
      $readmemh (`PROGRAM_FILE,  tb_top.rom.mem);
145
      repeat (20) @(negedge clk);
146
      reset_n = 1;
147 42 ghutchis
    end // initial begin
148
 
149
`ifdef DUMP_START
150
  always
151
    begin
152
      if ($time > `DUMP_START)
153
        dumpon;
154
      #100;
155 2 ghutchis
    end
156 42 ghutchis
`endif
157
 
158
 
159 36 ghutchis
/*
160
  always
161
    begin
162
      while (mreq_n) @(posedge clk);
163
      wait_n <= #1 0;
164
      @(posedge clk);
165
      wait_n <= #1 1;
166
      while (!mreq_n) @(posedge clk);
167
    end
168
  */
169 2 ghutchis
 
170 31 ghutchis
`ifdef TV80_INSTRUCTION_DECODE
171
  reg [7:0] state;
172
  initial
173
    state = 0;
174
 
175
  always @(posedge clk)
176
    begin : inst_decode
177
      if ((`TV80_CORE_PATH.mcycle[6:0] == 1) &&
178
          (`TV80_CORE_PATH.tstate[6:0] == 8))
179
        begin
180
          op_decode.decode (`TV80_CORE_PATH.IR[7:0], state);
181
        end
182
      else if (`TV80_CORE_PATH.mcycle[6:0] != 1)
183
        state = 0;
184
    end
185
`endif
186
 
187 2 ghutchis
`include "env_tasks.v"
188
 
189
endmodule // tb_top

powered by: WebSVN 2.1.0

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