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

📄 udevrom.v

📁 实现USB接口功能的VHDL和verilog完整源代码
💻 V
字号:
/* 
The device rom contains the bytes for the get confuration
cycles.  
This is the version for the usb camera core application.
*/

module Udevrom
	(
	// inputs from dev
		devromdescriptorindex,
		devromsetupaddr,
		
	// outputs to sie
		romdevsetupdata
	);

input	[6:0]	devromdescriptorindex;
input	[7:0]	devromsetupaddr;

output	[7:0]	romdevsetupdata;

reg	[7:0]	romdevsetupdata;

`include "Udevctldef.v"


// pure combinatorial logic
always @(devromdescriptorindex or devromsetupaddr)
begin
	case (devromdescriptorindex[6:4])	// synopsys parallel_case full_case
	TYPEDEVICE:	
	begin
		case (devromsetupaddr)	// synopsys parallel_case full_case
		5'h00: romdevsetupdata = 8'h12;	// length
		5'h01: romdevsetupdata = 8'h01;	// DEVICE
		5'h02: romdevsetupdata = 8'h00;	// spec version 1.00
		5'h03: romdevsetupdata = 8'h01;	// spec
		5'h04: romdevsetupdata = 8'hff;	// device class
		5'h05: romdevsetupdata = 8'hff;	// device sub-class
		5'h06: romdevsetupdata = 8'hff;	// vendor specific protocol
		5'h07: romdevsetupdata = 8'h08;	// max packet size
		5'h08: romdevsetupdata = 8'hb4;	// vendor id
		5'h09: romdevsetupdata = 8'h05;	// vendor id
		5'h0a: romdevsetupdata = 8'h01;	// product id
		5'h0b: romdevsetupdata = 8'h60;	// product id
		5'h0c: romdevsetupdata = 8'h01;	// device release #
		5'h0d: romdevsetupdata = 8'h00;	// device release #
		5'h0e: romdevsetupdata = 8'h00;	// manufacturer index string
		5'h0f: romdevsetupdata = 8'h00;	// product index string
		5'h10: romdevsetupdata = 8'h00;	// serial number index string
		5'h11: romdevsetupdata = 8'h01;	// number of configurations
		endcase
	end
	TYPECONFIG:	
	begin
		case (devromsetupaddr)	// synopsys parallel_case full_case
		// first provide configuration descriptor
		8'h0: romdevsetupdata = 8'h09;	// length of this descriptor
		8'h1: romdevsetupdata = 8'h02;	// CONFIGURATION (2)
		8'h2: romdevsetupdata = 8'h27;	// total length includes endpoint descriptors (should be 1 more than last address)
		8'h3: romdevsetupdata = 8'h00;	// total length high byte
		8'h4: romdevsetupdata = 8'h01;	// number of interfaces
		8'h5: romdevsetupdata = 8'h01;	// configuration value for this one
		8'h6: romdevsetupdata = 8'h00;	// configuration - string is here, 0 means no string
		8'h7: romdevsetupdata = 8'h80;	// attributes - bus powered, no wakeup
		8'h8: romdevsetupdata = 8'h32;	// max power - 100 ma is 50 (32 hex)
		// now provide interface descriptor(s)
		// first interface descriptor for alternate settting 00
		8'h9: romdevsetupdata = 8'h09;	// length of the interface descriptor
		8'ha: romdevsetupdata = 8'h04;	// INTERFACE (4)
		8'hb: romdevsetupdata = 8'h00;	// Zero based index 0f this interface
		8'hc: romdevsetupdata = 8'h00;	// Alternate setting value (?)
		8'hd: romdevsetupdata = 8'h03;	// Number of endpoints (not counting 0)
		8'he: romdevsetupdata = 8'hff;	// Interface class, ff is vendor specific
		8'hf: romdevsetupdata = 8'hff;	// Interface sub-class
		8'h10: romdevsetupdata = 8'hff;	// Interface protocol
		8'h11: romdevsetupdata = 8'h00;	// Index to string descriptor for this interface
		// now provide endpoint 1 descriptor
		8'h12: romdevsetupdata = 8'h07;	// length of this endpoint descriptor
		8'h13: romdevsetupdata = 8'h05;	// ENDPOINT (6)
		8'h14: romdevsetupdata = 8'h01;	// endpoint direction (00 is out) and address
		8'h15: romdevsetupdata = 8'h02;	// transfer type - 00 = control, 01 = iso, 10 = bulk, 11 = int
		8'h16: romdevsetupdata = 8'h20;	// max packet size - low //16 byte
		8'h17: romdevsetupdata = 8'h00;	// max packet size - high
		8'h18: romdevsetupdata = 8'h00;	// polling interval in milliseconds (1 for iso)
		// now provide endpoint 2 descriptor
		8'h19: romdevsetupdata = 8'h07;	// length of this endpoint descriptor
		8'h1a: romdevsetupdata = 8'h05;	// ENDPOINT (7)
		8'h1b: romdevsetupdata = 8'h82;	// endpoint direction (80 is in) and address
		8'h1c: romdevsetupdata = 8'h02;	// transfer type - 00 = control, 01 = iso, 2 = bulk, 3 = int
		8'h1d: romdevsetupdata = 8'h20;	// max packet size - low (16)
		8'h1e: romdevsetupdata = 8'h00;	// max packet size - high
		8'h1f: romdevsetupdata = 8'h00;	// polling interval in milliseconds (1 for iso)
	   // now provide endpoint 3 descriptor	
		
		8'h20: romdevsetupdata = 8'h07;	// length of this endpoint descriptor
		8'h21: romdevsetupdata = 8'h05;	// ENDPOINT (7)
		8'h22: romdevsetupdata = 8'h83;	// endpoint direction (80 is in) and address
		8'h23: romdevsetupdata = 8'h02;	// transfer type - 00 = control, 01 = iso, 2 = bulk, 3 = int
		8'h24: romdevsetupdata = 8'h08;	// max packet size - low (16)
		8'h25: romdevsetupdata = 8'h00;	// max packet size - high
		8'h26: romdevsetupdata = 8'h00;	// polling interval in milliseconds (1 for iso)
		endcase
	end
	TYPESTRING:
	begin
		case (devromsetupaddr)	// synopsys parallel_case full_case
		3'h0: romdevsetupdata = 8'h02;	// size in bytes (including leading 2 bytes)
		3'h1: romdevsetupdata = 8'h03;	// STRING type (3)
		endcase
	end
	endcase
end

// make the ascii version of the devromdescriptorindex field
// synopsys translate_off
reg [8*20:1]    typefield;
always @(devromdescriptorindex)
case (devromdescriptorindex[6:4])
	TYPEDEVICE: typefield = "TYPEDEVICE";
	TYPECONFIG: typefield = "TYPECONFIG";
	TYPESTRING: typefield = "TYPESTRING";
	TYPEINTF: typefield = "TYPEINTF";
	TYPEENDP: typefield = "TYPEENDP";
endcase
// synopsys translate_on

endmodule

⌨️ 快捷键说明

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