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

📄 tiny16_maxii.v

📁 这个是专门用在ALtera第二代PLD MAXII上的16位微处理器IP核
💻 V
字号:
module tiny16_MAXII(
	v_sram_ena,
	sram_address,
	sram_data,
	sram_ncs,
	sram_noe,
	sram_nwe,

	v_lcd_ena,
	lcd_db,
	lcd_e,
	lcd_rs,
	lcd_rw,
	
	led,
	
	temp_ncs,
	temp_sdo,
	temp_sck);

output			v_sram_ena;
output	[16:0]	sram_address;
output			sram_ncs;
output			sram_noe;
output			sram_nwe;
inout	[7:0]	sram_data;

output			v_lcd_ena;
output			lcd_e;
output			lcd_rs;
output			lcd_rw;
inout	[7:0]	lcd_db;

output			led;

input			temp_sdo;
output			temp_ncs;
output			temp_sck;

reg				led, led_ena;
reg				temp_ncs, temp_ncs_ena;
reg				temp_sck, temp_sck_ena;

reg				flash_go_read, flash_complete, flash_chipselect, flash_osc;
reg		[15:0]	flash_data_out;
reg				cpu_go_read, cpu_go_write, cpu_complete;
reg		[15:0]	cpu_address, cpu_data_in, cpu_data_out;
reg				ram_chipselect, ram_complete;
reg		[15:0]	ram_data_out, ram_data_in;
reg				lcd_chipselect, lcd_complete;
reg		[7:0]	lcd_data_out;

wire			clk;

flash			flash(.clock(clk), .address(cpu_address[8:0]), .data_out(flash_data_out), .osc(clk),
					.go_read(flash_go_read), .chipselect(flash_chipselect), .complete(flash_complete));

tiny16			cpu(.clock(clk), .address(cpu_address), .data_in(cpu_data_in),
					.data_out(cpu_data_out), .go_read(cpu_go_read),
					.go_write(cpu_go_write), .complete(cpu_complete));

sram_interface	ram(.clock(clk), .address(cpu_address[14:0]), .data_in(cpu_data_out),
					.data_out(ram_data_out), .go_read(cpu_go_read), .go_write(cpu_go_write),
					.chipselect(ram_chipselect), .complete(ram_complete), .sram_address(sram_address[15:0]),
					.sram_data(sram_data), .sram_ncs(sram_ncs), .sram_noe(sram_noe), .sram_nwe(sram_nwe));

/*smallram		ram(.clock(clk), .address(cpu_address[2:0]), .data_out(ram_data_out),
					.data_in(cpu_data_out), .go_read(cpu_go_read), .go_write(cpu_go_write),
					.chipselect(ram_chipselect), .complete(ram_complete));*/

lcd_controller	lcd(.clock(clk), .address(cpu_address[0]), .data_in(cpu_data_out),
					.data_out(lcd_data_out), .go_read(cpu_go_read), .go_write(cpu_go_write),
					.chipselect(lcd_chipselect), .complete(lcd_complete), .rs(lcd_rs), .e(lcd_e),
					.rw(lcd_rw), .data(lcd_db));

assign v_lcd_ena = 1'b1;
assign v_sram_ena = 1'b1;
assign sram_address[16] = 1'b0;

always @ (posedge clk) begin
	if(led_ena == 1'b1)
		led <= cpu_data_out[0];
	if(temp_ncs_ena == 1'b1)
		temp_ncs <= cpu_data_out[2];
	if(temp_sck_ena == 1'b1)
		temp_sck <= cpu_data_out[1];
end

always @ (cpu_address, flash_data_out, cpu_go_read, cpu_go_write, flash_complete, led, ram_data_out,
			ram_complete, lcd_data_out, lcd_complete, temp_ncs, temp_sck, temp_sdo) begin
	flash_chipselect <= 1'b0;
	cpu_data_in <= 0;
	flash_go_read <= 1'b0;
	cpu_complete <= 1'b0;
	led_ena <= 1'b0;
	ram_chipselect <= 1'b0;
	lcd_chipselect <= 1'b0;
	temp_ncs_ena <= 1'b0;
	temp_sck_ena <= 1'b0;
	casex(cpu_address)
		16'b0xxx_x00x_xxxx_xxxx:begin // internal flash memory 0x0000 to 0x01ff
			flash_chipselect <= 1'b1;
			cpu_data_in <= flash_data_out;
			flash_go_read <= cpu_go_read;
			cpu_complete <= flash_complete;
		end
		
		16'b0xxx_x01x_xxxx_0xx0:begin // led register 0x0200
			led_ena <= cpu_go_write;
			cpu_data_in[0] <= led;
			cpu_complete <= cpu_go_read | cpu_go_write;
		end
		
		16'b0xxx_x01x_xxxx_1000:begin // temperature port 0x0208
			temp_ncs_ena <= cpu_go_write;
			temp_sck_ena <= cpu_go_write;
			cpu_data_in[2:0] <= {temp_ncs, temp_sck, temp_sdo};
			cpu_complete <= (cpu_go_read | cpu_go_write);
		end
				
		16'b0xxx_x11x_xxxx_xxxx:begin // lcd display 0x600, 0x601
			lcd_chipselect <= 1'b1;
			cpu_data_in <= lcd_data_out;
			cpu_complete <= lcd_complete;
		end

		16'b1xxx_xxxx_xxxx_xxxx:begin // RAM 32kx16 0x8000 to 0xffff
			ram_chipselect <= 1'b1;
			cpu_data_in <= ram_data_out;
			cpu_complete <= ram_complete;
		end
		
		default:begin
			cpu_data_in <= 16'hdead;
			cpu_complete <= 1'b1;
		end
	endcase
end

endmodule

⌨️ 快捷键说明

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