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

📄 fifo_test_rev0.1.v

📁 Verilog jpec coder encoder source code
💻 V
字号:
////////////////////////////////////////////////////////////////
//
//  Module Name: 	fifo_test
// 	Descr: 			FIFO Implementation Test
// 	Author: 		James Rosenthal
// 	Date: 			12/07/04
//
//
// 	Version	Date		Modifications
// 	---------------------------------
// 	0.0		12/07/04	- Initial
//	0.1		12/13/04	- Add another address bit for an
//						  addressable reset, and to read 
//						  status flags without affecting 
//						  the rest of the design.
//
// 	Module Description
// 	------------------
//  This module will implement both the input and output fifo, 
//  to interface the fpga to the dsp.  The input fifo is to 
//  accept writes from the dsp, as the output fifo is used to 
//  read data back to the fpga.  
//
//  The read/write addresses are defined below.
//
//  write address 0x0 - write to input fifo
//  write address 0x1 - no-op instruction
//  write address 0x2 - reset
//  write address 0x3 - ?
//  read address 0x0 - read from output fifo
//  read address 0x1 - read from input fifo, write to output fifo
//  read address 0x2 - read status reg
//  read address 0x3 - 
//  
//  Rearranging the data will put the 4LSB, to bits [11:8]
//  Read from address 0x0, will also have empty/full status flags,
//  even though reading 0x2 will provide those flags as well as error
//  flags.
////////////////////////////////////////////////////////////////

`timescale 1ns / 10ps

module fifo_test(
	sysclk,		// FPGA clock
	fpgarst,	// Async. Active Low Reset
	nce,		// Active Low Chip Enable
	are,		// Async. Active Low Read Enable
	awe,		// Async. Active Low Write Enable
	data,		// Data bus 
	addr		// Address Bus 
);

	//
	// Inputs & Outputs
	//
	
	input sysclk;	// FPGA Clock - 25MHz
	input fpgarst;	// Async. Active Low Reset
	input nce;		// Active Low Chip Enable
	input are;		// Async. Active Low Read Enable
	input awe;		// Async. Active Low Write Enable

	inout [18:0] data;	// Data Bus 
	input [1:0] addr;	// Address Bus
	
	//
	// Registers & Wires
	//
	
	wire rst;	// Reset to FIFO Modules
	wire soft;	// Soft Reset via Write to address 0x2

	wire doe;	// Data Output Enable for Tristate

	wire [12:0] odout; // Data Output of Output FIFO
	wire [12:0] idout; // Data Output of Input FIFO
	
	wire ifull;		// Input FIFO is Full
	wire iempty;	// Input FIFO is Empty
	wire ierror;	// Input FIFO Error - Write on Full
	wire ofull;		// Output FIFO Full
	wire oempty;	// Output FIFO Empty
	wire oerror;	// Output FIFO Error - Read on Empty

	wire [5:0] status;	// Flag Status

	wire iwr_en, ird_en;	// Input FIFO Read/Write Enables
	wire ord_en;			// Output FIFO Read Enables
	reg owr_en;				// Output FIFO Write Enable
	
	// 
	// Instantiate Input FIFO
	//
	
	input_fifo input_fifo(
		.sysclk(sysclk),
		.wr_en(iwr_en),
		.rd_en(ird_en),
		.din(data[12:0]),
		.dout(idout),
		.full(ifull),
		.empty(iempty),
		.rst(rst),
		.error(ierror)
	);
	
	//
	// Instantiate Output FIFO
	//
	
	output_fifo output_fifo(
		.sysclk(sysclk),
		.rst(rst),
		.rd_en(ord_en),
		.wr_en(owr_en),
		.din({idout[12],idout[3:0],idout[11:4]}),
		.dout(odout),
		.full(ofull),
		.empty(oempty),
		.error(oerror)
	);

	// 
	// Behavioral Description
	//
	
	// Reset
	assign soft = nce || awe || !addr[1] || addr[0];
	assign rst = fpgarst && soft;
	
	// Status Flags
	assign status = {ifull, iempty, ierror, ofull, oempty, oerror};
	
	// Data Bus 
	assign doe = ~nce && ~are;
	assign data = doe ? ( (addr == 2'h2) ? {15'h0,status[5:4],status[2:1]} : {status,odout} ) : 19'bz;

	// Write/Read Enables
	assign iwr_en = ~nce && ~awe && (addr == 2'h0);
	assign ird_en = ~nce && ~are && (addr == 2'h1);
	assign ord_en = ~nce && ~are && (addr == 2'h0);
	
	always @ (posedge sysclk or negedge rst)
	begin
		if(!rst) owr_en <= 1'b0;
		else owr_en <= ird_en;
	end	

endmodule


	

⌨️ 快捷键说明

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