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

Subversion Repositories tv80

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

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

Line No. Rev Author Line
1 89 ghutchis
`timescale 1ns/100ps
2 31 ghutchis
`define TV80_CORE_PATH tb_top.tv80s_inst.i_tv80_core
3
 
4 2 ghutchis
module tb_top;
5
 
6
  reg         clk;
7
  reg         reset_n;
8
  reg         wait_n;
9
  reg         int_n;
10
  reg         nmi_n;
11
  reg         busrq_n;
12
  wire        m1_n;
13
  wire        mreq_n;
14
  wire        iorq_n;
15
  wire        rd_n;
16
  wire        wr_n;
17
  wire        rfsh_n;
18
  wire        halt_n;
19
  wire        busak_n;
20
  wire [15:0] A;
21
  wire [7:0]  di;
22 89 ghutchis
  wire [7:0]  d_out;
23 2 ghutchis
  wire        ram_rd_cs, ram_wr_cs, rom_rd_cs;
24 56 ghutchis
  reg         tx_clk;
25 2 ghutchis
 
26
  always
27
    begin
28
      clk = 1;
29
      #5;
30
      clk = 0;
31
      #5;
32
    end
33
 
34 56 ghutchis
  always
35
    begin
36
      tx_clk = 0;
37
      #8;
38
      tx_clk = 1;
39
      #8;
40
    end
41
 
42 2 ghutchis
  assign rom_rd_cs = !mreq_n & !rd_n & !A[15];
43
  assign ram_rd_cs = !mreq_n & !rd_n & A[15];
44
  assign ram_wr_cs = !mreq_n & !wr_n & A[15];
45
 
46
  tv80s tv80s_inst
47
    (
48
     // Outputs
49
     .m1_n                              (m1_n),
50
     .mreq_n                            (mreq_n),
51
     .iorq_n                            (iorq_n),
52
     .rd_n                              (rd_n),
53
     .wr_n                              (wr_n),
54
     .rfsh_n                            (rfsh_n),
55
     .halt_n                            (halt_n),
56
     .busak_n                           (busak_n),
57
     .A                                 (A[15:0]),
58 89 ghutchis
     .dout                              (d_out[7:0]),
59 2 ghutchis
     // Inputs
60
     .reset_n                           (reset_n),
61
     .clk                               (clk),
62
     .wait_n                            (wait_n),
63
     .int_n                             (int_n),
64
     .nmi_n                             (nmi_n),
65
     .busrq_n                           (busrq_n),
66
     .di                                (di[7:0]));
67
 
68
  async_mem ram
69
    (
70
     // Outputs
71
     .rd_data                           (di),
72
     // Inputs
73
     .wr_clk                            (clk),
74 89 ghutchis
     .wr_data                           (d_out),
75 2 ghutchis
     .wr_cs                             (ram_wr_cs),
76
     .addr                              (A[14:0]),
77
     .rd_cs                             (ram_rd_cs));
78
 
79
  async_mem rom
80
    (
81
     // Outputs
82
     .rd_data                           (di),
83
     // Inputs
84
     .wr_clk                            (),
85
     .wr_data                           (),
86
     .wr_cs                             (1'b0),
87
     .addr                              (A[14:0]),
88
     .rd_cs                             (rom_rd_cs));
89
 
90
  env_io env_io_inst
91
    (
92
     // Outputs
93
     .DI                                (di[7:0]),
94
     // Inputs
95
     .clk                               (clk),
96
     .iorq_n                            (iorq_n),
97
     .rd_n                              (rd_n),
98
     .wr_n                              (wr_n),
99
     .addr                              (A[7:0]),
100 89 ghutchis
     .D_OUT                             (d_out[7:0]));
101 2 ghutchis
 
102 69 ghutchis
  //----------------------------------------------------------------------
103
  // UART
104
  //----------------------------------------------------------------------
105
 
106
  wire                uart_cs_n;
107
  wire [7:0]          uart_rd_data;
108
 
109 89 ghutchis
  wire                ser_in;
110 69 ghutchis
  wire                cts_n;
111
  wire                dsr_n;
112
  wire                ri_n;
113
  wire                dcd_n;
114
 
115
  wire                sout;
116
  wire                rts_n;
117
  wire                dtr_n;
118
  wire                out1_n;
119
  wire                out2_n;
120
  wire                baudout;
121
  wire                intr;
122
 
123
  // base address of 0x18 (24dec)
124
 
125
  assign              uart_cs_n = ~(!iorq_n & (A[7:3] == 5'h3));
126
  assign              di = (!uart_cs_n & !rd_n) ? uart_rd_data : 8'bz;
127 89 ghutchis
  assign              ser_in = sout;
128 69 ghutchis
 
129
  T16450 uart0
130
    (.reset_n     (reset_n),
131
     .clk         (clk),
132
     .rclk        (baudout),
133
     .cs_n        (uart_cs_n),
134
     .rd_n        (rd_n),
135
     .wr_n        (wr_n),
136
     .addr        (A[2:0]),
137 89 ghutchis
     .wr_data     (d_out),
138 69 ghutchis
     .rd_data     (uart_rd_data),
139 89 ghutchis
     .sin         (ser_in),
140 69 ghutchis
     .cts_n       (cts_n),
141
     .dsr_n       (dsr_n),
142
     .ri_n        (ri_n),
143
     .dcd_n       (dcd_n),
144
     .sout        (sout),
145
     .rts_n       (rts_n),
146
     .dtr_n       (dtr_n),
147
     .out1_n      (out1_n),
148
     .out2_n      (out2_n),
149
     .baudout     (baudout),
150
     .intr        (intr));
151
 
152
  //----------------------------------------------------------------------
153
  // Network Interface
154
  //----------------------------------------------------------------------
155
 
156
  //wire   nwintf_sel = !iorq_n & (A[7:3] == 5'b00001);
157 53 ghutchis
  wire [7:0] rx_data, tx_data;
158
  wire       rx_clk, rx_dv, rx_er;
159
  wire       tx_dv, tx_er;
160
  wire [7:0] nw_data_out;
161 66 ghutchis
  wire       nwintf_oe;
162 53 ghutchis
 
163
  // loopback config
164
  assign     rx_data = tx_data;
165
  assign     rx_dv = tx_dv;
166
  assign     rx_er = tx_er;
167
  assign     rx_clk = tx_clk;
168
 
169 66 ghutchis
  assign     di = (nwintf_oe) ? nw_data_out : 8'bz;
170
 
171 69 ghutchis
  simple_gmii_top nwintf
172 53 ghutchis
    (
173 66 ghutchis
     // unused outputs
174
     .int_n                             (),
175
     // Outputs
176
     .tx_dv                             (tx_dv),
177
     .tx_er                             (tx_er),
178
     .tx_data                           (tx_data),
179
     .tx_clk                            (tx_clk),
180
     .rd_data                           (nw_data_out),
181
     .doe                               (nwintf_oe),
182
     // Inputs
183
     .clk                               (clk),
184
     .reset                             (!reset_n),
185
     .rx_data                           (rx_data),
186
     .rx_clk                            (rx_clk),
187
     .rx_dv                             (rx_dv),
188
     .rx_er                             (rx_er),
189
     //.io_select                         (nwintf_sel),
190
     .iorq_n                            (iorq_n),
191
     .rd_n                              (rd_n),
192
     .wr_n                              (wr_n),
193
     .addr                              (A[15:0]),
194 89 ghutchis
     .wr_data                           (d_out));
195 66 ghutchis
 
196 69 ghutchis
  //----------------------------------------------------------------------
197
  // Global Initialization
198
  //----------------------------------------------------------------------
199
 
200
   initial
201 2 ghutchis
    begin
202 28 ghutchis
      clear_ram;
203 2 ghutchis
      reset_n = 0;
204
      wait_n = 1;
205
      int_n  = 1;
206
      nmi_n  = 1;
207
      busrq_n = 1;
208
      $readmemh (`PROGRAM_FILE,  tb_top.rom.mem);
209
      repeat (20) @(negedge clk);
210
      reset_n = 1;
211 42 ghutchis
    end // initial begin
212
 
213
`ifdef DUMP_START
214
  always
215
    begin
216
      if ($time > `DUMP_START)
217
        dumpon;
218
      #100;
219 2 ghutchis
    end
220 42 ghutchis
`endif
221
 
222
 
223 36 ghutchis
/*
224
  always
225
    begin
226
      while (mreq_n) @(posedge clk);
227
      wait_n <= #1 0;
228
      @(posedge clk);
229
      wait_n <= #1 1;
230
      while (!mreq_n) @(posedge clk);
231
    end
232
  */
233 2 ghutchis
 
234 31 ghutchis
`ifdef TV80_INSTRUCTION_DECODE
235
  reg [7:0] state;
236
  initial
237
    state = 0;
238
 
239
  always @(posedge clk)
240
    begin : inst_decode
241
      if ((`TV80_CORE_PATH.mcycle[6:0] == 1) &&
242
          (`TV80_CORE_PATH.tstate[6:0] == 8))
243
        begin
244
          op_decode.decode (`TV80_CORE_PATH.IR[7:0], state);
245
        end
246
      else if (`TV80_CORE_PATH.mcycle[6:0] != 1)
247
        state = 0;
248
    end
249
`endif
250
 
251 2 ghutchis
`include "env_tasks.v"
252
 
253
endmodule // tb_top

powered by: WebSVN 2.1.0

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