Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.12 2003/04/16 09:55:56 simont
|
|
// add support for external rom from xilinx ramb4
|
|
//
|
// Revision 1.11 2003/04/10 12:45:06 simont
|
// Revision 1.11 2003/04/10 12:45:06 simont
|
// defines for pherypherals added
|
// defines for pherypherals added
|
//
|
//
|
// Revision 1.10 2003/04/03 19:20:55 simont
|
// Revision 1.10 2003/04/03 19:20:55 simont
|
// Remove instruction cache and wb_interface
|
// Remove instruction cache and wb_interface
|
Line 77... |
Line 80... |
`include "oc8051_defines.v"
|
`include "oc8051_defines.v"
|
|
|
|
|
module oc8051_tb;
|
module oc8051_tb;
|
|
|
|
|
|
//parameter FREQ = 20000; // frequency in kHz
|
|
parameter FREQ = 12000; // frequency in kHz
|
|
|
|
parameter DELAY = 500000/FREQ;
|
|
|
reg rst, clk;
|
reg rst, clk;
|
reg [7:0] p0_in, p1_in, p2_in;
|
reg [7:0] p0_in, p1_in, p2_in;
|
wire [15:0] ext_addr, iadr_o;
|
wire [15:0] ext_addr, iadr_o;
|
wire write, write_xram, write_uart, txd, rxd, int_uart, int0, int1, t0, t1, bit_out, stb_o, ack_i;
|
wire write, write_xram, write_uart, txd, rxd, int_uart, int0, int1, t0, t1, bit_out, stb_o, ack_i;
|
wire ack_xram, ack_uart, cyc_o, iack_i, istb_o, icyc_o, t2, t2ex;
|
wire ack_xram, ack_uart, cyc_o, iack_i, istb_o, icyc_o, t2, t2ex;
|
Line 164... |
Line 173... |
oc8051_xram oc8051_xram1 (.clk(clk), .rst(rst), .wr(write_xram), .addr(ext_addr), .data_in(data_out), .data_out(data_out_xram), .ack(ack_xram), .stb(stb_o));
|
oc8051_xram oc8051_xram1 (.clk(clk), .rst(rst), .wr(write_xram), .addr(ext_addr), .data_in(data_out), .data_out(data_out_xram), .ack(ack_xram), .stb(stb_o));
|
|
|
|
|
defparam oc8051_xram1.DELAY = 2;
|
defparam oc8051_xram1.DELAY = 2;
|
|
|
|
`ifdef OC8051_SERIAL
|
|
|
|
//
|
|
// test programs with serial interface
|
|
//
|
|
oc8051_serial oc8051_serial1(.clk(clk), .rst(rst), .rxd(txd), .txd(rxd));
|
|
|
|
defparam oc8051_serial1.FREQ = FREQ;
|
|
//defparam oc8051_serial1.BRATE = 9.6;
|
|
defparam oc8051_serial1.BRATE = 4.8;
|
|
|
|
|
|
`else
|
|
|
//
|
//
|
// external uart
|
// external uart
|
//
|
//
|
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
|
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
|
.wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
|
.wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
|
.txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
|
.txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
|
|
|
|
|
|
`endif
|
|
|
|
|
`ifdef OC8051_XILINX_RAMB
|
`ifdef OC8051_XILINX_RAMB
|
|
|
`include "oc8051_rom_values.v"
|
`include "oc8051_rom_values.v"
|
|
|
Line 241... |
Line 266... |
`else
|
`else
|
|
|
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_o), .data(idat_i),
|
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_o), .data(idat_i),
|
.stb_i(istb_o), .cyc_i(icyc_o), .ack_o(iack_i));
|
.stb_i(istb_o), .cyc_i(icyc_o), .ack_o(iack_i));
|
|
|
defparam oc8051_xrom1.DELAY = 5;
|
defparam oc8051_xrom1.DELAY = 0;
|
|
|
`endif
|
`endif
|
//
|
//
|
//
|
//
|
//
|
//
|
|
|
|
|
|
|
//
|
|
// test wb interface
|
|
//
|
|
|
|
reg [31:0] log_file;
|
|
|
|
initial
|
|
begin
|
|
log_file = $fopen("log_file");
|
|
$fdisplay(log_file, "file open");
|
|
end
|
|
|
|
|
|
assign write_xram = p3_out[7] & write;
|
assign write_xram = p3_out[7] & write;
|
assign write_uart = !p3_out[7] & write;
|
assign write_uart = !p3_out[7] & write;
|
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
|
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
|
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
|
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
|
assign p3_in = {6'h0, bit_out, int_uart};
|
assign p3_in = {6'h0, bit_out, int_uart};
|
Line 284... |
Line 296... |
p1_in = 8'h00;
|
p1_in = 8'h00;
|
p2_in = 8'h00;
|
p2_in = 8'h00;
|
#220
|
#220
|
rst = 1'b0;
|
rst = 1'b0;
|
|
|
#40000000
|
#80000000
|
$fclose(log_file);
|
|
$display("time ",$time, "\n faulire: end of time\n \n");
|
$display("time ",$time, "\n faulire: end of time\n \n");
|
$finish;
|
$finish;
|
end
|
end
|
|
|
|
|
initial
|
initial
|
begin
|
begin
|
clk = 0;
|
clk = 0;
|
forever #30 clk <= ~clk;
|
forever #DELAY clk <= ~clk;
|
end
|
end
|
|
|
|
|
|
|
initial
|
initial
|
Line 317... |
Line 328... |
$display("time ",$time, " faulire: mismatch on ports in step %d", num);
|
$display("time ",$time, " faulire: mismatch on ports in step %d", num);
|
$display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
|
$display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
|
$display(" testvecp %h", buff[num]);
|
$display(" testvecp %h", buff[num]);
|
$display(" p_out %h%h%h", p0_out, p1_out, p2_out);
|
$display(" p_out %h%h%h", p0_out, p1_out, p2_out);
|
#22
|
#22
|
$fclose(log_file);
|
|
$finish;
|
$finish;
|
end
|
end
|
else begin
|
else begin
|
$display("time ",$time, " step %d", num, ": pass");
|
$display("time ",$time, " step %d", num, ": pass");
|
num = num+1;
|
num = num+1;
|
if (buff[num]===24'hxxxxxx)
|
if (buff[num]===24'hxxxxxx)
|
begin
|
begin
|
$display("");
|
$display("");
|
$display(" Done!");
|
$display(" Done!");
|
$fclose(log_file);
|
|
$finish;
|
$finish;
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|