- Joined
- Jul 28, 2008
- Messages
- 22
- Reaction score
- 0
Hi. I have not experience in vhdl but i need to make work this code! It is very important!
I explain the problem. I have a 24 bits vector as input (B). The input dataready is a signal that is high when B must be read(it is a strobe). I want that the output signal Bup is a 1 microsecond pulse only when B increases. clk50 is a 50 MHz clock. On the contrary these two my processes give 1 microsecond pulses but not always and something also when B does not increase.
WHY???????Thank you very much for your help
rst<=dataready;
gatepr: process (B,dataready,rst)
variable lastB : std_logic_vector (23 downto 0);
begin
if rst='0' then
up<='0';
elsif (dataready'event and dataready = '1') then
if B>lastB then
up<='1';
end if;
Bdiff<=B-lastB;
lastB:=B;
end if;
end process gatepr;
spero: process(up,clk50)
variable conta: integer:=51;
variable last_up: std_logic;
begin
if clk50'event and clk50='1' then
if (up='1' and last_up='0') then
conta:=0;
elsif conta<50 then
Bup<='1';
elsif conta>=50 then
Bup<='0';
end if;
last_up:=up;
conta:=conta+1;
end if;
end process spero;
I explain the problem. I have a 24 bits vector as input (B). The input dataready is a signal that is high when B must be read(it is a strobe). I want that the output signal Bup is a 1 microsecond pulse only when B increases. clk50 is a 50 MHz clock. On the contrary these two my processes give 1 microsecond pulses but not always and something also when B does not increase.
WHY???????Thank you very much for your help
rst<=dataready;
gatepr: process (B,dataready,rst)
variable lastB : std_logic_vector (23 downto 0);
begin
if rst='0' then
up<='0';
elsif (dataready'event and dataready = '1') then
if B>lastB then
up<='1';
end if;
Bdiff<=B-lastB;
lastB:=B;
end if;
end process gatepr;
spero: process(up,clk50)
variable conta: integer:=51;
variable last_up: std_logic;
begin
if clk50'event and clk50='1' then
if (up='1' and last_up='0') then
conta:=0;
elsif conta<50 then
Bup<='1';
elsif conta>=50 then
Bup<='0';
end if;
last_up:=up;
conta:=conta+1;
end if;
end process spero;
Last edited: