module oc8051_fpga_top (clk, rst,
//
// interrupt interface
//
   int1, int2,
//
// 2x7 led display output (port 0)
//
   dispout, 
//
// ports
//
   p0_out, p1_out, p2_out, p3_out, 
//
// external instruction rom interface
//
   ea, iadr_o, istb_o, iack_i, icyc_o, idat_i,
//
// external data ram interface
//
   stb_o, cyc_o, dat_i, dat_o, adr_o, ack_i, we_o,
//
// serial interface
//
   rxd, txd, 
//
// timer/counter interface
//
   t0, t1);

input clk, rst, int1, int2, ea, iack_i, ack_i, rxd, t0, t1;
input [7:0] dat_i;
input [31:0] idat_i;
output txd, istb_o, icyc_o, stb_o, cyc_o, we_o;
output [13:0] dispout;
output [7:0] p0_out, p1_out, p2_out, p3_out, dat_o;
output [15:0] adr_o, iadr_o;


wire cstb_o, ccyc_o, cack_i;
wire [15:0] cadr_o;
wire [31:0] cdat_i;


wire nrst;

assign nrst = ~rst;

oc8051_top oc8051_top_1(.rst(nrst), .clk(clk),
//
// interrupt interface
//
    .int0(int1), .int1(int2),
//
// external rom interface
//
    .ea(ea), .iadr_o(cadr_o),  .idat_i(cdat_i), .istb_o(cstb_o), .iack_i(cack_i), .icyc_o(ccyc_o),
//
// external ram interface
//
    .dat_i(dat_i), .dat_o(dat_o), .adr_o(adr_o), .we_o(we_o), .ack_i(ack_i), .stb_o(stb_o),
    .cyc_o(cyc_o),
//
//  ports interface
//
     .p0_in(8'hb0), .p1_in(8'hb1), .p2_in(8'hb2), .p3_in(8'hb3),
     .p0_out(p0_out), .p1_out(p1_out), .p2_out(p2_out), .p3_out(p3_out),
//
// serial interface
//
     .rxd(rxd), .txd(txd),
//
// timer/counter interface
//
     .t0(t0), .t1(t1));





oc8051_icache oc8051_icache1(.rst(rst), .clk(clk),
// oc8051
        .adr_i(cadr_o), .dat_o(cdat_i), .stb_i(cstb_o), .ack_o(cack_i),
        .cyc_i(ccyc_o),
// external rom
        .dat_i(idat_i), .stb_o(istb_o), .adr_o(iadr_o), .ack_i(iack_i),
        .cyc_o(icyc_o));


defparam oc8051_icache1.ADR_WIDTH = 6;  // cache address wihth
defparam oc8051_icache1.LINE_WIDTH = 3; // line address width (2 => 4x32)
defparam oc8051_icache1.BL_NUM = 7; // number of blocks (2^BL_WIDTH-1); BL_WIDTH = ADR_WIDTH - LINE_WIDTH
defparam oc8051_icache1.CACHE_RAM = 64; // cache ram x 32 (2^ADR_WIDTH)



  disp disp1(.in(p0_out), .out(dispout));

endmodule