OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [host/] [basic_de1/] [basic_de1_ModelSim.sv] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 gdevic
//============================================================================
2
// Host design containing A-Z80 and a few peripherials
3
//
4
// This module does not define a physical board but is only meant to be
5
// compiled within the ModelSim host test.
6
//
7
//  Copyright (C) 2014-2016  Goran Devic
8
//
9
//  This program is free software; you can redistribute it and/or modify it
10
//  under the terms of the GNU General Public License as published by the Free
11
//  Software Foundation; either version 2 of the License, or (at your option)
12
//  any later version.
13
//
14
//  This program is distributed in the hope that it will be useful, but WITHOUT
15
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17
//  more details.
18
//
19
//  You should have received a copy of the GNU General Public License along
20
//  with this program; if not, write to the Free Software Foundation, Inc.,
21
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
//============================================================================
23
module host
24
(
25
    input wire clk,
26
    input wire reset,
27
    input wire nint,
28
    input wire nnmi,
29
    output wire uart_tx
30
);
31
 
32
// ----------------- CPU PINS -----------------
33
wire nM1;
34
wire nMREQ;
35
wire nIORQ;
36
wire nRD;
37
wire nWR;
38
wire nRFSH;
39
wire nHALT;
40
wire nBUSACK;
41
 
42 13 gdevic
wire nWAIT;
43 8 gdevic
wire nINT = nint;
44
wire nNMI = nnmi;
45
wire nBUSRQ = 1;
46
 
47
wire [15:0] A;
48
wire [7:0] D;
49
 
50 13 gdevic
// This is an optional, test feature: add M1/Memory Wait states as described in the Zilog manual
51
reg nWAIT_M1_sig;
52
reg nWAIT_Mem_sig;
53
 
54
// *** Uncomment one of the following 3 choices ***:
55
//assign nWAIT = nWAIT_M1_sig;  // Add one wait state to an M1 cycle
56
//assign nWAIT = nWAIT_Mem_sig; // Add one wait state to any memory cycle (M1 + memory read/write)
57
assign nWAIT = 1;               // Do not add wait cycles
58
 
59 8 gdevic
// ----------------- INTERNAL WIRES -----------------
60
wire [7:0] RamData;                     // RamData is a data writer from the RAM module
61
wire RamWE;
62
assign RamWE = nIORQ==1 && nRD==1 && nWR==0;
63
 
64
wire uart_busy;
65
wire UartWE = nIORQ==0 && nRD==1 && nWR==0;
66
 
67
// Memory map:
68
//   0000 - 3FFF  16K RAM
69
assign D[7:0] = (A[15:14]=='h0 && nIORQ==1 && nRD==0 && nWR==1) ? RamData :
70
                (nIORQ==0 && nRD==1 && nWR==1) ? 8'h80 :
71
                (nIORQ==0 && nRD==0 && nWR==1) ? {7'h0,uart_busy} :
72
                {8{1'bz}};
73
 
74
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75
// Instantiate A-Z80 CPU module
76
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77
z80_top_direct_n z80_( .*, .nRESET(reset), .CLK(clk) );
78
 
79
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 13 gdevic
// Instantiate gates to add Wait states to M1 and Memory cycles (for testing)
81
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
wait_state wait_state_inst
83
(
84
    .CLK(clk),
85
    .nM1(nM1),
86
    .nMREQ((nMREQ === z) ? 1'b1 : nMREQ), // Correct nMREQ from being tri-stated after reset
87
    .nWAIT_M1(nWAIT_M1_sig),
88
    .nWAIT_Mem(nWAIT_Mem_sig)
89
);
90
 
91
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92 8 gdevic
// Instantiate 16Kb of RAM memory
93
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
ram ram_( .address(A[13:0]), .clock(clk), .data(D[7:0]), .wren(RamWE), .q(RamData[7:0]) );
95
 
96
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
// Instantiate UART module
98
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
uart #( .BAUD(115200), .IN_CLOCK(10000000) ) uart_(
100
   // Outputs
101
   .busy(uart_busy),
102
   .uart_tx(uart_tx),
103
   // Inputs
104
   .wr(UartWE),
105
   .data(D[7:0]),
106
   .clk(clk),
107
   .reset(!reset)
108
);
109
 
110
endmodule

powered by: WebSVN 2.1.0

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