完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
HI,
我想在PC和我的XIlinx FPGA(xc3s1600e)之间进行UART接口。我创建了UART Rx&的代码。 数字系统设计中的Tx部分和顶级文件使用Charles Roth的VHDL。在第11章他提供了代码。如何使用此代码开始模拟?如何在模拟中检查它是否正常工作。请帮我解决这个问题 问题。 感谢你,Mahesh Hegde。 以上来自于谷歌翻译 以下为原文 HI, I want UART interfacing between PC and my XIlinx FPGA (xc3s1600e).I founded the code for UART Rx & Tx part and top file for that in Digital System Design Using VHDL by Charles Roth .In 11th chapter he provided code.How to start simulation by using this code?How i can check wether it's working or not in simulation.Please help me regarding this problem. Thanks You in Advance, Mahesh Hegde. |
|
相关推荐
7个回答
|
|
None
以上来自于谷歌翻译 以下为原文 Hi, It's my simulation set up of UART.If i send 100 from Tx side it's transmitting well.I will receive this at Rx side.But at receiving side i am receiving 112.My suspection is "this is due to some clock related."Please see this and help me..... ----------------------------------------Tx Side--------------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity UART_Transmitter is port ( Bclk : in std_logic; sysclk : in std_logic; rst_b : in std_logic; TDRE : in std_logic; loadTDR : in std_logic; DBUS : in std_logic_vector(7 downto 0); setTDRE : out std_logic; TxD : out std_logic ); end UART_Transmitter; architecture xmit of UART_Transmitter is type stateType is (IDLE, SYNCH, TDATA); signal state, nextstate : stateType; signal TSR : std_logic_vector(8 downto 0); -- Transmit Shift Register signal TDR : std_logic_vector(7 downto 0); -- Transmit Data Register signal Bct : integer range 0 to 9; -- counts number of bits sent signal inc : std_logic; signal clr : std_logic; signal loadTSR : std_logic; signal shftTSR : std_logic; signal start : std_logic; signal Bclk_rising : std_logic; signal Bclk_dlayed : std_logic; begin TxD <= TSR(0); setTDRE <= loadTSR; Bclk_rising <= Bclk and (not Bclk_dlayed); -- indicates the rising edge of bit clock Xmit_Control: process(state, TDRE, Bct, Bclk_rising) begin inc <= '0'; clr <= '0'; loadTSR <= '0'; shftTSR <= '0'; start <= '0'; -- reset control signals case state is when IDLE => if (TDRE = '0' ) then loadTSR <= '1'; nextstate <= SYNCH; else nextstate <= IDLE; end if; when SYNCH => -- synchronize with the bit clock if (Bclk_rising = '1') then start <= '1'; nextstate <= TDATA; else nextstate <= SYNCH; end if; when TDATA => if (Bclk_rising = '0') then nextstate <= TDATA; elsif (Bct /= 9) then shftTSR <= '1'; inc <= '1'; nextstate <= TDATA; else clr <= '1'; nextstate <= IDLE; end if; end case; end process Xmit_Control; Xmit_update: process (sysclk, rst_b) begin if (rst_b = '0') then TSR <= "111111111"; state <= IDLE; Bct <= 0; Bclk_dlayed <= '0'; elsif (sysclk'event and sysclk = '1') then state <= nextstate; if (clr = '1') then Bct <= 0; elsif (inc = '1') then Bct <= Bct + 1; end if; if (loadTDR = '1') then TDR <= DBUS; end if; if (loadTSR = '1') then TSR <= TDR & '1'; end if; if (start = '1') then TSR(0) <= '0'; end if; if (shftTSR = '1') then TSR <= '1' & TSR(8 downto 1); -- shift out one bit end if; Bclk_dlayed <= Bclk; -- Bclk delayed by 1 sysclk end if; end process Xmit_update; end xmit; ---------------------------------------------Rx Side------------------------------------------------------ LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity UART_receiver is port ( Rxd : in std_logic; Bclkx8 : in std_logic; sysclk : in std_logic; rst_b : in std_logic; RDRF : in std_logic; RDR : out std_logic_vector (7 downto 0); setRDRF : out std_logic; setOE : out std_logic; setFE : out std_logic ); end UART_Receiver; Architecture rcvr of UART_receiver is type statetype is (IDLE,START_DETECTED,RECV_DATA); signal state,nextstate :statetype; signal RSR : std_logic_vector(7 downto 0); -- receive shift register signal ct1 : integer range 0 to 7; -- indicates when to read RXD input. signal ct2 : integer range 0 to 8; -- counts number of bits read. signal inc1 : std_logic; signal inc2 : std_logic; signal clr1 : std_logic; signal clr2 : std_logic; signal shftRSR : std_logic; signal loadRDR : std_logic; signal BclkX8_delayed : std_logic; signal BclkX8_rising : std_logic; begin BclkX8_rising <= BclkX8 and (not BclkX8_Delayed); -- indicates rising edge of bitX8 clock Rcvr_Control : process (state,RxD,RDRF,ct1,ct2,BclkX8_rising) begin -- reset control signal inc1 <= '0'; inc2 <= '0'; clr1 <= '0'; clr2 <= '0'; shftRSR <= '0'; loadRDR <= '0'; setRDRF <= '0'; setOE <= '0'; setFE <= '0'; case state is when IDLE => if(Rxd ='0') then nextstate <= START_DETECTED; else nextstate <= IDLE; end if; when START_DETECTED => if(BclkX8_rising = '0') then nextstate <= START_DETECTED; elsif(Rxd ='1') then clr1 <= '1'; nextstate <= IDLE; elsif(ct1 =3) then clr1 <= '1'; nextstate <= RECV_DATA; else inc1 <= '1'; nextstate <= START_DETECTED; end if; when RECV_DATA => if(BclkX8_rising ='0') then nextstate <= RECV_DATA; else inc1 <= '1'; if(ct1 /= 7) then nextstate <= RECV_DATA; -- wait for 8 clk cycles elsif(ct2 /= 8) then shftRSR <= '1'; inc2 <= '1'; clr1 <= '1'; -- read next data bit nextstate<= RECV_DATA; else nextstate <= IDLE; setRDRF <= '1'; clr1 <= '1'; clr2 <= '1'; if(RDRF = '1') then setOE <= '1'; -- oevr run error elsif(RxD = '0') then setFE <= '1'; -- frame error else loadRDR <= '1'; end if; -- load recv data reg end if; end if; end case; end process; Rcvr_update : process (sysclk,rst_b) begin if(rst_b = '0') then state <= IDLE ; BclkX8_Delayed <= '0'; ct1 <= 0 ; ct2 <= 0 ; elsif(sysclk'event and sysclk = '1') then state <= nextstate; if(clr1 ='1') then ct1 <= 0; elsif(inc1 ='1') then ct1 <= ct1 + 1; end if; if(clr2 ='1') then ct2 <= 0; elsif(inc2 = '1') then ct2 <= ct2 + 1 ; end if; if(shftRSR = '1') then RSR <= RxD & RSR (7 downto 1); end if; -- update shift reg. if(loadRDR = '1') then RDR <= RSR; end if; BclkX8_delayed <= BclkX8; -- BclkX8 delayed by 1 sysclk end if; end process; end rcvr; ------------------------------------Test Bench---------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity test_bench is end test_bench; Architecture behavioral of test_bench is signal clk : std_logic:='0'; signal sysclk : std_logic:='0'; signal rst : std_logic:='0'; signal clkx8 : std_logic:='0'; signal dbus : std_logic_vector(7 downto 0):= "01100100"; signal txd : std_logic; signal TDRE : std_logic; signal loadTDR : std_logic; signal setTDRE : std_logic; signal RDRF : std_logic; signal RDR : std_logic; signal setRDRF : std_logic; signal setOE : std_logic; signal setFE : std_logic; Component UART_Transmitter port ( Bclk : in std_logic; sysclk : in std_logic; rst_b : in std_logic; TDRE : in std_logic; loadTDR : in std_logic; DBUS : in std_logic_vector(7 downto 0); setTDRE : out std_logic; TxD : out std_logic ); end Component; Component UART_receiver port ( Rxd : in std_logic; Bclkx8 : in std_logic; sysclk : in std_logic; rst_b : in std_logic; RDRF : in std_logic; RDR : out std_logic_vector(7 downto 0); setRDRF : out std_logic; setOE : out std_logic; setFE : out std_logic ); end Component; begin inst_UART_Transmitter : UART_Transmitter port map ( Bclk => clk, sysclk => sysclk, rst_b => rst, DBUS => dbus, TxD => txd, TDRE => TDRE, loadTDR => loadTDR ); inst_UART_receiver : UART_receiver port map ( Rxd => TxD, Bclkx8 => clkx8, sysclk => sysclk, rst_b => rst, RDRF => RDRF, setRDRF => setRDRF, setOE => setOE, setFE => setFE ); clk <= not clk after 14 ns; sysclk <= not sysclk after 62.5 ns; clkx8 <= not clkx8 after 500 ns; rst <= '1' after 1 ns; TDRE <= '0' after 50 ns; loadTDR <= '1' after 50 ns; end behavioral; Thanks You in Advance, Mahesh Hegde.View solution in original post |
|
|
|
你好
听起来像你迈出了相当大的第一步, 尝试模拟一个小电路,如和门, 这将向您展示您需要的基础知识, 以上来自于谷歌翻译 以下为原文 Hi sounds like your taking a fairly big first step, try simulating a small circuit, like an and gate, that will show you the basics you need, |
|
|
|
maheshhegde写道:
HI, 我想在PC和我的XIlinx FPGA(xc3s1600e)之间进行UART接口。我创建了UART Rx&amp;的代码。 数字系统设计中的Tx部分和顶级文件使用Charles Roth的VHDL。在第11章他提供了代码。如何使用此代码开始模拟?如何在模拟中检查它是否正常工作。请帮我解决这个问题 问题。 你需要写一个测试台。 做一些搜索。 有很多东西需要学习。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 maheshhegde wrote:You need to write a test bench. Do some searching. There's a lot to learn. ----------------------------Yes, I do this for a living. |
|
|
|
嗨,
感谢您的建议。在UART Tx&amp; Rx部件在那里。我今天能够单独模拟这些部件。正如“bassman59”所说,要将这个(Rx和Tx)部件一起运行,测试台是必需的。这是对的。我对此有所了解。我没有 写了任何测试台。我独自在这里。我有开始的问题。有哪些文件或学习材料可以获得更多关于测试台的知识? 感谢你,Mahesh Hegde。 以上来自于谷歌翻译 以下为原文 Hi, Thank you for your suggestions.In UART Tx & Rx parts are there.I am able to simulate those parts seperately today.As told by "bassman59", to run this (Rx & Tx) parts together testbench is required .It's right.I have idea about that.i didn't written any test bench still.i am alone here.I am having starting problem.Any documents or study material is there to get more knowledge on TEST BENCH ? Thanks You in Advance, Mahesh Hegde. |
|
|
|
maheshhegde写道:
嗨, 感谢您的建议。在UART Tx&amp; Rx部件在那里。我今天能够单独模拟这些部件。正如“bassman59”所说,要将这个(Rx和Tx)部件一起运行,测试台是必需的。这是对的。我对此有所了解。我没有 写了任何测试台。我独自在这里。我有开始的问题。有哪些文件或学习材料可以获得更多关于测试台的知识? Janick Bergeron写了一本名为“编写测试平台”的书。 从那里开始。 ----------------------------是的,我这样做是为了谋生。 以上来自于谷歌翻译 以下为原文 maheshhegde wrote: There's a book by Janick Bergeron called "Writing Testbenches." Start there. ----------------------------Yes, I do this for a living. |
|
|
|
None
以上来自于谷歌翻译 以下为原文 Hi, It's my simulation set up of UART.If i send 100 from Tx side it's transmitting well.I will receive this at Rx side.But at receiving side i am receiving 112.My suspection is "this is due to some clock related."Please see this and help me..... ----------------------------------------Tx Side--------------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity UART_Transmitter is port ( Bclk : in std_logic; sysclk : in std_logic; rst_b : in std_logic; TDRE : in std_logic; loadTDR : in std_logic; DBUS : in std_logic_vector(7 downto 0); setTDRE : out std_logic; TxD : out std_logic ); end UART_Transmitter; architecture xmit of UART_Transmitter is type stateType is (IDLE, SYNCH, TDATA); signal state, nextstate : stateType; signal TSR : std_logic_vector(8 downto 0); -- Transmit Shift Register signal TDR : std_logic_vector(7 downto 0); -- Transmit Data Register signal Bct : integer range 0 to 9; -- counts number of bits sent signal inc : std_logic; signal clr : std_logic; signal loadTSR : std_logic; signal shftTSR : std_logic; signal start : std_logic; signal Bclk_rising : std_logic; signal Bclk_dlayed : std_logic; begin TxD <= TSR(0); setTDRE <= loadTSR; Bclk_rising <= Bclk and (not Bclk_dlayed); -- indicates the rising edge of bit clock Xmit_Control: process(state, TDRE, Bct, Bclk_rising) begin inc <= '0'; clr <= '0'; loadTSR <= '0'; shftTSR <= '0'; start <= '0'; -- reset control signals case state is when IDLE => if (TDRE = '0' ) then loadTSR <= '1'; nextstate <= SYNCH; else nextstate <= IDLE; end if; when SYNCH => -- synchronize with the bit clock if (Bclk_rising = '1') then start <= '1'; nextstate <= TDATA; else nextstate <= SYNCH; end if; when TDATA => if (Bclk_rising = '0') then nextstate <= TDATA; elsif (Bct /= 9) then shftTSR <= '1'; inc <= '1'; nextstate <= TDATA; else clr <= '1'; nextstate <= IDLE; end if; end case; end process Xmit_Control; Xmit_update: process (sysclk, rst_b) begin if (rst_b = '0') then TSR <= "111111111"; state <= IDLE; Bct <= 0; Bclk_dlayed <= '0'; elsif (sysclk'event and sysclk = '1') then state <= nextstate; if (clr = '1') then Bct <= 0; elsif (inc = '1') then Bct <= Bct + 1; end if; if (loadTDR = '1') then TDR <= DBUS; end if; if (loadTSR = '1') then TSR <= TDR & '1'; end if; if (start = '1') then TSR(0) <= '0'; end if; if (shftTSR = '1') then TSR <= '1' & TSR(8 downto 1); -- shift out one bit end if; Bclk_dlayed <= Bclk; -- Bclk delayed by 1 sysclk end if; end process Xmit_update; end xmit; ---------------------------------------------Rx Side------------------------------------------------------ LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity UART_receiver is port ( Rxd : in std_logic; Bclkx8 : in std_logic; sysclk : in std_logic; rst_b : in std_logic; RDRF : in std_logic; RDR : out std_logic_vector (7 downto 0); setRDRF : out std_logic; setOE : out std_logic; setFE : out std_logic ); end UART_Receiver; Architecture rcvr of UART_receiver is type statetype is (IDLE,START_DETECTED,RECV_DATA); signal state,nextstate :statetype; signal RSR : std_logic_vector(7 downto 0); -- receive shift register signal ct1 : integer range 0 to 7; -- indicates when to read RXD input. signal ct2 : integer range 0 to 8; -- counts number of bits read. signal inc1 : std_logic; signal inc2 : std_logic; signal clr1 : std_logic; signal clr2 : std_logic; signal shftRSR : std_logic; signal loadRDR : std_logic; signal BclkX8_delayed : std_logic; signal BclkX8_rising : std_logic; begin BclkX8_rising <= BclkX8 and (not BclkX8_Delayed); -- indicates rising edge of bitX8 clock Rcvr_Control : process (state,RxD,RDRF,ct1,ct2,BclkX8_rising) begin -- reset control signal inc1 <= '0'; inc2 <= '0'; clr1 <= '0'; clr2 <= '0'; shftRSR <= '0'; loadRDR <= '0'; setRDRF <= '0'; setOE <= '0'; setFE <= '0'; case state is when IDLE => if(Rxd ='0') then nextstate <= START_DETECTED; else nextstate <= IDLE; end if; when START_DETECTED => if(BclkX8_rising = '0') then nextstate <= START_DETECTED; elsif(Rxd ='1') then clr1 <= '1'; nextstate <= IDLE; elsif(ct1 =3) then clr1 <= '1'; nextstate <= RECV_DATA; else inc1 <= '1'; nextstate <= START_DETECTED; end if; when RECV_DATA => if(BclkX8_rising ='0') then nextstate <= RECV_DATA; else inc1 <= '1'; if(ct1 /= 7) then nextstate <= RECV_DATA; -- wait for 8 clk cycles elsif(ct2 /= 8) then shftRSR <= '1'; inc2 <= '1'; clr1 <= '1'; -- read next data bit nextstate<= RECV_DATA; else nextstate <= IDLE; setRDRF <= '1'; clr1 <= '1'; clr2 <= '1'; if(RDRF = '1') then setOE <= '1'; -- oevr run error elsif(RxD = '0') then setFE <= '1'; -- frame error else loadRDR <= '1'; end if; -- load recv data reg end if; end if; end case; end process; Rcvr_update : process (sysclk,rst_b) begin if(rst_b = '0') then state <= IDLE ; BclkX8_Delayed <= '0'; ct1 <= 0 ; ct2 <= 0 ; elsif(sysclk'event and sysclk = '1') then state <= nextstate; if(clr1 ='1') then ct1 <= 0; elsif(inc1 ='1') then ct1 <= ct1 + 1; end if; if(clr2 ='1') then ct2 <= 0; elsif(inc2 = '1') then ct2 <= ct2 + 1 ; end if; if(shftRSR = '1') then RSR <= RxD & RSR (7 downto 1); end if; -- update shift reg. if(loadRDR = '1') then RDR <= RSR; end if; BclkX8_delayed <= BclkX8; -- BclkX8 delayed by 1 sysclk end if; end process; end rcvr; ------------------------------------Test Bench---------------------------------------------------------- LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; entity test_bench is end test_bench; Architecture behavioral of test_bench is signal clk : std_logic:='0'; signal sysclk : std_logic:='0'; signal rst : std_logic:='0'; signal clkx8 : std_logic:='0'; signal dbus : std_logic_vector(7 downto 0):= "01100100"; signal txd : std_logic; signal TDRE : std_logic; signal loadTDR : std_logic; signal setTDRE : std_logic; signal RDRF : std_logic; signal RDR : std_logic; signal setRDRF : std_logic; signal setOE : std_logic; signal setFE : std_logic; Component UART_Transmitter port ( Bclk : in std_logic; sysclk : in std_logic; rst_b : in std_logic; TDRE : in std_logic; loadTDR : in std_logic; DBUS : in std_logic_vector(7 downto 0); setTDRE : out std_logic; TxD : out std_logic ); end Component; Component UART_receiver port ( Rxd : in std_logic; Bclkx8 : in std_logic; sysclk : in std_logic; rst_b : in std_logic; RDRF : in std_logic; RDR : out std_logic_vector(7 downto 0); setRDRF : out std_logic; setOE : out std_logic; setFE : out std_logic ); end Component; begin inst_UART_Transmitter : UART_Transmitter port map ( Bclk => clk, sysclk => sysclk, rst_b => rst, DBUS => dbus, TxD => txd, TDRE => TDRE, loadTDR => loadTDR ); inst_UART_receiver : UART_receiver port map ( Rxd => TxD, Bclkx8 => clkx8, sysclk => sysclk, rst_b => rst, RDRF => RDRF, setRDRF => setRDRF, setOE => setOE, setFE => setFE ); clk <= not clk after 14 ns; sysclk <= not sysclk after 62.5 ns; clkx8 <= not clkx8 after 500 ns; rst <= '1' after 1 ns; TDRE <= '0' after 50 ns; loadTDR <= '1' after 50 ns; end behavioral; Thanks You in Advance, Mahesh Hegde. |
|
|
|
你好,
我正在测试台进行uart测试,所以我按照查尔斯罗斯给出的代码...第385页 addr r_w动作 00 1 dbus UART.txt 7 KB 以上来自于谷歌翻译 以下为原文 hello, I am doing uart test in test benches so i followed the code given in charles roth ... page 385 addr r_w action 00 1 dbus <- rdr 00 0 tdr <- dbus 01 1 dbus <- scsr 01 0 dbus <-hi-z 1_ 1 dbus <- sccr 1_ 0 sccr <- dbus i followed the above data is not being transmitted on th dbus .....i am getting hiz .....i am doing uart code in VERILOG not vhdl .... i am attaching notepad file ...in which my entire code is present ... so i couldnt know the problem ...... UART.txt 7 KB |
|
|
|
只有小组成员才能发言,加入小组>>
2424 浏览 7 评论
2826 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2294 浏览 9 评论
3375 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2465 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1252浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
590浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
453浏览 1评论
2008浏览 0评论
732浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 22:18 , Processed in 1.670006 second(s), Total 89, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号