File: nolatch3.vhdl

package info (click to toggle)
ghdl 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,000 kB
  • sloc: ada: 309,826; vhdl: 209,727; ansic: 31,072; python: 19,213; sh: 14,214; cpp: 2,345; makefile: 1,542; pascal: 585; asm: 45; exp: 40; fortran: 33
file content (58 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
entity nolatch2 is
  port (sel : bit;
        rst : bit;
        clk : bit;
        r : out bit);
end;

architecture arch of nolatch2 is
  type t_enum is (S0, S1, S2, S3, S4);
  signal state, nstate : t_enum;
begin
  process (all)
    variable a : bit;
  begin
    nstate <= state;
    r <= '0';
    
    case state is
      when S0 =>
        if sel = '0' then
          nstate <= S1;
        end if;
      when S1 =>
        if sel = '0' then
          nstate <= S2;
        end if;
      when S2 =>
        if sel = '1' then
          nstate <= S3;
        end if;
      when S3 =>
        r <= '1';
        if sel = '1' then
          a := '1';
          r <= '0';
        end if;
        nstate <= S4;
      when S4 =>
        if sel = '1' then
          nstate <= S2;
        else
          nstate <= S0;
        end if;
    end case;
  end process;

  process (clk)
  begin
    if clk'event and clk = '1' then
      if rst = '1' then
        state <= S0;
      else
        state <= nstate;
      end if;
    end if;
  end process;
end;