亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wishbone_i2c_master.html

?? wishbone i2c master vhdl code
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0114)http://www.opencores.org/cvsweb.cgi/~checkout~/i2c/Attic/wishbone_i2c_master.vhd?rev=1.4;content-type=text%2Fplain -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY><PRE>--
-- WISHBONE revB2 compiant I2C master core
--
-- author: Richard Herveille
-- rev. 0.1 based on simple_i2c
-- rev. 0.2 april 27th 2001, fixed incomplete sensitivity list on assign_dato process (thanks to Matt Oseman)
-- rev. 0.3 may 4th 2001, fixed typo rev.0.2 txt -&gt; txr
-- rev. 0.4 may 8th, added some remarks, fixed some sensitivity list issues
--
--
-- Changes compared to simple_i2c
-- 1) WISHBONE interface
-- 2) added start/stop detection
-- 3) added busy bit
-- 4) removed automatic tri-state buffer insertion (for ASIC support)
--



library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity wishbone_i2c_master is
	port (
		-- wishbone signals
		CLK_I : in std_logic;				-- master clock input
		RST_I : in std_logic := '0';			-- synchronous active high reset
		nRESET: in std_logic := '1';			-- asynchronous active low reset
		ADR_I : in unsigned(1 downto 0);		-- lower address bits
		DAT_I : in std_logic_vector(15 downto 0);	-- Databus input
		DAT_O : out std_logic_vector(15 downto 0);	-- Databus output
		SEL_I : in std_logic_vector(1 downto 0);		-- Byte select signals
		WE_I : in std_logic;				-- Write enable input
		STB_I : in std_logic;				-- Strobe signals / core select signal
		CYC_I : in std_logic;				-- Valid bus cycle input
		ACK_O : out std_logic;			-- Bus cycle acknowledge output
		INTA_O : out std_logic;			-- interrupt request output signal

		-- I2C signals
		SCLi : in std_logic;				-- I2C clock line
		SCLo : out std_logic;
		SDAi : in std_logic;				-- I2C data line
		SDAo : out std_logic
	);
end entity wishbone_i2c_master;

architecture structural of wishbone_i2c_master is
	component byte_ctrl is
	port (
		clk : in std_logic;
		rst : in std_logic;		-- synchronous active high reset (WISHBONE compatible)
		nReset : in std_logic;	-- asynchornous active low reset (FPGA compatible)

		clk_cnt : in unsigned(15 downto 0);	-- 4x SCL 

		-- input signals
		ena,
		start,
		stop,
		read,
		write,
		ack_in : std_logic;
		Din : in std_logic_vector(7 downto 0);

		-- output signals
		cmd_ack : out std_logic;
		ack_out : out std_logic;
		Dout : out std_logic_vector(7 downto 0);
		i2c_busy : out std_logic;

		-- i2c signals
		SCLi : in std_logic;				-- I2C clock line
		SCLo : out std_logic;
		SDAi : in std_logic;				-- I2C data line
		SDAo : out std_logic
	);
	end component byte_ctrl;

	-- registers
	signal prer : unsigned(15 downto 0);			-- clock prescale register
	signal ctr : std_logic_vector(7 downto 0);			-- control register
	signal txr : std_logic_vector(7 downto 0);			-- transmit register
	signal rxr : std_logic_vector(7 downto 0);			-- receive register
	signal cr : std_logic_vector(7 downto 0);			-- command register
	signal sr : std_logic_vector(7 downto 0);			-- status register

	-- done signal: command completed, clear command register
	signal done : std_logic;

	-- command register signals
	signal sta, sto, rd, wr, ack, iack : std_logic;

	-- core enable signal
	signal core_en : std_logic;

	-- status register signals
	signal irxack, rxack : std_logic; 			-- received aknowledge from slave
	signal tip : std_logic;					-- transfer in progress
	signal irq_flag : std_logic;				-- interrupt pending flag
	signal i2c_busy : std_logic;				-- bus busy (start signal detected)

begin
	-- generate acknowledge output signal
	ACK_O &lt;= STB_I;	-- since timing is always honored 


	-- assign DAT_O
	assign_dato : process(ADR_I, prer, ctr, txr, cr, rxr, sr)
	begin
		case ADR_I is
			when "00" =&gt;
				DAT_O &lt;= std_logic_vector(prer);

			when "01" =&gt;
				DAT_O &lt;= (x"00" &amp; ctr);

			when "10" =&gt;
				DAT_O &lt;= (txr &amp; cr);

			when "11" =&gt;
				DAT_O &lt;= (rxr &amp; sr);

			when others =&gt;
				DAT_O &lt;= (others =&gt; 'X');	-- for simulation only
		end case;
	end process assign_dato;


	-- registers block
	regs_block: block
		-- address decode signals
		signal we_a0, we_a1, we_a2, we_a3 : std_logic;
	begin
		-- decode address lines
		we_a0 &lt;= CYC_I and STB_I and WE_I and not ADR_I(1) and not ADR_I(0);
		we_a1 &lt;= CYC_I and STB_I and WE_I and not ADR_I(1) and       ADR_I(0);
		we_a2 &lt;= CYC_I and STB_I and WE_I and       ADR_I(1) and not ADR_I(0);
		we_a3 &lt;= CYC_I and STB_I and WE_I and       ADR_I(1) and       ADR_I(0);

		-- store data in writeable registers
		-- prescale register
		write_prer: process(nRESET, CLK_I)
		begin
			if (nRESET = '0') then
					prer &lt;= (others =&gt; '1');
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					prer &lt;= (others =&gt; '1');
				else
					if ( (we_a0 and SEL_I(1)) = '1') then
						prer(15 downto 8) &lt;= unsigned(DAT_I(15 downto 8));
					end if;

					if ( (we_a0 and SEL_I(0)) = '1') then
						prer(7 downto 0) &lt;= unsigned(DAT_I(7 downto 0));
					end if;
				end if;
			end if;
		end process write_prer;


		-- control register
		write_ctr: process(nRESET, CLK_I)
		begin
			if (nRESET = '0') then
					ctr &lt;= (others =&gt; '0');
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					ctr &lt;= (others =&gt; '0');
				else
					if ( (we_a1 and SEL_I(0)) = '1') then
						ctr &lt;= DAT_I(7 downto 0);
					end if;
				end if;
			end if;
		end process write_ctr;

		-- transmit register
		write_txr: process(nRESET, CLK_I)
		begin
			if (nRESET = '0') then
					txr &lt;= (others =&gt; '0');
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					txr &lt;= (others =&gt; '0');
				else
					if ( (we_a2 and SEL_I(1)) = '1') then
						txr &lt;= DAT_I(15 downto 8);
					end if;
				end if;
			end if;
		end process write_txr;


		-- command register
		write_cr: process(nRESET, CLK_I)
		begin
			if (nRESET = '0') then
					cr &lt;= (others =&gt; '0');					-- asynchronous clear
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					cr &lt;= (others =&gt; '0');					-- synchronous clear
				else

					if ( (we_a2 and SEL_I(0)) = '1') then
						if (core_en = '1') then
							cr &lt;= DAT_I(7 downto 0);		-- only take new commands when I2C core is enabled, pending commands are finished
						end if;
					else
						if (done = '0') then
							cr(7 downto 4) &lt;= cr(7 downto 4);
						else
							cr(7 downto 0) &lt;= (others =&gt; '0'); 	-- clear command_bits when command completed
						end if;
						cr(2 downto 1) &lt;= cr(2 downto 1);
						cr(0) &lt;= cr(0) and irq_flag; 			-- automatically clear when irq_flag is cleared
					end if;
				end if;
			end if;
		end process write_cr;
	end block regs_block;

		
	-- decode command register
	sta &lt;= cr(7);
	sto &lt;= cr(6);
	rd &lt;= cr(5);
	wr &lt;= cr(4);
	ack &lt;= cr(3);
	iack &lt;= cr(0);

	-- decode control register
	core_en &lt;= ctr(7);

	-- hookup byte controller block
	u1: byte_ctrl port map (clk =&gt; CLK_I, rst =&gt; RST_I, nReset =&gt; nRESET,  clk_cnt =&gt; prer, ena =&gt; core_en, 
		start =&gt; sta,  stop =&gt; sto, read =&gt; rd, write =&gt; wr, ack_in =&gt; ack, i2c_busy =&gt; i2c_busy,
		Din =&gt; txr, cmd_ack =&gt; done, ack_out =&gt; irxack, Dout =&gt; rxr, 			-- note: maybe store rxr in registers ??
		SCLi =&gt; SCLi, SCLo =&gt; SCLo, SDAi =&gt; SDAi, SDAo =&gt; SDAo);


	-- status register block + interrupt request signal
	st_block : block
	begin
		-- generate status register bits
		gen_sr_bits: process (CLK_I, nRESET)
		begin
			if (nRESET = '0') then
				rxack &lt;= '0';
				tip &lt;= '0';
				irq_flag &lt;= '0';
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					rxack &lt;= '0';
					tip &lt;= '0';
					irq_flag &lt;= '0';
				else
					rxack &lt;= irxack;
					tip &lt;= ( rd or wr );
					irq_flag &lt;= (done or irq_flag) and not iack;	-- interrupt request flag is always generated
				end if;
			end if;
		end process gen_sr_bits;

		-- generate interrupt request signals
		gen_irq: process (CLK_I, nRESET)
		begin
			if (nRESET = '0') then
				INTA_O &lt;= '0';
			elsif (CLK_I'event and CLK_I = '1') then
				if (RST_I = '1') then
					INTA_O &lt;= '0';
				else
					INTA_O &lt;= irq_flag and ctr(6);			-- interrupt signal is only generated when IEN (interrupt enable bit) is set
				end if;
			end if;
		end process gen_irq;

		-- assign status register bits
		sr(7) &lt;= rxack;
		sr(6) &lt;= i2c_busy;
		sr(5 downto 2) &lt;= (others =&gt; '0'); -- reserved
		sr(1) &lt;= tip;
		sr(0) &lt;= irq_flag;
	end block;

end architecture structural;


--
------------------------------------------
-- Byte controller section
------------------------------------------
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity byte_ctrl is
	port (
		clk : in std_logic;
		rst : in std_logic;		-- synchronous active high reset (WISHBONE compatible)
		nReset : in std_logic;	-- asynchornous active low reset (FPGA compatible)

		clk_cnt : in unsigned(15 downto 0);	-- 4x SCL 

		-- input signals
		ena,
		start,
		stop,
		read,
		write,
		ack_in : std_logic;
		Din : in std_logic_vector(7 downto 0);

		-- output signals
		cmd_ack : out std_logic;
		ack_out : out std_logic;
		Dout : out std_logic_vector(7 downto 0);
		i2c_busy : out std_logic;

		-- i2c signals
		SCLi : in std_logic;				-- I2C clock line
		SCLo : out std_logic;
		SDAi : in std_logic;				-- I2C data line
		SDAo : out std_logic
	);
end entity byte_ctrl;

architecture structural of byte_ctrl is
	component bit_ctrl is
	port (
		clk : in std_logic;
		rst : in std_logic;
		nReset : in std_logic;

		clk_cnt : in unsigned(15 downto 0);		-- clock prescale value

		ena : in std_logic;				-- core enable signal
		cmd : in std_logic_vector(2 downto 0);
		cmd_ack : out std_logic;
		busy : out std_logic;

		Din : in std_logic;
		Dout : out std_logic;

		SCLin : in std_logic;				-- I2C clock line
		SCLout : out std_logic;
		SDAin : in std_logic;				-- I2C data line
		SDAout : out std_logic
	);
	end component bit_ctrl;

	-- commands for i2c_core
	constant CMD_NOP	: std_logic_vector(2 downto 0) := "000";
	constant CMD_START	: std_logic_vector(2 downto 0) := "010";
	constant CMD_STOP	: std_logic_vector(2 downto 0) := "011";
	constant CMD_READ	: std_logic_vector(2 downto 0) := "100";
	constant CMD_WRITE	: std_logic_vector(2 downto 0) := "101";

	-- signals for bit_controller
	signal core_cmd : std_logic_vector(2 downto 0);
	signal core_ack, core_txd, core_rxd : std_logic;

	-- signals for shift register
	signal sr : std_logic_vector(7 downto 0); -- 8bit shift register
	signal shift, ld : std_logic;

	-- signals for state machine
	signal go, host_ack : std_logic;
begin
	-- hookup bit_controller
	u1: bit_ctrl port map (clk, rst, nReset, clk_cnt, ena, core_cmd, core_ack, i2c_busy, core_txd, core_rxd, SCLi, SCLo, SDAi, SDAo);

	-- generate host-command-acknowledge
	cmd_ack &lt;= host_ack;
	
	-- generate go-signal
	go &lt;= (read or write) and not host_ack;

	-- assign Dout output to shift-register
	Dout &lt;= sr;

	-- assign ack_out output to core_rxd (contains last received bit)
	ack_out &lt;= core_rxd;

	-- generate shift register
	shift_register: process(clk)
	begin
		if (clk'event and clk = '1') then
			if (ld = '1') then
				sr &lt;= din;
			elsif (shift = '1') then
				sr &lt;= (sr(6 downto 0) &amp; core_rxd);
			end if;
		end if;
	end process shift_register;

	--
	-- state machine
	--
	statemachine : block
		type states is (st_idle, st_start, st_read, st_write, st_ack, st_stop);
		signal state : states;
		signal dcnt : unsigned(2 downto 0);
	begin
		--
		-- command interpreter, translate complex commands into simpler I2C commands
		--
		nxt_state_decoder: process(clk, nReset, state)
			variable nxt_state : states;
			variable idcnt : unsigned(2 downto 0);
			variable ihost_ack : std_logic;
			variable icore_cmd : std_logic_vector(2 downto 0);
			variable icore_txd : std_logic;
			variable ishift, iload : std_logic;
		begin
			-- 8 databits (1byte) of data to shift-in/out
			idcnt := dcnt;

			-- no acknowledge (until command complete)
			ihost_ack := '0';

			icore_txd := core_txd;

			-- keep current command to bit_controller
			icore_cmd := core_cmd;

			-- no shifting or loading of shift-register
			ishift := '0';
			iload := '0';

			-- keep current state;
			nxt_state := state;
			case state is
				when st_idle =&gt;
					if (go = '1') then
						if (start = '1') then
							nxt_state := st_start;	
							icore_cmd := CMD_START;
						elsif (read = '1') then
							nxt_state := st_read;
							icore_cmd := CMD_READ;
							idcnt := "111";
						else
							nxt_state := st_write;
							icore_cmd := CMD_WRITE;
							idcnt := "111";
							iload := '1';
						end if;
					end if;

				when st_start =&gt;
					if (core_ack = '1') then
						if (read = '1') then
							nxt_state := st_read;
							icore_cmd := CMD_READ;
							idcnt := "111";
						else
							nxt_state := st_write;
							icore_cmd := CMD_WRITE;
							idcnt := "111";
							iload := '1';
						end if;
					end if;

				when st_write =&gt;
					if (core_ack = '1') then
						idcnt := dcnt -1;	-- count down Data_counter

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69成人精品免费视频| 日本二三区不卡| 亚洲成人av一区| 一区二区在线观看免费| 国产精品夫妻自拍| 国产精品不卡一区二区三区| 国产清纯白嫩初高生在线观看91| 精品国精品国产尤物美女| 日韩美女主播在线视频一区二区三区| 91精品国产综合久久香蕉的特点| 欧美日韩一区二区三区免费看| 欧美性生活影院| 欧美年轻男男videosbes| 欧美日韩电影一区| 3atv一区二区三区| 欧美不卡一区二区三区| 久久久99精品久久| 亚洲色图19p| 亚洲国产日日夜夜| 美脚の诱脚舐め脚责91| 国产另类ts人妖一区二区| 在线不卡一区二区| 日韩女优视频免费观看| 久久久久国产精品人| 国产精品的网站| 亚洲永久免费视频| 免费人成在线不卡| av成人老司机| 欧美精品三级在线观看| 国产亚洲制服色| 亚洲精品成人少妇| 久久电影国产免费久久电影| 国产·精品毛片| 日本丶国产丶欧美色综合| 欧美一级搡bbbb搡bbbb| 国产精品久久久久三级| 日本aⅴ免费视频一区二区三区| 国产一区中文字幕| 欧美精选一区二区| 国产无人区一区二区三区| 亚洲蜜臀av乱码久久精品| 久久国产尿小便嘘嘘尿| 一本一本大道香蕉久在线精品| 69成人精品免费视频| 国产免费久久精品| 蜜臀av国产精品久久久久| 高清免费成人av| 91精品国产欧美一区二区18 | 精品影视av免费| 91在线观看成人| 精品国产露脸精彩对白| 亚洲午夜影视影院在线观看| 国产不卡在线播放| 日韩精品一区二区三区视频播放| 一区二区三区精品在线观看| 国产精品一品二品| 日韩美女视频在线| 午夜精品福利一区二区三区av| www.色综合.com| 久久嫩草精品久久久久| 日本成人中文字幕在线视频| 日本精品一级二级| 丝瓜av网站精品一区二区| 色综合一个色综合亚洲| 中文字幕av不卡| 国产成人自拍网| 精品国产91久久久久久久妲己| 日本亚洲欧美天堂免费| 在线观看日产精品| 亚洲精品乱码久久久久久黑人| av动漫一区二区| 国产精品国产a| 99re热这里只有精品免费视频| 国产日韩精品一区二区三区 | 91久久一区二区| 亚洲欧美另类小说视频| 成人app下载| 中文字幕中文字幕在线一区| 国产成人精品免费网站| 中文字幕第一区第二区| 懂色中文一区二区在线播放| 国产日韩欧美麻豆| 国产成人亚洲精品狼色在线 | 亚洲已满18点击进入久久| 日韩欧美成人一区二区| 麻豆精品视频在线观看视频| 欧美成人一区二区| 九色综合狠狠综合久久| 久久这里只有精品6| 国产一区二区中文字幕| 国产日韩影视精品| 色综合久久综合中文综合网| 一级精品视频在线观看宜春院| 欧美午夜精品理论片a级按摩| 亚洲电影在线播放| 日韩午夜av电影| 国产91精品入口| 亚洲在线观看免费视频| 日韩一区二区三区免费看 | 国产精品一卡二| 国产精品国产三级国产三级人妇| 色婷婷av一区二区三区大白胸| 亚洲一区二区成人在线观看| 欧美精品第一页| 国内精品久久久久影院薰衣草| 中文字幕成人av| 精品视频1区2区| 国产精品自拍av| 亚洲影院理伦片| 久久久久一区二区三区四区| 91色porny| 日韩不卡一二三区| 国产欧美一区视频| 欧美三级视频在线播放| 看电影不卡的网站| 中文字幕一区二区三区不卡| 欧美三级电影网| 国产高清久久久| 香蕉加勒比综合久久| 欧美极品少妇xxxxⅹ高跟鞋| 91麻豆精品久久久久蜜臀| 91精品蜜臀在线一区尤物| 国产69精品一区二区亚洲孕妇| 日韩av电影免费观看高清完整版在线观看| 国产亚洲一二三区| 欧美日韩国产免费| 91免费视频网| 国产精品白丝av| 美女尤物国产一区| 亚洲国产精品一区二区www| 国产精品大尺度| 久久综合网色—综合色88| 欧美精品99久久久**| 97久久精品人人爽人人爽蜜臀| 国内精品伊人久久久久影院对白| 亚洲成人动漫精品| 亚洲亚洲精品在线观看| 中文字幕高清不卡| 国产日韩欧美精品综合| 精品国免费一区二区三区| 91精品国产色综合久久不卡蜜臀| 色视频欧美一区二区三区| 不卡的av在线播放| 成人免费高清在线| 国产成人久久精品77777最新版本| 奇米综合一区二区三区精品视频| 亚洲成在人线在线播放| 亚洲免费在线看| 亚洲视频一区二区在线| 国产精品欧美一级免费| 国产精品亲子伦对白| 国产精品久久久久久久久免费樱桃| 精品国产sm最大网站| 日韩女优视频免费观看| 精品免费99久久| 精品捆绑美女sm三区| 日韩视频在线你懂得| 精品久久久久久久人人人人传媒 | 99久久综合精品| www.欧美色图| 色悠悠久久综合| 欧美午夜精品久久久| 欧美精品1区2区| 欧美一级在线免费| 精品国产电影一区二区| 久久久久久久久一| 国产精品午夜在线观看| 亚洲免费观看在线视频| 午夜视频在线观看一区二区| 秋霞影院一区二区| 国产精品18久久久久| 国产aⅴ综合色| 色综合久久综合| 欧美一区二区三区人| 久久午夜老司机| 国产精品久久久久影视| 亚洲无线码一区二区三区| 九一九一国产精品| 99re热视频精品| 69av一区二区三区| 亚洲国产精品99久久久久久久久| 亚洲精品一二三四区| 蜜桃一区二区三区在线| 99久久精品免费观看| 欧美妇女性影城| 中文字幕av免费专区久久| 亚洲国产综合人成综合网站| 国产一区二区在线看| 在线免费一区三区| 久久网这里都是精品| 亚洲愉拍自拍另类高清精品| 久久99国产精品久久99果冻传媒| 成人av资源网站| 91精品国产入口| 亚洲品质自拍视频| 国产精品一区二区男女羞羞无遮挡| 色国产精品一区在线观看| 日韩欧美的一区| 亚洲国产精品精华液网站| 国产伦精品一区二区三区免费 |