usb 发表于 2010-6-28 12:01:37

你到底想问什么呀?

usd 发表于 2010-6-28 12:09:02

我觉得最好能有人给出个串并并串的例子,这样就好了,光说个移位寄存器,不明白啊,和楼主一同期待

interig 发表于 2010-6-28 13:43:09

还是要个完整的例子才适合我们这样的入门菜鸟

VVIC 发表于 2010-6-28 13:46:18

顶一个,确实不错

longt 发表于 2010-6-28 14:30:07

都可以采用移位寄存器实现

longt 发表于 2010-6-28 15:28:44

begin<br>
counter: process(reset,clk,shift_start)<br>
begin<br>
&nbsp;&nbsp;if(reset = '0') then<br>
&nbsp; &nbsp;cnt &lt;= (others =&gt; '0');<br>
&nbsp;&nbsp;elsif(clk'event and clk = '1') then<br>
&nbsp; &nbsp;if(shift_start = '0') then<br>
&nbsp; &nbsp; cnt &lt;= cnt + 1;<br>
&nbsp; &nbsp;else<br>
&nbsp; &nbsp; cnt &lt;= (others =&gt; '0');<br>
&nbsp; &nbsp;end if;<br>
&nbsp;&nbsp;end if;<br>
end process counter;<br>
<br>
fsm: block<br>
begin<br>
&nbsp;&nbsp;sync: process(reset,clk)<br>
&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;if(reset= '0') then<br>
&nbsp; &nbsp; current_state &lt;= idle;<br>
&nbsp; &nbsp;elsif(clk'event and clk = '1') then<br>
&nbsp; &nbsp; current_state &lt;= next_state;<br>
&nbsp; &nbsp;end if;<br>
&nbsp;&nbsp;end process sync;<br>
<br>
&nbsp;&nbsp;comb: process(current_state,cnt,start)<br>
&nbsp;&nbsp;begin<br>
&nbsp; &nbsp;case current_state is<br>
&nbsp; &nbsp; when idle =&gt;<br>
&nbsp; &nbsp;&nbsp;&nbsp;ready &lt;= '0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;reg_en &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;shift_start &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;data_valid &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;if(start = '0') then<br>
&nbsp; &nbsp;&nbsp; &nbsp;reg_en &lt;= '0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;next_state &lt;= recieve;<br>
&nbsp; &nbsp;&nbsp;&nbsp;else<br>
&nbsp; &nbsp;&nbsp; &nbsp;next_state &lt;= idle;<br>
&nbsp; &nbsp;&nbsp;&nbsp;end if;<br>
&nbsp; &nbsp; when recieve =&gt;<br>
&nbsp; &nbsp;&nbsp;&nbsp;reg_en &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;ready &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;data_valid &lt;= '0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;shift_start &lt;= '0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;next_state &lt;= shift;<br>
&nbsp; &nbsp; when shift =&gt;<br>
&nbsp; &nbsp;&nbsp;&nbsp;reg_en &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;ready &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;data_valid &lt;= '0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;if(cnt = 8) then<br>
&nbsp; &nbsp;&nbsp; &nbsp;shift_start &lt;= '1';<br>
&nbsp; &nbsp;&nbsp; &nbsp;next_state &lt;= finish;<br>
&nbsp; &nbsp;&nbsp;&nbsp;else<br>
&nbsp; &nbsp;&nbsp; &nbsp;shift_start &lt;= '0';&nbsp; &nbsp;&nbsp; &nbsp;<br>
&nbsp; &nbsp;&nbsp; &nbsp;next_state &lt;= shift;<br>
&nbsp; &nbsp;&nbsp;&nbsp;end if;<br>
&nbsp; &nbsp; when finish =&gt;<br>
&nbsp; &nbsp;&nbsp;&nbsp;reg_en &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;ready &lt;= '0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;data_valid &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;shift_start &lt;= '1';<br>
&nbsp; &nbsp;&nbsp;&nbsp;next_state &lt;= idle;<br>
&nbsp; &nbsp; when others =&gt;<br>
&nbsp; &nbsp;&nbsp;&nbsp;next_state &lt;= idle;<br>
&nbsp; &nbsp;end case;<br>
&nbsp;&nbsp;end process comb;<br>
<br>
end block fsm;<br>
<br>
data_channel: process(reset,clk)<br>
begin<br>
&nbsp;&nbsp;if(reset = '0') then<br>
&nbsp; &nbsp;reg &lt;= (others =&gt; '0');<br>
&nbsp; &nbsp;q&nbsp; &nbsp;&lt;= '0';<br>
&nbsp;&nbsp;elsif(clk'event and clk = '1') then<br>
&nbsp; &nbsp;if(reg_en = '0') then<br>
&nbsp; &nbsp; reg &lt;= data_in;<br>
&nbsp; &nbsp;elsif(shift_start = '0') then<br>
&nbsp; &nbsp; q &lt;= reg(7);<br>
&nbsp; &nbsp; for i in 7 downto 1 loop&nbsp; &nbsp; --shift register<br>
&nbsp; &nbsp;&nbsp;&nbsp;reg(i) &lt;= reg(i - 1);<br>
&nbsp; &nbsp; end loop;<br>
&nbsp; &nbsp; reg(0) &lt;= '0';<br>
&nbsp; &nbsp;else&nbsp;&nbsp;<br>
&nbsp; &nbsp; q &lt;= '0';<br>
&nbsp; &nbsp;end if;<br>
&nbsp;&nbsp;end if;<br>
end process data_channel; <br>
<br>
end Behavioral;<br>
<br>
并串转换,,整个代码已经通过了后仿真,而且思路还是比较清楚的,可靠性和稳定性方面也应该没有问题滴,呵呵。不过说老实话,里面有些信号是确实可以去掉的,不过后来就懒得改了。如果谁想要实际的工程中用的话可以改一下。

longtime 发表于 2010-6-28 16:24:20

随便一本教硬件语言的都有吧

UFP 发表于 2010-6-28 17:07:31

移位寄存器和状态机都可以,不过移位寄存器要简单的多

usb 发表于 2010-6-28 17:39:53

就是状态机有一点麻烦,不过有时候却有好处

HDL 发表于 2010-6-28 17:45:10

很简单的,就用移位寄存器搞定
页: 1 [2] 3
查看完整版本: 请教串并并串转换原理