帮忙修改VHDL 语言程序

来源:百度知道 编辑:UC知道 时间:2024/05/21 17:00:00
程序如下:目的实现模24和模12的切换
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity h_smod is
port (clk,rst,set: in std_logic;
cq : out std_logic_vector (7 downto 0);
cout: out std_logic);
end h_smod;
architecture behav of h_smod is
variable cq1 : std_logic_vector(7 downto 0);
variable c1:std_logic;
variable cq2 : std_logic_vector(7 downto 0);
variable c2:std_logic;
begin
p1:process (clk, rst)
begin
if rst ='1' then cq1:=(others=>'0');
elsif clk'event and clk='1'then
if cq1<24 then cq1:=cq1+1;
else cq1:= (others=>'0');
end if;
end if;
if cq1=24 then c1:='1';
else c1:='0';
end if;
end process p1;
p2:process (clk, rst)
begin
if rst ='1' then cq2:=(others=>'0');

不算答案,提几个语法上的意见。
不要用veriable,不适于综合,用signal。
cq1是std_logic_vector就不要用24之类的,要不用二进制表示24,要不cq1改成integer型。
:=赋值没延时,<=赋值有延时,一般用后者。
敏感列表里没写全,比如缺cq1和cq2。

内容没时间看了见谅。