//--------------------------------------------------------------------------------------------------
//
// Title       : Interface
// Design      : U4
// Author      : mbari###
// Company     : MBARI
//
//-------------------------------------------------------------------------------------------------
//
// File        : C:\Projects\genosensor\2g\CPLDs\Core\U4\src\Interface.v
// Generated   : Tue Dec 16 13:43:36 2003
// From        : interface description file
// By          : Itf2Vhdl ver. 1.20
//
//-------------------------------------------------------------------------------------------------
//
// Description : 
//
//-------------------------------------------------------------------------------------------------
`timescale 1ps / 1ps

//{{ Section below this comment is automatically maintained
//   and may be overwritten
//{module {Interface}}
module Interface ( inDATA ,outDATA ,Reset ,AS ,AD ,RD ,Mclk ,WR ,ADDR );

input WR ;
wire WR ;
input [7:0] outDATA ;
wire [7:0] outDATA ;
input Reset ;
wire Reset ;
input AS ;
wire AS ;
input RD ;
wire RD ;
input Mclk ;
wire Mclk ;

output [7:0] inDATA ;
wire [7:0] inDATA ;
output [7:0] ADDR ;
wire [7:0] ADDR ;

inout [7:0] AD ;
wire [7:0] AD ;

//}} End of automatically maintained section

// -- Enter your statements here -- //

//The core PLD currently uses address range 0 - F
`define CORE_PLD_RANGE 8'h0F   

//This is the register which lathces the address off the bus
reg [7:0] ADDR_reg;
//wire Enable_AD;
//synthesis attribute keep of Enable_AD is true;
wire Enable_AD;
//wire Enable_DATA;

assign ADDR = ADDR_reg;

 //drive the AD bus only if within this pld's range
assign Enable_AD = ((!AS) & (!WR) & (RD) & (ADDR <= `CORE_PLD_RANGE));
//assign Enable_DATA = ((WR) & (ADDR <= `CORE_PLD_RANGE));
//assign AD = Enable_AD ? DATA : 8'bz;  
//assign DATA = Enable_DATA ? AD : 8'bz;

assign inDATA = AD;
assign AD = (Enable_AD) ? outDATA : 8'bz;

always @ (posedge Mclk)
	begin
		if (Reset) ADDR_reg <= 8'b0;
		else if (AS) ADDR_reg <= AD; //Latch the Address off the bus
	end
endmodule
