- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
EDA(中国地质大学 )课堂作业
1题:4选1生成8个
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ff is
port(ain:in std_logic_vector(3 downto 0);
sel:in std_logic_vector(1 downto 0);
y:out std_logic );
end ;
architecture bhv of ff is
begin
y=ain(conv_integer(sel));
end bhv;
library ieee;
use ieee.std_logic_1164.all;
package newtype is
type ary84 is array (7 downto 0,3 downto 0) of std_logic;
type ary82 is array (7 downto 0,1 downto 0) of std_logic;
End package;
library ieee;
use ieee.std_logic_1164.all;
use work.newtype.all;
entity f is
port(ain84:in ary84;
sel84:in ary82;
y84:out std_logic_vector(7 downto 0);
count:out std_logic);
end ;
architecture t of f is
component ff is
port(ain:in std_logic_vector(3 downto 0);
sel:in std_logic_vector(1 downto 0);
y:out std_logic );
end component;
signal y841: std_logic_vector(7 downto 0);
begin
gen1:for n in 0 to 7 generate
ux: ff port map(ain84(n,3)ain84(n,2)ain84(n,1)ain84(n,0),
sel84(n,1)sel84(n,0),y841(n));
end generate;
y84=y841;
process(y841)
variable tmp:std_logic;
begin
tmp:=1;
for i in 0 to 7 loop
tmp:=tmp and y841(i);
end loop;
count=tmp;
end process;
end architecture;
2题:5-4状态机
library ieee;
use ieee.std_logic_1164.all;
entity ff is
port(clk,res:in std_logic;
ina:in std_logic_vector(0 to 2);
outa:out std_logic_vector(3 downto 0));
end ff;
architecture f1 of ff is
type sta is(s0,s1,s2,s3);
signal cs,ns:sta;
begin
reg:process(clk,res) begin
if res=1 then cs=s0;
elsif clkevent and clk=1 then cs=ns;end if;
end process;
com:process(cs,ina) begin
case cs is
when s0= ns=s1;
if ina=101 then outa=0010;
elsif ina=111 then outa=1100;
end if;
when s1= outa=1001;
if ina=000 then ns=s1;
elsif ina=110 then ns=s2;else ns=s2;
end if;
when s2= outa=1111;
if ina=011 then ns=s1;
elsif ina=100 then ns=s2;
else ns=s3;
end if;
when s3= ns=s0;
if ina=101 then outa=1101;
els
文档评论(0)