Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.8 2003/04/07 14:58:02 simont
|
|
// change sfr's interface.
|
|
//
|
// Revision 1.7 2003/01/13 14:14:41 simont
|
// Revision 1.7 2003/01/13 14:14:41 simont
|
// replace some modules
|
// replace some modules
|
//
|
//
|
// Revision 1.6 2002/09/30 17:33:59 simont
|
// Revision 1.6 2002/09/30 17:33:59 simont
|
// prepared header
|
// prepared header
|
Line 58... |
Line 61... |
// synopsys translate_on
|
// synopsys translate_on
|
|
|
`include "oc8051_defines.v"
|
`include "oc8051_defines.v"
|
|
|
|
|
module oc8051_ports (clk, rst,
|
module oc8051_ports (clk,
|
bit_in, data_in,
|
rst,
|
wr, wr_bit,
|
bit_in,
|
wr_addr, rmw,
|
data_in,
|
p0_out, p1_out, p2_out, p3_out,
|
wr,
|
p0_in, p1_in, p2_in, p3_in,
|
wr_bit,
|
p0_data, p1_data, p2_data, p3_data);
|
wr_addr,
|
//
|
|
// clk (in) clock
|
`ifdef OC8051_PORT0
|
// rst (in) reset
|
p0_out,
|
// bit_in (in) bit input [oc8051_alu.desCy]
|
p0_in,
|
// data_in (in) data input (from alu destiantion 1) [oc8051_alu.des1]
|
p0_data,
|
// wr (in) write [oc8051_decoder.wr -r]
|
`endif
|
// wr_bit (in) write bit addresable [oc8051_decoder.bit_addr -r]
|
|
// wr_addr (in) write address [oc8051_ram_wr_sel.out]
|
`ifdef OC8051_PORT1
|
// rd_addr (in) read address [oc8051_ram_rd_sel.out]
|
p1_out,
|
// rmw (in) read modify write feature [oc8051_decoder.rmw]
|
p1_in,
|
// data_out (out) data output [oc8051_ram_sel.ports_in]
|
p1_data,
|
// p0_out, p1_out, p2_out, p3_out (out) port outputs [pin]
|
|
// p0_in, p1_in, p2_in, p3_in (in) port inputs [pin]
|
`endif
|
//
|
|
|
`ifdef OC8051_PORT2
|
|
p2_out,
|
|
p2_in,
|
|
p2_data,
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT3
|
|
p3_out,
|
|
p3_in,
|
|
p3_data,
|
|
`endif
|
|
|
|
rmw);
|
|
|
|
input clk, //clock
|
|
rst, //reset
|
|
wr, //write [oc8051_decoder.wr -r]
|
|
wr_bit, //write bit addresable [oc8051_decoder.bit_addr -r]
|
|
bit_in, //bit input [oc8051_alu.desCy]
|
|
rmw; //read modify write feature [oc8051_decoder.rmw]
|
|
input [7:0] wr_addr, //write address [oc8051_ram_wr_sel.out]
|
|
data_in; //data input (from alu destiantion 1) [oc8051_alu.des1]
|
|
|
|
`ifdef OC8051_PORT0
|
|
input [7:0] p0_in;
|
|
output [7:0] p0_out,
|
|
p0_data;
|
|
reg [7:0] p0_out;
|
|
|
input clk, rst, wr, wr_bit, bit_in, rmw;
|
assign p0_data = rmw ? p0_out : p0_in;
|
input [7:0] wr_addr, data_in, p0_in, p1_in, p2_in, p3_in;
|
`endif
|
|
|
output [7:0] p0_out, p1_out, p2_out, p3_out;
|
|
output [7:0] p0_data, p1_data, p2_data, p3_data;
|
|
|
|
reg [7:0] p0_out, p1_out, p2_out, p3_out;
|
`ifdef OC8051_PORT1
|
|
input [7:0] p1_in;
|
|
output [7:0] p1_out,
|
|
p1_data;
|
|
reg [7:0] p1_out;
|
|
|
assign p0_data = rmw ? p0_out : p0_in;
|
|
assign p1_data = rmw ? p1_out : p1_in;
|
assign p1_data = rmw ? p1_out : p1_in;
|
|
`endif
|
|
|
|
|
|
`ifdef OC8051_PORT2
|
|
input [7:0] p2_in;
|
|
output [7:0] p2_out,
|
|
p2_data;
|
|
reg [7:0] p2_out;
|
|
|
assign p2_data = rmw ? p2_out : p2_in;
|
assign p2_data = rmw ? p2_out : p2_in;
|
|
`endif
|
|
|
|
|
|
`ifdef OC8051_PORT3
|
|
input [7:0] p3_in;
|
|
output [7:0] p3_out,
|
|
p3_data;
|
|
reg [7:0] p3_out;
|
|
|
assign p3_data = rmw ? p3_out : p3_in;
|
assign p3_data = rmw ? p3_out : p3_in;
|
|
`endif
|
|
|
//
|
//
|
// case of writing to port
|
// case of writing to port
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or posedge rst)
|
begin
|
begin
|
if (rst) begin
|
if (rst) begin
|
|
`ifdef OC8051_PORT0
|
p0_out <= #1 `OC8051_RST_P0;
|
p0_out <= #1 `OC8051_RST_P0;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT1
|
p1_out <= #1 `OC8051_RST_P1;
|
p1_out <= #1 `OC8051_RST_P1;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT2
|
p2_out <= #1 `OC8051_RST_P2;
|
p2_out <= #1 `OC8051_RST_P2;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT3
|
p3_out <= #1 `OC8051_RST_P3;
|
p3_out <= #1 `OC8051_RST_P3;
|
|
`endif
|
end else if (wr) begin
|
end else if (wr) begin
|
if (!wr_bit) begin
|
if (!wr_bit) begin
|
case (wr_addr)
|
case (wr_addr)
|
//
|
//
|
// bytaddresable
|
// bytaddresable
|
|
`ifdef OC8051_PORT0
|
`OC8051_SFR_P0: p0_out <= #1 data_in;
|
`OC8051_SFR_P0: p0_out <= #1 data_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT1
|
`OC8051_SFR_P1: p1_out <= #1 data_in;
|
`OC8051_SFR_P1: p1_out <= #1 data_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT2
|
`OC8051_SFR_P2: p2_out <= #1 data_in;
|
`OC8051_SFR_P2: p2_out <= #1 data_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT3
|
`OC8051_SFR_P3: p3_out <= #1 data_in;
|
`OC8051_SFR_P3: p3_out <= #1 data_in;
|
|
`endif
|
endcase
|
endcase
|
end else begin
|
end else begin
|
case (wr_addr[7:3])
|
case (wr_addr[7:3])
|
|
|
//
|
//
|
// bit addressable
|
// bit addressable
|
|
`ifdef OC8051_PORT0
|
`OC8051_SFR_B_P0: p0_out[wr_addr[2:0]] <= #1 bit_in;
|
`OC8051_SFR_B_P0: p0_out[wr_addr[2:0]] <= #1 bit_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT1
|
`OC8051_SFR_B_P1: p1_out[wr_addr[2:0]] <= #1 bit_in;
|
`OC8051_SFR_B_P1: p1_out[wr_addr[2:0]] <= #1 bit_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT2
|
`OC8051_SFR_B_P2: p2_out[wr_addr[2:0]] <= #1 bit_in;
|
`OC8051_SFR_B_P2: p2_out[wr_addr[2:0]] <= #1 bit_in;
|
|
`endif
|
|
|
|
`ifdef OC8051_PORT3
|
`OC8051_SFR_B_P3: p3_out[wr_addr[2:0]] <= #1 bit_in;
|
`OC8051_SFR_B_P3: p3_out[wr_addr[2:0]] <= #1 bit_in;
|
|
`endif
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|