【发布时间】:2019-07-31 10:52:29
【问题描述】:
我正在制作一个包含公共入口和出口的多级停车场系统模块,其想法是,当我从信号 car entry 或 car exit 获得输入刺激时,它将检查汽车的类型,然后检查输出应该显示为特定类型预留的级别,汽车应该去哪里,如果为特定类型预留的插槽已满,则显示应该这样输出。代码通过输出得到刺激,只有在给定输入刺激后的下一个时钟周期后才会显示。
我尝试过使用不同的 if-else 块进行计数操作,也尝试过使用标志的不同进程,并尝试将其更改为不同的 if-else 块,但它仍然相同。我是vhdl的初学者,语句的执行很混乱,网上搜索帮助不大,请帮助我哪里出错了?
library ieee;
use ieee.std_logic_1164.all;
use ieee.Numeric_std.all;
use work.Parking_Package.all;
entity CarPark is
port( clk :in std_logic;
rst : in std_logic;
car_in : in std_logic;
Car_out : in std_logic;
Ent_car_type : car_type;
Ext_car_type : car_type;
Status : out level
);
end CarPark;
architecture behave of CarPark is
signal count : counter;
begin
SLOT_CHECKING: process(rst,clk)
begin
if(rst= '1')then
count <= (others => 0);
Status <= FULL;
elsif(rising_edge(clk))then
if(car_in )then
case(Ent_car_type)is
when Admin =>
if(count(Admin) < 5) then
Status <= L1;
count(Admin) <= count(Admin) +1;
else
Status <= FULL;
end if;
when Staff =>
if(count(Staff) < 5) then
Status <= L2;
count(Staff) <= count(Staff) + 1;
else
Status <= FULL;
end case;
end if;
elsif(car_out)then
case(Ext_car_type)is
when Admin =>
if(count(Admin) >0) then
Status <= L1a;
count(Admin) <= count(Admin) - 1;
else
count(Admin)<= 0;
end if;
when Staff =>
if(count(Staff) >0) then
Status <= L2a;
count(Staff) <= count(Staff) - 1;
else
count(Staff) <= 0;
end if;
end process;
end behave;
用户定义包如下
library ieee;
use ieee.std_logic_1164.all;
use ieee.Numeric_std.all;
package Parking_Package is
type car_type is (Admin, Staff);
type level is (L1, L2a, FULL);
type counter is array (Staff downto Admin) of integer range 0 to 22;
end Parking_Package;
package body Parking_Package is
end Parking_Package;
使用重置初始化后,我将car_in 的输入作为 1 和
car_type 作为管理员,输出在 下一个时钟 中显示为 L1
如果我将car_type的值强制为staff,则在下一个时钟周期模拟相应的输出。
![屏幕截图模拟]https://imgur.com/a/B6cqADn
【问题讨论】:
-
我不太明白你的问题。您的模拟行为似乎不错。
-
@Gautitho 请参考链接中的图片,每当
Ent_Car_type被强制为一个值时,输出Status就会显示下一个时钟周期的变化。我希望输出显示相同时钟周期内的变化,即给出变化输入时。