EmbDev.net

Forum: FPGA, VHDL & Verilog get some outputsignals if cnt reaches an exact amount


von Steven Tumler (Guest)


Rate this post
useful
not useful
Hello Guys

I got a Problem. I made a shift register who is counting from 0 to 12 
over and over and Some Outputs.

It looks like this:
1
entity Ampel is
2
    Port ( ROT : out  STD_LOGIC;
3
           GRÜN : out  STD_LOGIC;
4
           GELB : out  STD_LOGIC;
5
           cnt : inout integer range 0 to 12:=0;
6
           clk : in  STD_LOGIC);
7
end Ampel;
8
9
architecture Behavioral of Ampel is
10
11
begin
12
process (clk)
13
begin
14
15
if rising_edge (clk) then
16
  if cnt=12 then cnt <= 0
17
   else          
18
   cnt <= cnt + 1;
19
    end if;
20
  end if;
21
end process;
22
23
24
25
26
end Behavioral;


If cnt = 0 - 4 ROT should be 1
if cnt = 5 GELB and ROT should be 1 and so on..

could anyone migth help me with this Problem ?

: Edited by Moderator
von -gb- (Guest)


Rate this post
useful
not useful
1
ROT <= '1' when cnt < 5 else '0';

Steven Tumler wrote:
> if cnt = 5 GELB and ROT should be 1 and so on..

Too unspecific.

Steven Tumler wrote:
> GRÜN

Contains "Ü" which may cause Problems.

Use the [vhdl] Tags for VHDL Code.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Steven Tumler wrote:
> cnt : inout integer range 0 to 12:=0;
Where the heck did you find this lazy coding style?
Is it your own way of reducing lines of code?

Short: never ever use a port as a signal. You will encounter strange 
problems in simulation later on.

> could anyone migth help me with this Problem ?
 What problems do you encounter? What do you want to happen? And what 
else happens instead? What error messages are reported by which 
toolchain?

> I made a shift register who is counting
You could use the German FPGA forum of µc.net if thats more convenient 
for you:
https://www.mikrocontroller.net/forum/fpga-vhdl-cpld

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.