Hi,
See search for "data_ptr_c" int the reference design here:
http://home.comcast.net/~mike_treseler/
I put the bus interface constants in a package
to share with the testbench.
I use a port address and data buses between entities.
I infer io registers locally using variable declarations.
Thanks for your answer. The Address is only one bit unfortunately. Here
is my address decoder, which looks very complicated and error prune to
me. I wrote some functions, which I can't use as I would like. Maybe
someone can give me hint to write it more compact since there are coming
more addresses which will follow the same schematic.
Thanks
Olaf
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package decoder_pkg is
subtype address_t is unsigned(7 downto 0);
subtype register_t is std_ulogic_vector(31 downto 0);
constant trigger_control : address_t := x"00";
constant trigger_config : address_t := x"10";
constant trg0_bit_value : address_t := x"20";
constant trg1_bit_value : address_t := x"21";
constant trg2_bit_value : address_t := x"22";
constant trg3_bit_value : address_t := x"23";
constant trg4_bit_value : address_t := x"24";
constant trg5_bit_value : address_t := x"25";
constant trg6_bit_value : address_t := x"26";
constant trg7_bit_value : address_t := x"27";
constant trg0_bit_mask : address_t := x"30";
constant trg1_bit_mask : address_t := x"31";
constant trg2_bit_mask : address_t := x"32";
constant trg3_bit_mask : address_t := x"33";
constant trg4_bit_mask : address_t := x"34";
constant trg5_bit_mask : address_t := x"35";
constant trg6_bit_mask : address_t := x"36";
constant trg7_bit_mask : address_t := x"37";
constant trg0_re_mask : address_t := x"40";
constant trg1_re_mask : address_t := x"41";
constant trg2_re_mask : address_t := x"42";
constant trg3_re_mask : address_t := x"43";
constant trg4_re_mask : address_t := x"44";
constant trg5_re_mask : address_t := x"45";
constant trg6_re_mask : address_t := x"46";
constant trg7_re_mask : address_t := x"47";
constant trg0_fe_mask : address_t := x"50";
constant trg1_fe_mask : address_t := x"51";
constant trg2_fe_mask : address_t := x"52";
constant trg3_fe_mask : address_t := x"53";
constant trg4_fe_mask : address_t := x"54";
constant trg5_fe_mask : address_t := x"55";
constant trg6_fe_mask : address_t := x"56";
constant trg7_fe_mask : address_t := x"57";
constant trg0_edge_mask : address_t := x"60";
constant trg1_edge_mask : address_t := x"61";
constant trg2_edge_mask : address_t := x"62";
constant trg3_edge_mask : address_t := x"63";
constant trg4_edge_mask : address_t := x"64";
constant trg5_edge_mask : address_t := x"65";
constant trg6_edge_mask : address_t := x"66";
constant trg7_edge_mask : address_t := x"67";
end package;
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.decoder_pkg.all;
entity decoder is
generic (
TRIGGER_DEPTH : integer range 1 to 8 := 2;
RESET_ACTIVE : std_ulogic := '1');
port (
conf_clk : in std_ulogic;
reset : in std_ulogic;
address : in std_ulogic_vector(7 downto 0);
data : in std_ulogic_vector(31 downto 0);
-- decoded address signals
set_bit_value : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
set_bit_mask : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
set_re_mask : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
set_fe_mask : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
set_edge_mask : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
set_config : out std_ulogic_vector(TRIGGER_DEPTH-1 downto 0);
glitch_capture : out std_ulogic;
arm : out std_ulogic);
end entity;
architecture behavioral of decoder is
signal config_reg : std_ulogic_vector(31 downto 0);
signal control_reg : std_ulogic_vector(31 downto 0);
begin
decode: process (conf_clk) is
variable addr : unsigned(address'range);
----------------------------------------
procedure reset_register is
begin
config_reg <= (others => '0');
control_reg <= (others => '0');
-- trigger register
set_bit_value <= (others => '0');
set_bit_mask <= (others => '0');
set_re_mask <= (others => '0');
set_fe_mask <= (others => '0');
set_edge_mask <= (others => '0');
set_config <= (others => '0');
end procedure;
-----------------------------------------
impure function trigger_no return integer is
variable no : unsigned(3 downto 0);
begin
return to_integer(no);
end function;
------------------------------------------
procedure dispatch_bit_value is
begin
set_bit_value(trigger_no) <= '1';
end procedure;
----------------------------------------
procedure dispatch_bit_mask is
begin
set_bit_mask(trigger_no) <= '1';
end procedure;
-----------------------------------------
begin
if rising_edge(conf_clk) then
if (reset = RESET_ACTIVE) then
reset_register;
else
addr := unsigned(address);
case addr is
when trigger_control => control_reg <= data;
when trigger_config => config_reg <= data;
when TRG0_bit_value => set_bit_value(0) <= '1';
when TRG1_bit_value => set_bit_value(1) <= '1';
when TRG2_bit_value => set_bit_value(2) <= '1';
when TRG3_bit_value => set_bit_value(3) <= '1';
when TRG4_bit_value => set_bit_value(4) <= '1';
when TRG5_bit_value => set_bit_value(5) <= '1';
when TRG6_bit_value => set_bit_value(6) <= '1';
when TRG7_bit_value => set_bit_value(7) <= '1';
when TRG0_bit_mask => set_bit_mask(0) <= '1';
when TRG1_bit_mask => set_bit_mask(1) <= '1';
when TRG2_bit_mask => set_bit_mask(2) <= '1';
when TRG3_bit_mask => set_bit_mask(3) <= '1';
when TRG4_bit_mask => set_bit_mask(4) <= '1';
when TRG5_bit_mask => set_bit_mask(5) <= '1';
when TRG6_bit_mask => set_bit_mask(6) <= '1';
when TRG7_bit_mask => set_bit_mask(7) <= '1';
when TRG0_re_mask => set_re_mask(0) <= '1';
when TRG1_re_mask => set_re_mask(1) <= '1';
when TRG2_re_mask => set_re_mask(2) <= '1';
when TRG3_re_mask => set_re_mask(3) <= '1';
when TRG4_re_mask => set_re_mask(4) <= '1';
when TRG5_re_mask => set_re_mask(5) <= '1';
when TRG6_re_mask => set_re_mask(6) <= '1';
when TRG7_re_mask => set_re_mask(7) <= '1';
when TRG0_fe_mask => set_fe_mask(0) <= '1';
when TRG1_fe_mask => set_fe_mask(1) <= '1';
when TRG2_fe_mask => set_fe_mask(2) <= '1';
when TRG3_fe_mask => set_fe_mask(3) <= '1';
when TRG4_fe_mask => set_fe_mask(4) <= '1';
when TRG5_fe_mask => set_fe_mask(5) <= '1';
when TRG6_fe_mask => set_fe_mask(6) <= '1';
when TRG7_fe_mask => set_fe_mask(7) <= '1';
when TRG0_edge_mask => set_edge_mask(0) <= '1';
when TRG1_edge_mask => set_edge_mask(1) <= '1';
when TRG2_edge_mask => set_edge_mask(2) <= '1';
when TRG3_edge_mask => set_edge_mask(3) <= '1';
when TRG4_edge_mask => set_edge_mask(4) <= '1';
when TRG5_edge_mask => set_edge_mask(5) <= '1';
when TRG6_edge_mask => set_edge_mask(6) <= '1';
when TRG7_edge_mask => set_edge_mask(7) <= '1';
when others => null;
end case;
glitch_capture <= config_reg(31);
arm <= control_reg(23);
end if;
end if;
end process;
end architecture;