vhdl - 具有外部触发和触发输出的 VHDL 脉冲生成
问题描述
我被困在这个程序中,以从外部触发和内部触发创建自定义脉冲。
这是我的外部触发程序。它将从“trig_in”输入端口获取触发信号以生成自定义脉冲:
if state_trig = extrig then
if (trig_in = '1') then
counter1 <= "000000";
if(counter >= 1 and counter <= 2) then
pwm_out1 <= '1';
pwm_out2 <= '0';
end if;
if(counter > 2 and counter <= 600) then
pwm_out1 <= '0';
pwm_out2 <= '0';
end if;
if(counter > 600 and counter <= 3000) then
pwm_out1 <= '1';
pwm_out2 <= '1';
end if;
counter <= counter + 1;
else if (trig_in = '0') then
counter <= "000000";
counter1 <= counter1 + 1;
if (counter1 >= 2100) then
pwm_out1 <= '0';
pwm_out2 <= '0';
end if;
end if;
end if;
end if;
这是内部触发的程序。它将生成一个 1kHz 重复脉冲以在“trig_out”输出端口上触发:
if state_trig = intrig then
--1kHz
if(i >= 1 and i <= 2) then
pwm_out1 <= '1';
pwm_out2 <= '0';
end if;
if(i > 2 and i <= 600) then
pwm_out1 <= '0';
pwm_out2 <= '0';
end if;
if(i > 600 and i <= 3000) then
pwm_out1 <= '1';
pwm_out2 <= '1';
end if;
if(i > 3000) then
pwm_out1 <= '0';
pwm_out2 <= '0';
end if;
if(i = 300000) then i := 0; end if;
i := i + 1;
end if;
end if;
我使用 fsm 状态来确定“extrig”和“intrig”状态。
type fsm_trig is (none, intrig, extrig);
signal state_trig : fsm_trig := none;
两个程序分别工作完美。但是当我将它们都放在一个进程(时钟)中时。每个触发程序中产生的脉冲相互冲突。我正在使用 UART 来确定触发器的状态。将两个信号“pwm_out1”和“pwm_out2”分配给输出端口以生成脉冲:
out_clk1 <= pwm_out1;
out_clk2 <= pwm_out2;
以下是两个程序的端口:
sys_clk : in STD_LOGIC; --system clock
rx : in STD_LOGIC; --receive for UART
trig_in : in STD_LOGIC; --External trigger
trig_out : out STD_LOGIC; --Internal trigger
out_clk1 : out STD_LOGIC; --Pulse out1
out_clk2 : out STD_LOGIC; --Pulse out2
请给我任何想法以避免两个程序之间的冲突。提前致谢。
解决方案
推荐阅读
- java - 如何使用 Spring MVC 进行正确的重定向?
- ios - 在范围内找不到类型“GADRequestError”
- wso2 - wso2 api manager 2.6.0 Suspending endpoint : AnonymousEndpoint with address https://{uri.var.hostname}:{uri.var.portnum}/oauth2/token
- shopify - Shoppify include image with max height in liquid template
- django - Using Taiga6 with Docker and an SMTP Server that does not require authentication
- reporting-services - SSRS Ignore some data in column group totals
- java - How can we pass topic and subscription name from yaml in azure function - java
- python - BeautifulSoup scraping pactpub html element returns empty item
- angular - 如何使用我的 asp.net 核心项目发布外部 Angular 文件夹?
- css - 如何更改角度组件中mat-checkbox的角度材料复选框的css