CORE-73 - Imported Drop-Watch Generator from the SMB repository

This commit is contained in:
gianmarcogirau 2019-12-17 13:46:29 +00:00
commit 2860b68e3c
5 changed files with 559 additions and 14 deletions

View file

@ -0,0 +1,166 @@
[{
"ip_name": "drop_watch_gen_0",
"bus": "csr",
"description": "Drop-Watch Generator",
"registers": {
"ip_id" : {
"address" : "0",
"width" : "32",
"description" : "Unique ID for this IP block",
"fields": {
"ip_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x20",
"description" : "IP identifier number"
},
"mfr_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0xFF",
"description" : "Manufacturer number"
},
"reserved" : {
"type" : "rsv",
"bit_len" : "16",
"description" : "Reserved bits"
}
}
},
"ip_ver" : {
"address" : "1",
"width" : "32",
"description" : "IP Version",
"fields": {
"minor_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x01",
"description" : "Minor number"
},
"major_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x00",
"description" : "Major number"
},
"reserved" : {
"type" : "rsv",
"bit_len" : "16",
"description" : "Reserved bits"
}
}
},
"dw_csr" : {
"address" : "2",
"width" : "26",
"description" : "Drop-Watch Control and Status",
"fields": {
"dw_en" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "Drop-Watch enable"
},
"dw_polarity" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "Drop-Watch polarity"
},
"input_polarity" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "input polarity"
},
"Reserved-0" : {
"type" : "rsv",
"bit_len" : "2",
"description" : "Reserved bits"
},
"seq_start_req" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "sequencer start request"
},
"seq_busy" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0x0",
"description" : "sequencer busy"
},
"Reserved-1" : {
"type" : "rsv",
"bit_len" : "1",
"description" : "Reserved bit"
},
"seq_start_addr" : {
"type" : "w",
"bit_len" : "8",
"reset" : "0x0",
"description" : "sequencer start address"
},
"Reserved-2" : {
"type" : "rsv",
"bit_len" : "8",
"description" : "Reserved bits"
},
"dw_sw_drive_en" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "Enable the Drop-Watch output to be driven through a control register (dw_sw_value), bypassing the sequencer and the queue&delay blocks"
},
"dw_sw_value" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0x0",
"description" : "Specifies the value of the Drop-Watch output, when dw_sw_drive_en is asserted"
}
}
},
"dw_delay" : {
"address" : "3",
"type" : "w",
"width" : "32",
"reset" : "0x0",
"description" : "Drop-Watch delay"
},
"dw_pulse_width" : {
"address" : "4",
"type" : "w",
"width" : "24",
"reset" : "0x03E8",
"description" : "Drop-Watch pulse-width"
},
"dw_cnt": {
"address": "5",
"width": "18",
"description": "Drop-Watch count",
"fields": {
"dw_cnt": {
"type": "r",
"bit_len": "16",
"reset": "0x0",
"description": "Drop-Watch events count"
},
"rst_dw_cnt": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Reset the drop-watch count"
},
"queue_ovfl_error": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "Drop-watch queue overflow error"
}
}
}
}
}]

View file

@ -0,0 +1,28 @@
# Simulation macro
# Cleanup libraries
foreach lib [list work] {
file delete -force -- $lib
vlib $lib
}
#.main clear
set COMMON_PATH ../../../common/0/src
set GEN_SEQ ../../../generic_sequencer/15/src
set DW_SRC ../src
set WORKLIB work
vlib ./work
vmap work ./work
# Compile the UUT
vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/queue_and_delay.vhd
vcom -2008 -work $WORKLIB $GEN_SEQ/altera/generic_seq_ram_15.vhd
vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15_pkg.vhd
vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15.vhd
vcom -2008 -work $WORKLIB $DW_SRC/drop_watch_gen_0_pkg.vhd
vcom -2008 -work $WORKLIB $DW_SRC/drop_watch_gen_0.vhd

View file

@ -0,0 +1,320 @@
-------------------------------------------------------------------------------
-- Title : drop_watch_gen_0
-- Project : Generic-IPs
-------------------------------------------------------------------------------
-- File : drop_watch_gen_0.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-05-29
-- Last update: 2019-12-17
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- Simple Drop-Watch generator, supporting queueing of multiple events,
-- programmable delay and pulse width, multiple source selection and
-- programmable polarity reversal (active high/low selection)
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.drop_watch_gen_0_pkg.all;
entity drop_watch_gen_0 is
port(
reset_n : in std_logic;
clk : in std_logic;
input_src : in std_logic_vector( 3 downto 0);
drop_watch : out std_logic;
-- Avalon MM
avs_address : in std_logic_vector( 9 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
avs_readdatavalid : out std_logic;
avs_readdata : out std_logic_vector(31 downto 0));
end drop_watch_gen_0;
architecture RTL of drop_watch_gen_0 is
constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF20";
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000001";
signal dw_src, dw_src_d, pulse_gen, pulse_cnt_tc : std_logic;
signal dw_gen_en, queue_overflow_err, drop_watch_i : std_logic;
signal dw_polarity, init_qd, dw_i, pulse_gen_d : std_logic;
signal input_polarity, seq_start_req : std_logic;
signal seq_csr_write, seq_csr_read : std_logic;
signal seq_busy, seq_read, seq_write, avs_write_i : std_logic;
signal avs_read_i, avs_read_d, rst_drop_cnt : std_logic;
signal bus_valid, pulse_1us, pulse_1ms : std_logic;
signal dw_sw_drive_en, dw_sw_value : std_logic;
--
signal vector_out : std_logic_vector( 0 downto 0);
signal input_src_d, input_src_i : std_logic_vector( 3 downto 0);
signal seq_csr_addr : std_logic_vector( 3 downto 0);
signal avs_addr : std_logic_vector( 2 downto 0);
signal seq_start_addr : std_logic_vector( 7 downto 0);
signal trigger_in : std_logic_vector( 7 downto 0);
signal seq_address : std_logic_vector( 7 downto 0);
signal avs_address_i : std_logic_vector( 9 downto 0);
signal us_cnt, ms_cnt : std_logic_vector( 9 downto 0);
signal drop_cnt : std_logic_vector(15 downto 0);
signal pulse_width, pulse_cnt : std_logic_vector(23 downto 0);
signal seq_csr_writedata, seq_csr_readdata : std_logic_vector(31 downto 0);
signal dw_delay, seq_writedata, seq_readdata : std_logic_vector(31 downto 0);
signal avs_readdata_i : std_logic_vector(31 downto 0);
begin -- RTL
-----------------------------------------------------------------------------
-- Drop-Watch Sequencer
-----------------------------------------------------------------------------
iCH_SEQ : entity work.generic_sequencer_15
generic map (
TRIGGER_WIDTH => 8,
VECTOR_WIDTH => 1,
BUS_WIDTH => 1,
POS_WIDTH => 1,
SEQ_DEPTH => 256,
ADD_VEC_PIPE => false,
VECT_RAMP_EN => false,
BUS_BURST_EN => false,
POS_BUS_EN => false,
ALU_EN => false)
port map (
clk => clk,
reset_n => reset_n,
avs_csr_address => seq_csr_addr,
avs_csr_write => seq_csr_write,
avs_csr_writedata => seq_csr_writedata,
avs_csr_read => seq_csr_read,
avs_csr_readdata => seq_csr_readdata,
avs_seq_address => seq_address,
avs_seq_write => seq_write,
avs_seq_writedata => seq_writedata,
avs_seq_read => seq_read,
avs_seq_readdata => seq_readdata,
start_req => seq_start_req,
start_addr => seq_start_addr,
trigger_in => trigger_in,
pos_in => (others => '0'),
busy => seq_busy,
vector_out => vector_out,
bus_data => open,
bus_valid => open,
bus_ack => '0');
-- make sure all the input signals are asserted for a single clock cycle
pIN_SRC_CON : process(clk)
begin
if(clk = '1' and clk'event) then
input_src_d <= input_src;
end if;
end process pIN_SRC_CON;
input_src_i <= (input_src and not input_src_d) when input_polarity = '1' else (not input_src and input_src_d);
trigger_in <= '0' & pulse_1ms & pulse_1us & '1' & input_src_i;
-- Generate a 1 us and a 1 ms pulse signal to be used for triggering events
-- in the drop-watch sequencer
pGEN_TIME_PULSES : process(reset_n, clk)
begin
if(reset_n = '0') then
us_cnt <= (others => '0');
ms_cnt <= (others => '0');
elsif(clk = '1' and clk'event) then
if(pulse_1us = '1') then
us_cnt <= (others => '0');
else
us_cnt <= std_logic_vector(unsigned(us_cnt)+1);
end if;
if(pulse_1ms = '1') then
ms_cnt <= (others => '0');
else
ms_cnt <= std_logic_vector(unsigned(ms_cnt)+1);
end if;
end if;
end process pGEN_TIME_PULSES;
pulse_1us <= '1' when unsigned(us_cnt) = 99 else '0';
pulse_1ms <= '1' when unsigned(ms_cnt) = 999 else '0';
-----------------------------------------------------------------------------
-- Drop-watch generation logic
-----------------------------------------------------------------------------
pGenDW_Event : process(reset_n, clk)
begin
if(reset_n = '0') then
dw_src <= '0';
dw_src_d <= '0';
dw_i <= '0';
pulse_gen_d <= '0';
drop_watch <= '1';
pulse_cnt <= (others => '0');
drop_cnt <= (others => '0');
elsif(clk = '1' and clk'event) then
-- source selection
dw_src <= dw_gen_en and vector_out(0);
dw_src_d <= dw_src;
pulse_gen_d <= pulse_gen;
if(dw_gen_en = '0' or pulse_cnt_tc = '1') then
dw_i <= '0';
elsif(pulse_gen_d = '1') then
dw_i <= '1';
end if;
if(dw_sw_drive_en = '0') then
if(dw_polarity = '1') then
drop_watch <= drop_watch_i;
else
drop_watch <= not drop_watch_i;
end if;
else
drop_watch <= dw_sw_value;
end if;
if(pulse_gen = '1') then
pulse_cnt <= (others => '0');
else
pulse_cnt <= std_logic_vector(unsigned(pulse_cnt)+1);
end if;
if(dw_gen_en = '0' or rst_drop_cnt = '1') then
drop_cnt <= (others => '0');
elsif(pulse_gen = '1') then
drop_cnt <= std_logic_vector(unsigned(drop_cnt)+1);
end if;
end if;
end process pGenDW_Event;
pulse_gen <= dw_src and not dw_src_d;
pulse_cnt_tc <= '1' when unsigned(pulse_cnt) = unsigned(pulse_width) else '0';
-- Queue and delay drop watch requests
iQD: entity work.queue_and_delay
generic map (
use_ext_time => false,
queue_size => 2048)
port map (
rstN => reset_n,
clk => clk,
init => init_qd,
cnt_dir => '0',
delay => dw_delay,
ext_time => (others => '0'),
wave_in => dw_i,
wave_out => drop_watch_i,
ovf_error => queue_overflow_err);
init_qd <= not dw_gen_en;
-----------------------------------------------------------------------------
-- C&S registers (Avalon-MM I/F)
-----------------------------------------------------------------------------
-- Memory partitioning:
-- Relative addresses between 0 and 511 => DW Gen C&S regs
-- Relative addresses between 32 and 63 => Sequencer Ctrl&Status
-- Relative addresses between 512 and 1023 => Sequencer instruction buffers
avs_write_i <= '1' when avs_write = '1' and avs_address(9 downto 3) = 7x"0" else '0';
seq_csr_write <= '1' when avs_write = '1' and avs_address(9 downto 3) = 7x"4" else '0';
seq_write <= '1' when avs_write = '1' and avs_address(9) = '1' else '0';
--
avs_read_i <= '1' when avs_read = '1' and avs_address(9 downto 3) = 7x"0" else '0';
seq_csr_read <= '1' when avs_read = '1' and avs_address(9 downto 3) = 7x"4" else '0';
seq_read <= '1' when avs_read = '1' and avs_address(9) = '1' else '0';
--
avs_addr <= avs_address(2 downto 0);
seq_address <= avs_address(seq_address'range);
seq_csr_addr <= avs_address(seq_csr_addr'range);
--
seq_writedata <= avs_writedata;
seq_csr_writedata <= avs_writedata;
pCTRL_STATUS : process(reset_n, clk)
begin
if(reset_n = '0') then
avs_read_d <= '0';
avs_readdatavalid <= '0';
avs_readdata_i <= (others => '0');
--
dw_gen_en <= '0';
dw_polarity <= '0';
input_polarity <= '0';
seq_start_req <= '0';
rst_drop_cnt <= '0';
dw_sw_drive_en <= '0';
dw_sw_value <= '0';
seq_start_addr <= (others => '0');
dw_delay <= (others => '0');
pulse_width <= X"0003E8";
elsif(clk = '1' and clk'event) then
-- CTRL registers
if(avs_write_i = '1') then
case avs_addr is
when CSR_DW_CSR =>
dw_gen_en <= avs_writedata(0);
dw_polarity <= avs_writedata(1); -- 0 => active low, 1 =>
-- active high
input_polarity <= avs_writedata(2);
seq_start_req <= avs_writedata(5);
seq_start_addr <= avs_writedata(seq_start_addr'high+8 downto 8);
dw_sw_drive_en <= avs_writedata(24);
dw_sw_value <= avs_writedata(25);
when CSR_DW_DELAY =>
dw_delay <= avs_writedata;
when CSR_DW_PULSE_WIDTH =>
pulse_width <= avs_writedata(pulse_width'range);
when CSR_DW_CNT =>
rst_drop_cnt <= avs_writedata(16);
when others => null;
end case;
end if;
-- Read Ctrl & Status registers
avs_read_d <= avs_read;
avs_readdatavalid <= avs_read_d;
if(avs_read_i = '1') then
case avs_addr is
when CSR_IP_ID_ADDR =>
avs_readdata_i <= CSR_IP_ID;
when CSR_IP_VER_ADDR =>
avs_readdata_i <= CSR_IP_VER;
when CSR_DW_CSR =>
avs_readdata_i(15 downto 0) <= seq_start_addr & '0' & seq_busy & seq_start_req & "00" & input_polarity & dw_polarity & dw_gen_en;
avs_readdata_i(31 downto 16) <= 14x"0" & dw_sw_value & dw_sw_drive_en;
when CSR_DW_DELAY =>
avs_readdata_i <= dw_delay;
when CSR_DW_PULSE_WIDTH =>
avs_readdata_i <= X"00" & pulse_width;
when CSR_DW_CNT =>
avs_readdata_i(31 downto 16) <= (16 => rst_drop_cnt, 17 => queue_overflow_err, others => '0');
avs_readdata_i(15 downto 0) <= drop_cnt;
when others =>
avs_readdata_i <= X"BAD1BAD0";
end case;
end if;
if(avs_read = '1') then
avs_address_i <= avs_address;
end if;
-- output multiplexer
case? avs_address_i(9 downto 5) is
when "00000" =>
avs_readdata <= avs_readdata_i;
when "00001" =>
avs_readdata <= seq_csr_readdata;
when "1----" =>
avs_readdata <= seq_readdata;
when others =>
avs_readdata <= X"BAD1BAD0";
end case?;
end if;
end process pCTRL_STATUS;
end RTL;

View file

@ -0,0 +1,31 @@
-------------------------------------------------------------------------------
-- Title : drop_watch_gen_0_pkg
-- Project : Generic-IPs
-------------------------------------------------------------------------------
-- File : drop_watch_gen_0_pkg.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-05-24
-- Last update: 2019-12-17
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Package defining common constants for the drop-watch generator
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package drop_watch_gen_0_pkg is
constant CSR_IP_ID_ADDR : std_logic_vector(2 downto 0) := 3x"0";
constant CSR_IP_VER_ADDR : std_logic_vector(2 downto 0) := 3x"1";
constant CSR_DW_CSR : std_logic_vector(2 downto 0) := 3x"2";
constant CSR_DW_DELAY : std_logic_vector(2 downto 0) := 3x"3";
constant CSR_DW_PULSE_WIDTH : std_logic_vector(2 downto 0) := 3x"4";
constant CSR_DW_CNT : std_logic_vector(2 downto 0) := 3x"5";
end package drop_watch_gen_0_pkg;

View file

@ -54,7 +54,7 @@
}
},
"ems_enable" : {
"address" : "0",
"address" : "2",
"width" : "4",
"description" : "EMS Enable",
"fields": {
@ -85,7 +85,7 @@
}
},
"ems_config" : {
"address" : "1",
"address" : "3",
"width" : "13",
"description" : "EMS configuration",
"fields": {
@ -152,7 +152,7 @@
}
},
"pd_hyst" : {
"address" : "2",
"address" : "4",
"width" : "17",
"description" : "PD hysteresis control",
"fields": {
@ -171,7 +171,7 @@
}
},
"sw_ctrl": {
"address": "3",
"address": "5",
"width": "6",
"description": "software controls",
"fields": {
@ -208,14 +208,14 @@
},
"enc_divide": {
"type": "w",
"address": "4",
"address": "6",
"reset": "0x0",
"width": "4",
"description": "division factor for the encoder increments/decrements"
},
"abs_pos_init": {
"type": "w",
"address": "5",
"address": "7",
"reset": "0x0",
"width": "32",
"subtype": "signed",
@ -223,14 +223,14 @@
},
"abs_pos_val": {
"type": "r",
"address": "6",
"address": "8",
"reset": "0x0",
"width": "32",
"subtype": "signed",
"description": "Current value of the absolute-position (With/Without Encoder Multiplier)"
},
"pd_counters": {
"address": "7",
"address": "9",
"width": "32",
"description": "PD counters",
"fields": {
@ -249,7 +249,7 @@
}
},
"filter_cfg": {
"address": "8",
"address": "10",
"width": "20",
"description": "input filters configuration",
"fields": {
@ -302,7 +302,7 @@
}
},
"enc_mult_cfg": {
"address": "9",
"address": "11",
"width": "15",
"description": "Encoder Multiplier Configuration",
"fields": {
@ -338,21 +338,21 @@
},
"delta_t_init": {
"type": "w",
"address": "10",
"address": "12",
"reset": "0x19",
"width": "28",
"description": "Set this constant to 25 for Encoder Mult values less or equal than 8, otherwise set to 2*Mult-Value"
},
"vel_timeout": {
"type": "w",
"address": "11",
"address": "13",
"reset": "0x1388",
"width": "28",
"description": "Velocity estimation time-out period"
},
"abs_pos_in_stat": {
"type": "r",
"address": "12",
"address": "14",
"reset": "0x0",
"width": "32",
"subtype": "signed",
@ -360,7 +360,7 @@
},
"abs_pos_vel_stat": {
"type": "r",
"address": "13",
"address": "15",
"reset": "0x0",
"width": "32",
"subtype": "signed",