| 1 |
192 |
creep |
////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// t6532 IP Core ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the t2600 project ////
|
| 6 |
|
|
//// http://www.opencores.org/cores/t2600/ ////
|
| 7 |
|
|
//// ////
|
| 8 |
|
|
//// Description ////
|
| 9 |
|
|
//// 6532 top level ////
|
| 10 |
|
|
//// ////
|
| 11 |
|
|
//// TODO: ////
|
| 12 |
|
|
//// - Add the timer, ram and i/o ////
|
| 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 |
|
|
`include "timescale.v"
|
| 46 |
|
|
|
| 47 |
193 |
creep |
module t6532(clk, io_lines, enable, rw_mem, address, data);
|
| 48 |
192 |
creep |
parameter [3:0] DATA_SIZE = 4'd8;
|
| 49 |
|
|
parameter [3:0] ADDR_SIZE = 4'd7; // this is the *local* addr_size
|
| 50 |
|
|
|
| 51 |
|
|
localparam [3:0] DATA_SIZE_ = DATA_SIZE - 4'd1;
|
| 52 |
|
|
localparam [3:0] ADDR_SIZE_ = ADDR_SIZE - 4'd1;
|
| 53 |
|
|
|
| 54 |
|
|
input clk;
|
| 55 |
|
|
input [15:0] io_lines;
|
| 56 |
|
|
input enable;
|
| 57 |
193 |
creep |
input rw_mem;
|
| 58 |
192 |
creep |
input [ADDR_SIZE_:0] address;
|
| 59 |
|
|
inout [DATA_SIZE_:0] data;
|
| 60 |
193 |
creep |
|
| 61 |
194 |
creep |
reg [DATA_SIZE_:0] ram [127:0];
|
| 62 |
|
|
reg [DATA_SIZE_:0] port_a;
|
| 63 |
|
|
reg [DATA_SIZE_:0] port_b;
|
| 64 |
|
|
reg [DATA_SIZE_:0] ddra;
|
| 65 |
196 |
creep |
reg [DATA_SIZE_:0] timer;
|
| 66 |
|
|
reg [DATA_SIZE_:0] 1c_timer;
|
| 67 |
|
|
reg [DATA_SIZE_:0] 8c_timer;
|
| 68 |
|
|
reg [DATA_SIZE_:0] 64c_timer;
|
| 69 |
|
|
reg [DATA_SIZE_:0] 1024c_timer;
|
| 70 |
|
|
|
| 71 |
193 |
creep |
reg [DATA_SIZE_:0] data_drv;
|
| 72 |
|
|
|
| 73 |
194 |
creep |
assign data = (rw_mem) ? 8'bZ: data_drv; // if i am writing the bus receives the data from cpu, else local data.
|
| 74 |
193 |
creep |
|
| 75 |
194 |
creep |
always @(clk) begin
|
| 76 |
|
|
port_b[0] <= ~io_lines[0]; // these two are not actually switches
|
| 77 |
|
|
port_b[1] <= ~io_lines[1];
|
| 78 |
|
|
|
| 79 |
|
|
if (io_lines[3]) begin // these are.
|
| 80 |
|
|
port_b[3] <= !port_b[3];
|
| 81 |
|
|
end
|
| 82 |
|
|
if (io_lines[6]) begin
|
| 83 |
|
|
port_b[6] <= !port_b[6];
|
| 84 |
|
|
end
|
| 85 |
|
|
if (io_lines[7]) begin
|
| 86 |
|
|
port_b[7] <= !port_b[7];
|
| 87 |
|
|
end
|
| 88 |
193 |
creep |
|
| 89 |
194 |
creep |
port_a[0] <= (ddra[0] == 0) ? io_lines[8] : port_a[0];
|
| 90 |
|
|
port_a[1] <= (ddra[1] == 0) ? io_lines[9] : port_a[1];
|
| 91 |
|
|
port_a[2] <= (ddra[2] == 0) ? io_lines[10] : port_a[2];
|
| 92 |
|
|
port_a[3] <= (ddra[3] == 0) ? io_lines[11] : port_a[3];
|
| 93 |
|
|
port_a[4] <= (ddra[4] == 0) ? io_lines[12] : port_a[4];
|
| 94 |
|
|
port_a[5] <= (ddra[5] == 0) ? io_lines[13] : port_a[5];
|
| 95 |
|
|
port_a[6] <= (ddra[6] == 0) ? io_lines[14] : port_a[6];
|
| 96 |
|
|
port_a[7] <= (ddra[7] == 0) ? io_lines[15] : port_a[7];
|
| 97 |
|
|
|
| 98 |
196 |
creep |
if (enable && rw_mem == 0) begin // reading!
|
| 99 |
193 |
creep |
case (address)
|
| 100 |
194 |
creep |
8'h80: data_drv = port_a;
|
| 101 |
|
|
8'h81: data_drv = ddra;
|
| 102 |
|
|
8'h82: data_drv = port_b;
|
| 103 |
196 |
creep |
8'h83: data_drv = 8'h00; // portb ddr is always input
|
| 104 |
|
|
8'h84: data_drv = timer;
|
| 105 |
194 |
creep |
8'h94: ;
|
| 106 |
|
|
8'h95: ;
|
| 107 |
|
|
8'h96: ;
|
| 108 |
|
|
8'h97: ;
|
| 109 |
193 |
creep |
default: ;
|
| 110 |
|
|
endcase
|
| 111 |
|
|
end
|
| 112 |
|
|
end
|
| 113 |
|
|
|
| 114 |
|
|
// timer
|
| 115 |
|
|
// ram
|
| 116 |
192 |
creep |
|
| 117 |
|
|
endmodule
|