关于控制总线信号时序的HDL描述问题!
时间:10-02
整理:3721RD
点击:
关于控制总线信号的VHDL描述我目前知道的两种方法,方法如下:
第一种:commond_cnt是一个按输入时钟为源的计数器,按照控制信号的时序顺序来依次给信号赋值法:
case commond_cnt is
when x"0fa2" => --enable the control signal
iodir_reg<='1'; --output
ale_reg<='0';
cle_reg<='1';
we_reg<='0';
wp_reg<='1';
re_reg<='1';
databusout_reg<=x"70";
cs_out_reg<=(others=>'0');
when x"0fa4"=>
we_reg<='1'; --input the read status commond
when x"0fb0"=>
cle_reg<='0';
--
databusout_reg(7 downto 0)<=x"70"; --input the read_status commond
cs_out_reg<=(0=>'0',others=>'1'); --just enable the cs1 chip;
--
we_reg<='0';
--
when x"0fb3" =>
--
we_reg<='1';
when x"0fb8"=> --read the status byte
iodir_reg<='0'; --change the dir of the port to input
--
cle_reg<='0';
when x"0fbf"=>
re_reg<='0'; --falling edge of the re to capture the status byte
when x"0fd0"=>
iodir_reg<='1'; --output
re_reg<='1';
第二种:根据各个时间点,各信号的电平情况单独赋值:
if(cnt=x"0001" or cnt=x"0005") then
cle<='1';
else
cle<='0';
end if;
if(cnt>x"1" and cnt<x"0005") then
ale<='1';
else
ale<='0';
end if;
if(cnt>x"0000" and cnt<x"0006")then
flag_we:=not flag_we;
we<=not flag_we;
else
we<='1';
end if;
想问一下到底该用哪种方法呢?这两种方法有什么区别?我是觉得第一种方法可读性强一些;
第一种:commond_cnt是一个按输入时钟为源的计数器,按照控制信号的时序顺序来依次给信号赋值法:
case commond_cnt is
when x"0fa2" => --enable the control signal
iodir_reg<='1'; --output
ale_reg<='0';
cle_reg<='1';
we_reg<='0';
wp_reg<='1';
re_reg<='1';
databusout_reg<=x"70";
cs_out_reg<=(others=>'0');
when x"0fa4"=>
we_reg<='1'; --input the read status commond
when x"0fb0"=>
cle_reg<='0';
--
databusout_reg(7 downto 0)<=x"70"; --input the read_status commond
cs_out_reg<=(0=>'0',others=>'1'); --just enable the cs1 chip;
--
we_reg<='0';
--
when x"0fb3" =>
--
we_reg<='1';
when x"0fb8"=> --read the status byte
iodir_reg<='0'; --change the dir of the port to input
--
cle_reg<='0';
when x"0fbf"=>
re_reg<='0'; --falling edge of the re to capture the status byte
when x"0fd0"=>
iodir_reg<='1'; --output
re_reg<='1';
第二种:根据各个时间点,各信号的电平情况单独赋值:
if(cnt=x"0001" or cnt=x"0005") then
cle<='1';
else
cle<='0';
end if;
if(cnt>x"1" and cnt<x"0005") then
ale<='1';
else
ale<='0';
end if;
if(cnt>x"0000" and cnt<x"0006")then
flag_we:=not flag_we;
we<=not flag_we;
else
we<='1';
end if;
想问一下到底该用哪种方法呢?这两种方法有什么区别?我是觉得第一种方法可读性强一些;
自己顶一下!
比较代码质量无非几个参数:代码健壮性,使用的资源多少,可读性,可扩展性。
要是你前面的都没问题,可读性与可扩展性就比较重要。
第一种资源用得少啊
