⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tb_top.v

📁 // -*- Mode: Verilog -*- // Filename : wb_master.v // Description : Wishbone Master Behavorial //
💻 V
字号:
//////////////////////////////////////////////////////////////////////
////                                                              ////
////  Real Time Clock Testbench Top                               ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////      - Jianmin Zhang                                         ////
////                                                              ////
//////////////////////////////////////////////////////////////////////


`include "timescale.v"

module tb_top;



//
// Interconnect wires
//
wire			clk;		// Clock
wire			rst;		// Reset
wire			cyc;		// Cycle valid
wire	[31:0]		adr;		// Address bus
wire	[31:0]		data_i;		// Data bus from RTC to WBM
wire	[3:0]		sel;		// Data selects
wire			we;		// Write enable
wire			stb;		// Strobe
wire	[31:0]		data_o;		// Data bus from WBM to RTC
wire			ack;		// Successful cycle termination
wire			err;		// Failed cycle termination

wire			int_o;
wire			extal;		// xtal output
reg	[31:0]		tempsec;
reg	[31:0]		tempmin;
reg	[31:0]		temphour;
reg	[31:0]		tempdate;
reg	[31:0]		tempday;
reg	[31:0]		tempmon;
reg	[31:0]		tempyear;
reg			start;



//
// Instantiation of Clock/Reset Generator
//
clkrst inst_clkrst(
			// Clock
			.clk_o(		clk	),
			// Reset
			.rst_o(		rst	)
		   );
		   


//
// Instantiation of Master WISHBONE BFM
//
wb_master wb_master(
			// WISHBONE Interface
			.CLK_I(		clk		),
			.RST_I(		rst		),
			.CYC_O(		cyc		),
			.ADR_O(		adr		),
			.DAT_O(		data_o		),
			.SEL_O(		sel		),
			.WE_O(		we		),
			.STB_O(		stb		),
			.DAT_I(		data_i		),
			.ACK_I(		ack		),
			.ERR_I(		err		),
			.RTY_I(		1'b0		)
		    );
		    


//
// Instantiation of GPIO core
//
rtc_top inst_rtc(
			// WISHBONE Interface
			.wb_clk_i(	clk		),
			.wb_rst_i(	rst		),
			.wb_cyc_i(	cyc		),
			.wb_adr_i(	adr[4:0]	),
			.wb_dat_i(	data_o		),
			.wb_sel_i(	sel		),
			.wb_we_i(	we		),
			.wb_stb_i(	stb		),
			.wb_dat_o(	data_i		),
			.wb_ack_o(	ack		),
			.wb_err_o(	err		),
			
			// Internal Interface
			.rtc_int_o(	int_o		),
			
			// External  Interface
			.XTAL(		clk		),
			.EXTAL(		extal		)
		);

initial begin        
        
        $display;
	$display("###");
	$display("### Real Time Clock IP Core Verification ###");
	$display("###");
	$display("\n ###################################################################### \n");
	$display;
	$display("   Testing wave of operation signals");
	$display;
	$display("   The current date is 1999/12/31/7/23:59:50  ");
	
	$display;
	$display("\n ###################################################################### \n");
	$display;
	$display("###");
	$display("###");
	$display;
	
	#20 tb_top.wb_master.wr({28'b0, 5'b01000}, 32'h61, 4'b0001); 	// rtc_con
		
	tb_top.wb_master.wr({28'b0, 5'b01001}, 32'h8, 4'b1111);		// inicount
		
	tb_top.wb_master.wr({28'b0, 5'b00110}, 32'h1999, 4'b0011);	// year
		
	tb_top.wb_master.wr({28'b0, 5'b00101}, 32'h12, 4'b0001);	// mon
		
	tb_top.wb_master.wr({28'b0, 5'b00100}, 32'h31, 4'b0001);	// date
		
	tb_top.wb_master.wr({28'b0, 5'b00011}, 32'h7, 4'b0001);		// day
		
	tb_top.wb_master.wr({28'b0, 5'b00010}, 32'h23, 4'b0001); 	// hour
		
	tb_top.wb_master.wr({28'b0, 5'b00001}, 32'h59, 4'b0001); 	// minute
		
	tb_top.wb_master.wr({28'b0, 5'b00000}, 32'h50, 4'b0001); 	// second
	
	
	tb_top.wb_master.wr({28'b0, 5'h19}, 32'h2000, 4'b0011);		// year
		
	tb_top.wb_master.wr({28'b0, 5'h18}, 32'h1, 4'b0001);		// mon
		
	tb_top.wb_master.wr({28'b0, 5'h17}, 32'h1, 4'b0001);		// date
		
	tb_top.wb_master.wr({28'b0, 5'h16}, 32'h1, 4'b0001);		// day
		
	tb_top.wb_master.wr({28'b0, 5'h15}, 32'h0, 4'b0001); 		// hour
		
	tb_top.wb_master.wr({28'b0, 5'h14}, 32'h0, 4'b0001); 		// minute
		
	tb_top.wb_master.wr({28'b0, 5'h13}, 32'h0, 4'b0001); 		// second
	
	tb_top.wb_master.wr({28'b0, 5'h12}, 32'hff, 4'b0001);		// Int mask
	
	tb_top.wb_master.wr({28'b0, 5'h11}, 32'hff, 4'b0001);		// Inte Reg
				
	tb_top.wb_master.wr({28'b0, 5'b01101}, 32'h1, 4'b1111);	 	// fred_cnt
	
	start = 1'b0;
	end

   
endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -