Browse Source

Add sequencer and first examples

* sequencer for easy waveform generation of
  simple 1 bit std_logic signals
* Package with sequencer component delaration
* Examples for always & never operator
master
T. Meissner 5 years ago
parent
commit
263dcae830
4 changed files with 127 additions and 0 deletions
  1. +19
    -0
      src/pkg.vhd
  2. +34
    -0
      src/psl_always.vhd
  3. +34
    -0
      src/psl_never.vhd
  4. +40
    -0
      src/sequencer.vhd

+ 19
- 0
src/pkg.vhd View File

@ -0,0 +1,19 @@
library ieee;
use ieee.std_logic_1164.all;
package pkg is
component sequencer is
generic (
seq : string
);
port (
clk : in std_logic;
data : out std_logic
);
end component sequencer;
end package pkg;

+ 34
- 0
src/psl_always.vhd View File

@ -0,0 +1,34 @@
library ieee;
use ieee.std_logic_1164.all;
use work.pkg.all;
entity psl_always is
port (
clk : in std_logic
);
end entity psl_always;
architecture psl of psl_always is
signal a : std_logic;
begin
SEQ : sequencer generic map ("_-_-_") port map (clk, a);
-- All is sensitive to rising edge of clk
default clock is rising_edge(clk);
-- Signal a has to be low at cycle 0 only
WITHOUT_ALWAYS_a : assert a;
-- Signal a has to be low forever
WITH_ALWAYS_a : assert always a;
end architecture psl;

+ 34
- 0
src/psl_never.vhd View File

@ -0,0 +1,34 @@
library ieee;
use ieee.std_logic_1164.all;
use work.pkg.all;
entity psl_never is
port (
clk : in std_logic
);
end entity psl_never;
architecture psl of psl_never is
signal a : std_logic;
begin
SEQ : sequencer generic map ("_-_-_") port map (clk, a);
-- All is sensitive to rising edge of clk
default clock is rising_edge(clk);
-- Signal a has to be low forever
NEVER_a : assert never a;
-- Equivalent assert with always and negation
ALWAYS_a : assert always not a;
end architecture psl;

+ 40
- 0
src/sequencer.vhd View File

@ -0,0 +1,40 @@
library ieee;
use ieee.std_logic_1164.all;
entity sequencer is
generic (
seq : string
);
port (
clk : in std_logic;
data : out std_logic
);
end entity sequencer;
architecture rtl of sequencer is
signal cycle : natural := 0;
signal ch : character;
begin
process (clk) is
begin
if rising_edge(clk) then
if (cycle < seq'length) then
cycle <= cycle + 1;
end if;
end if;
end process;
ch <= seq(cycle+1);
data <= '0' when ch = '0' or ch = '_' else
'1' when ch = '1' or ch = '-' else
'X';
end architecture rtl;

Loading…
Cancel
Save