Commit a81703d3 authored by Carlos Gil Soriano's avatar Carlos Gil Soriano

Big cleanup of the repo. All hdl subfolders have a .gitignore file

parent ef23e750
#Ignore generated LaTeX files
*.aux
*.lof
*.log
*.lot
*.out
*.toc
......@@ -85,17 +85,12 @@
<status xil_pn:value="SuccessfullyRun"/>
<status xil_pn:value="WarningsGenerated"/>
<status xil_pn:value="ReadyToRun"/>
<outfile xil_pn:name="_xmsgs/xst.xmsgs"/>
<outfile xil_pn:name="image1_top.lso"/>
<outfile xil_pn:name="image1_top.ngc"/>
<outfile xil_pn:name="image1_top.ngr"/>
<outfile xil_pn:name="image1_top.prj"/>
<outfile xil_pn:name="image1_top.stx"/>
<outfile xil_pn:name="image1_top.syr"/>
<outfile xil_pn:name="image1_top.xst"/>
<outfile xil_pn:name="image1_top_xst.xrpt"/>
<outfile xil_pn:name="webtalk_pn.xml"/>
<outfile xil_pn:name="xst"/>
<status xil_pn:value="OutOfDateForInputs"/>
<status xil_pn:value="OutOfDateForOutputs"/>
<status xil_pn:value="InputAdded"/>
<status xil_pn:value="InputChanged"/>
<status xil_pn:value="InputRemoved"/>
<status xil_pn:value="OutputRemoved"/>
</transform>
<transform xil_pn:end_ts="1354033300" xil_pn:in_ck="-7461616560160808584" xil_pn:name="TRAN_compileBCD2" xil_pn:prop_ck="5283660913978915678" xil_pn:start_ts="1354033300">
<status xil_pn:value="SuccessfullyRun"/>
......@@ -103,8 +98,9 @@
</transform>
<transform xil_pn:end_ts="1354033381" xil_pn:in_ck="4649869214785825988" xil_pn:name="TRANEXT_ngdbuild_FPGA" xil_pn:prop_ck="-883419811469213931" xil_pn:start_ts="1354033375">
<status xil_pn:value="SuccessfullyRun"/>
<status xil_pn:value="ReadyToRun"/>
<status xil_pn:value="NotReadyToRun"/>
<status xil_pn:value="OutOfDateForInputs"/>
<status xil_pn:value="OutOfDateForPredecessor"/>
<status xil_pn:value="OutOfDateForOutputs"/>
<status xil_pn:value="InputChanged"/>
<status xil_pn:value="InputRemoved"/>
......
......@@ -134,18 +134,10 @@
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="47"/>
<association xil_pn:name="Implementation" xil_pn:seqID="17"/>
</file>
<file xil_pn:name="../../../../../general-cores/modules/wishbone/wb_crossbar/sdb_rom.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="62"/>
<association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file>
<file xil_pn:name="../../../../../general-cores/modules/wishbone/wb_crossbar/xwb_crossbar.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="63"/>
<association xil_pn:name="Implementation" xil_pn:seqID="25"/>
</file>
<file xil_pn:name="../../../../../general-cores/modules/wishbone/wb_crossbar/xwb_sdb_crossbar.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="64"/>
<association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file>
<file xil_pn:name="../../../../../general-cores/modules/wishbone/wishbone_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="65"/>
<association xil_pn:name="Implementation" xil_pn:seqID="16"/>
......@@ -154,6 +146,16 @@
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="63"/>
<association xil_pn:name="Implementation" xil_pn:seqID="9"/>
</file>
<file xil_pn:name="../test/image1_top_tb_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="64"/>
<association xil_pn:name="Implementation" xil_pn:seqID="64"/>
</file>
<file xil_pn:name="../test/image1_top_tb.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="65"/>
<association xil_pn:name="PostMapSimulation" xil_pn:seqID="65"/>
<association xil_pn:name="PostRouteSimulation" xil_pn:seqID="65"/>
<association xil_pn:name="PostTranslateSimulation" xil_pn:seqID="65"/>
</file>
</files>
<properties>
......@@ -393,8 +395,8 @@
<property xil_pn:name="Run Design Rules Checker (DRC)" xil_pn:value="true" xil_pn:valueState="default"/>
<property xil_pn:name="Safe Implementation" xil_pn:value="No" xil_pn:valueState="default"/>
<property xil_pn:name="Security" xil_pn:value="Enable Readback and Reconfiguration" xil_pn:valueState="default"/>
<property xil_pn:name="Selected Module Instance Name" xil_pn:value="/image1_top" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Root Source Node Behavioral" xil_pn:value="work.image1_top" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Module Instance Name" xil_pn:value="/xwb_sdb_crossbar" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Root Source Node Behavioral" xil_pn:value="work.xwb_sdb_crossbar" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Source Node" xil_pn:value="UUT" xil_pn:valueState="default"/>
<property xil_pn:name="Set SPI Configuration Bus Width spartan6" xil_pn:value="1" xil_pn:valueState="default"/>
<property xil_pn:name="Setup External Master Clock Division spartan6" xil_pn:value="1" xil_pn:valueState="default"/>
......
......@@ -13,7 +13,7 @@ use work.rtm_detector_pkg.ALL;
package image1_pkg is
constant c_WB_CLK_PERIOD : TIME := 8 ns;
constant c_WB_CLK_PERIOD : TIME := 50 ns;
constant c_RST_CLKS : NATURAL := 256; --! @8ns
constant c_NUM_MASTERS : NATURAL := 1;
......
......@@ -11,29 +11,27 @@ use UNISIM.VCOMPONENTS.ALL;
entity image1_top is
generic(g_NUMBER_OF_CHANNELS : NATURAL := 6);
port (
FPGA_CLK_P : in STD_LOGIC;
FPGA_CLK_N : in STD_LOGIC;
led_pw_o : out STD_LOGIC;
led_err_o : out STD_LOGIC;
led_ttl_o : out STD_LOGIC;
led_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
led_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_front : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_rear : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
inv_i : in STD_LOGIC_VECTOR(4 downto 1);
inv_o : out STD_LOGIC_VECTOR(4 downto 1);
clk_i : in STD_LOGIC; --Using the 20MHz clock
led_pw_o : out STD_LOGIC;
led_err_o : out STD_LOGIC;
led_ttl_o : out STD_LOGIC;
led_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
led_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_front : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_rear : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
inv_i : in STD_LOGIC_VECTOR(4 downto 1);
inv_o : out STD_LOGIC_VECTOR(4 downto 1);
--! Lines for the i2c_slave
SCL_I : in STD_LOGIC;
SCL_O : out STD_LOGIC;
SCL_OE : out STD_LOGIC;
SDA_I : in STD_LOGIC;
SDA_O : out STD_LOGIC;
SDA_OE : out STD_LOGIC;
FPGA_GA : in STD_LOGIC_VECTOR(4 downto 0);
FPGA_GAP : in STD_LOGIC;
SCL_I : in STD_LOGIC;
SCL_O : out STD_LOGIC;
SCL_OE : out STD_LOGIC;
SDA_I : in STD_LOGIC;
SDA_O : out STD_LOGIC;
SDA_OE : out STD_LOGIC;
FPGA_GA : in STD_LOGIC_VECTOR(4 downto 0);
FPGA_GAP : in STD_LOGIC;
--! Pins of the SPI interface to write into the Flash memory
FPGA_PROM_CCLK : out STD_LOGIC;
FPGA_PROM_CSO_B_N : out STD_LOGIC;
......@@ -41,22 +39,22 @@ entity image1_top is
FPGA_PROM_MOSI : out STD_LOGIC;
--! This LED will show the status of the PLL
led_link_up_o : out STD_LOGIC;
led_pps_o : out STD_LOGIC;
led_wr_ok_o : out STD_LOGIC;
led_link_up_o : out STD_LOGIC;
led_pps_o : out STD_LOGIC;
led_wr_ok_o : out STD_LOGIC;
--! RTM identifiers, should match with the expected values
--! TODO: add matching
fpga_o_en : out STD_LOGIC;
fpga_o_blo_en : out STD_LOGIC;
fpga_o_ttl_en : out STD_LOGIC;
fpga_o_inv_en : out STD_LOGIC;
level : in STD_LOGIC;
switch_i : in STD_LOGIC; --! General enable
manual_rst_n_o : out STD_LOGIC; --! It allows power sequencing of the
--! 24V rail after a security given
--! delay
FPGA_RTMM : in STD_LOGIC_VECTOR(2 downto 0);
FPGA_RTMP : in STD_LOGIC_VECTOR(2 downto 0));
fpga_o_en : out STD_LOGIC;
fpga_o_blo_en : out STD_LOGIC;
fpga_o_ttl_en : out STD_LOGIC;
fpga_o_inv_en : out STD_LOGIC;
level : in STD_LOGIC;
switch_i : in STD_LOGIC; --! General enable
manual_rst_n_o : out STD_LOGIC; --! It allows power sequencing of the
--! 24V rail after a security given
--! delay
FPGA_RTMM : in STD_LOGIC_VECTOR(2 downto 0);
FPGA_RTMP : in STD_LOGIC_VECTOR(2 downto 0));
end image1_top;
......
-- TestBench Template
library IEEE;
library work;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.NUMERIC_STD.ALl;
use std.textio.ALL;
use work.i2c_tb_pkg.ALL;
use work.wishbone_driver_pkg.ALL;
entity image1_top_tb is
end image1_top_tb;
architecture Behaviour of image1_top_tb is
component image1_top
generic(
g_NUMBER_OF_CHANNELS : INTEGER := 6
);
port(
rst_i : in STD_LOGIC;
clk_i : in STD_LOGIC;
pulse_i : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS -1 downto 0);
pulse_o : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS -1 downto 0);
sda_oen : out STD_LOGIC;
sda_i : in STD_LOGIC;
sda_o : out STD_LOGIC;
scl_oen : out STD_LOGIC;
scl_i : in STD_LOGIC;
scl_o : out STD_LOGIC;
GA : in STD_LOGIC_VECTOR (4 downto 0);
GAP : in STD_LOGIC
);
end component;
constant clk_i_period : TIME := 10 ns;
constant c_NUMBER_OF_CHANNELS : INTEGER := 6;
--Inputs
signal rst_i : STD_LOGIC;
signal clk_i : STD_LOGIC;
signal pulse_i : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS -1 downto 0);
signal pulse_o : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS -1 downto 0);
signal sda_oen : STD_LOGIC;
signal sda_i : STD_LOGIC := '0';
signal sda_o : STD_LOGIC;
signal scl_oen : STD_LOGIC;
signal scl_i : STD_LOGIC := '0';
signal scl_o : STD_LOGIC;
-- Clock period definitions
constant wb_clk_period : time := 50 ns; -- @ 20 MHz
constant scl_i_period : time := 2500 ns; -- @ 400 KHz
signal PRE_value : UNSIGNED(15 downto 0) := X"0032";
signal VME_crate_slot : UNSIGNED(4 downto 0) := "00001";
signal i2c_addr : STD_LOGIC_VECTOR(4 downto 0) := not(std_logic_vector(VME_crate_slot));
signal GAP : STD_LOGIC := '0';
signal wb_addr_i2c : STD_LOGIC_VECTOR (15 downto 0);
signal i2c_rcved_data : STD_LOGIC_VECTOR (7 downto 0);
constant bytes_ind_addr : STD_LOGIC_VECTOR (7 downto 6) := "10";
constant bytes_wr_state : STD_LOGIC_VECTOR (7 downto 0) := X"06";
constant bytes_rd_state : STD_LOGIC_VECTOR (7 downto 0) := X"04";
constant STA_addr : STD_LOGIC_VECTOR(3 downto 0) := X"0";
constant PRE_addr : STD_LOGIC_VECTOR(3 downto 0) := X"1";
constant CTR0_addr : STD_LOGIC_VECTOR(3 downto 0) := X"2";
constant CTR1_addr : STD_LOGIC_VECTOR(3 downto 0) := X"3";
constant DRXl_addr : STD_LOGIC_VECTOR(3 downto 0) := X"4";
constant DRXh_addr : STD_LOGIC_VECTOR(3 downto 0) := X"5";
constant DTX_addr : STD_LOGIC_VECTOR(3 downto 0) := X"6";
end image1_top_tb;
architecture behavior of image1_top_tb is
--! ========================================================================
--! Signals for the image1_top module
--! ========================================================================
signal wb_clk : STD_LOGIC := '0';
signal s_led_pw_o : STD_LOGIC;
signal s_led_err_o : STD_LOGIC;
signal s_led_ttl_o : STD_LOGIC;
signal s_pulse_led : t_pulse_led_vector;
signal s_pulse_i : t_pulse_vector;
signal s_pulse_o : t_pulse_vector;
signal s_inv_i : STD_LOGIC_VECTOR(4 downto 1);
signal s_inv_o : STD_LOGIC_VECTOR(4 downto 1);
--! Connections for i2c_slave_top
signal s_sda_slave_oen : STD_LOGIC;
signal s_scl_slave_oen : STD_LOGIC;
signal s_I2C_master_i : t_I2C_master_in;
signal s_I2C_master_o : t_I2C_master_out;
signal s_I2C_slave_i : t_I2C_slave_in;
signal s_I2C_slave_o : t_I2C_slave_out;
signal s_FPGA_GA : STD_LOGIC_VECTOR(4 downto 0);
signal s_FPGA_GAP : STD_LOGIC;
--! Pins of the SPI interface to write into the Flash memory
signal s_SPI_master_i : t_SPI_master_in;
signal s_SPI_master_o : t_SPI_master_out;
signal s_SPI_slave_i : t_SPI_slave_in;
signal s_SPI_slave_o : t_SPI_slave_out;
--! This LED will show the status of the PLL
signal s_led_link_up_o : STD_LOGIC;
signal s_led_pps_o : STD_LOGIC;
signal s_led_wr_ok_o : STD_LOGIC;
signal s_fpga_en : t_fpga_en;
signal level : STD_LOGIC;
signal switch_i : STD_LOGIC;
signal manual_rst_n_o : STD_LOGIC;
signal s_RTM_id_i : t_RTM_id;
--! ========================================================================
--! Signals for the i2c_master_driver (Renesasa alike)
--! ========================================================================
signal s_i2c_addr_op : STD_LOGIC_VECTOR(7 downto 0)
:= (others => '0');
signal s_wishbone_addr : STD_LOGIC_VECTOR(c_WB_ADDR_LENGTH - 1 downto 0)
:= (others => '0');
signal s_wr_data : STD_LOGIC_VECTOR(c_WR_DATA_LENGTH - 1 downto 0)
:= (others => '0');
signal s_rd_data : STD_LOGIC_VECTOR(c_RD_DATA_LENGTH - 1 downto 0);
signal s_i2c_driver_start : STD_LOGIC := '0';
signal s_i2c_driver_start_done : STD_LOGIC;
signal s_i2c_driver_pause : STD_LOGIC := '0';
signal s_i2c_driver_pause_done : STD_LOGIC;
signal s_i2c_driver_write : STD_LOGIC := '0';
signal s_i2c_driver_write_done : STD_LOGIC;
signal s_i2c_driver_read : STD_LOGIC := '0';
signal s_i2c_driver_read_done : STD_LOGIC;
begin
image1_top_uut: image1_top
port map (
rst_i => rst_i,
clk_i => clk_i,
pulse_i => pulse_i,
pulse_o => pulse_o,
sda_oen => sda_oen,
sda_i => sda_i,
sda_o => sda_o,
scl_oen => scl_oen,
scl_i => scl_i,
scl_o => scl_o,
GA => i2c_addr,
GAP => GAP
);
-- Clock process definitions
clk_i_process :process
begin
clk_i <= '1';
wait for wb_clk_period/2;
clk_i <= '0';
wait for wb_clk_period/2;
end process;
s_I2C_master_i <= s_I2C_slave_o;
s_I2C_slave_i <= s_I2C_master_o;
scl_i_process :process
--! Clock process definitions
wb_clk_process :process
begin
scl_i <= '1';
wait for scl_i_period/2;
scl_i <= '0';
wait for scl_i_period/2;
wb_clk <= '1';
wait for c_WB_CLK_PERIOD/2;
wb_clk <= '0';
wait for c_WB_CLK_PERIOD/2;
end process;
-- Stimulus process
stim_proc: process
procedure init_cond is
begin
pulse_i <= (others => '0');
sda_i <= '1';
scl_i <= 'Z';
end init_cond;
procedure rst is
begin
wait for wb_clk_period*2;
rst_i <= '1';
wait for wb_clk_period*2;
rst_i <= '0';
wait for wb_clk_period*2;
end rst;
procedure start is
begin
sda_i <= '1';
wait until rising_edge(scl_i);
wait for scl_i_period/4;
sda_i <= '0';
end start;
-- Instantiate the Unit Under Test (UUT)
i2c_driver: i2c_master_driver
port map(tb_clk => wb_clk,
sda_master_i => s_I2C_master_i.SDA,
sda_master_o => s_I2C_master_o.SDA,
scl_master_o => s_I2C_master_o.SCL,
i2c_addr_op_i => s_i2c_addr_op,
wishbone_addr_i => s_wishbone_addr,
wr_data_i => s_wr_data,
rd_data_o => s_rd_data,
start_i => s_i2c_driver_start,
start_done_o => s_i2c_driver_start_done,
pause_i => s_i2c_driver_pause,
pause_done_o => s_i2c_driver_pause_done,
write_i => s_i2c_driver_write,
write_done_o => s_i2c_driver_write_done,
read_i => s_i2c_driver_read,
read_done_o => s_i2c_driver_read_done);
uut: image1_top
generic map(g_NUMBER_OF_CHANNELS => c_NUMBER_OF_CHANNELS)
port map(FPGA_CLK_P =>,
FPGA_CLK_N =>,
led_pw_o => s_led_pw_o ,
led_err_o => s_led_err_o,
led_ttl_o => s_led_ttl_o,
led_o_front => s_pulse_led.FRONT,
led_o_rear => s_pulse_led.REAR,
pulse_i_front => s_pulse_i.FRONT,
pulse_o_front => s_pulse_o.FRONT,
pulse_i_rear => s_pulse_i.REAR,
pulse_o_rear => s_pulse_o.REAR,
inv_i => s_inv_i,
inv_o => s_inv_o,
SCL_I => s_I2C_master_o.SCL,
SCL_O => open,
SCL_OE => s_scl_slave_oen,
SDA_I => s_I2C_slave_i.SDA,
SDA_O => s_I2C_slave_o.SDA,
SDA_OE => s_sda_slave_oen,
FPGA_GA => s_FPGA_GA,
FPGA_GAP => s_FPGA_GAP,
FPGA_PROM_CCLK => s_SPI_master_o.CCLK,
FPGA_PROM_CSO_B_N => s_SPI_master_o.CSO_B_N,
FPGA_PROM_DIN => s_SPI_master_i.DIN,
FPGA_PROM_MOSI => s_SPI_master_o.MOSI,
led_link_up_o => s_led_link_up_o,
led_pps_o => s_led_pps_o,
led_wr_ok_o => s_led_wr_ok_o,
fpga_o_en => s_fpga_en.GEN,
fpga_o_blo_en => s_fpga_en.BLO,
fpga_o_ttl_en => s_fpga_en.TTL,
fpga_o_inv_en => s_fpga_en.INV,
level => level,
switch_i => switch_i,
manual_rst_n_o => manual_rst_n_o,
FPGA_RTMM => s_RTM_id_i.RTMM,
FPGA_RTMP => s_RTM_id_i.RTMP);
end component;
procedure addr_send(addr : STD_LOGIC_VECTOR(6 downto 0)) is
begin
for i in 6 downto 0 loop
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= addr(i);
end loop;
end addr_send;
--! Stimulus process
p_i2c_tb: process
procedure rd_wrn_send(rd_wrn_bit: STD_LOGIC) is
procedure set_i2c_wb_feedback is
begin
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= rd_wrn_bit;
end rd_wrn_send;
s_feedback_wb_bus <= '1';
wait until rising_edge(wb_clk);
end procedure;
procedure read_ACK (ERRORmsg: STRING; OKmsg: STRING) is
procedure unset_i2c_wb_feedback is
begin
wait until falling_edge(scl_i);
wait for scl_i_period*3/4;
assert sda_o = '0' report ERRORmsg severity ERROR;
if (sda_o = '0') then
report OKmsg;
end if;
end read_ACK;
s_feedback_wb_bus <= '0';
wait until rising_edge(wb_clk);
end procedure;
procedure write_ACK(ack_bit: STD_LOGIC) is
procedure start_I2C is
begin
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= ack_bit;
end write_ACK;
procedure write_SDA(byte: STD_LOGIC_VECTOR (7 downto 0)) is
s_i2c_driver_start <= '1';
wait until rising_edge(s_i2c_driver_start_done);
wait until rising_edge(wb_clk);
s_i2c_driver_start <= '0';
end procedure;
procedure write_I2C(i2c_addr : STD_LOGIC_VECTOR(7 downto 0);
wb_addr : STD_LOGIC_VECTOR(s_wishbone_addr'length - 1 downto 0);
wr_data : STD_LOGIC_VECTOR(s_wr_data'length - 1 downto 0)) is
begin
for i in 7 downto 0 loop
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= byte(i);
end loop;
end write_SDA;
procedure read_SDA is
wait until rising_edge(wb_clk);
s_i2c_addr_op <= i2c_addr;
s_wishbone_addr <= wb_addr;
s_wr_data <= wr_data;
s_i2c_driver_write <= '1';
wait until rising_edge(wb_clk);
s_i2c_driver_write <= '0';
wait until rising_edge(s_i2c_driver_write_done);
wait until rising_edge(wb_clk);
end procedure;
--! This procedure is a wrapper in case we want to address with VME
--! directions. Front padding is done with zeroes.
procedure write_I2C(vme_slot : UNSIGNED(4 downto 0);
wb_addr : STD_LOGIC_VECTOR(s_wishbone_addr'length - 1 downto 0);
wr_data : STD_LOGIC_VECTOR(s_wr_data'length - 1 downto 0)) is
variable v_i2c_addr : STD_LOGIC_VECTOR(7 downto 0);
begin
for i in 0 to 7 loop
i2c_rcved_data(i) <= sda_o;
wait for scl_i_period;
end loop;
sda_i <= '0';
wait for scl_i_period;
sda_i <= '1';
end read_SDA;
procedure pause is
v_i2c_addr(7 downto 6) := "00";
v_i2c_addr(5 downto 1) := STD_LOGIC_VECTOR(vme_slot);
v_i2c_addr(0) := '0';
write_I2C(v_i2c_addr, wb_addr, wr_data);
end procedure;
procedure read_I2C(vme_slot : UNSIGNED(4 downto 0);
wb_addr : STD_LOGIC_VECTOR(s_wishbone_addr'length - 1 downto 0);
wr_data : STD_LOGIC_VECTOR(s_wr_data'length - 1 downto 0)) is
variable v_i2c_addr : STD_LOGIC_VECTOR(7 downto 0);
begin
sda_i <= '0';
wait until rising_edge(scl_i);
wait for scl_i_period/4;
sda_i <= '1';
wait until falling_edge(scl_i);
wait for scl_i_period/4;
end pause;
v_i2c_addr(7 downto 6) := "00";
v_i2c_addr(5 downto 1) := STD_LOGIC_VECTOR(vme_slot);
v_i2c_addr(0) := '0';
wait until rising_edge(wb_clk);
-- i2c_master_driver
s_i2c_addr_op <= v_i2c_addr;
s_wishbone_addr <= wb_addr;
s_wr_data <= wr_data;
s_i2c_driver_read <= '1';
wait until rising_edge(wb_clk);
s_i2c_driver_read <= '0';
wait until rising_edge(s_i2c_driver_read_done);
wait until rising_edge(wb_clk);
end procedure;
-------------------------------------------------------------------------
-- Procedure for correctly setting up the i2c slave
-------------------------------------------------------------------------
-- procedure init_cfg_i2c_slave(PRE_data: STD_LOGIC_VECTOR(15 downto 0); CTR0_data : STD_LOGIC_VECTOR(15 downto 0) ; CTR1_data : STD_LOGIC_VECTOR(15 downto 0)) is
-- begin
-- write_CTR0(CTR0_data and X"0002");
-- wait for wb_clk_period;
-- write_PRE(PRE_data);
-- wait for wb_clk_period;
-- write_CTR0(CTR0_data and X"FF00");
-- wait for wb_clk_period;
-- write_CTR1(CTR1_data);
-- wait for wb_clk_period;
-- write_CTR0(CTR0_data); -- Enough to assert enable bit
-- end procedure;
begin
-- ERROR list
----> ACK erros
-- 01 Instruction byte
-- 02 Internal wishbone address high byte
-- 03 Internal wishbone address low byte
rst_i <= '0';
init_cond;
wait for 100ns;
----------------------------------------------------------------------------
-- i2c_slave_top initial configuration
----------------------------------------------------------------------------
rst;
--init_cfg_i2c_slave(std_logic_vector(PRE_value), '0'&i2c_addr&bytes_ind_addr&"0000"&"01", bytes_wr_state&bytes_rd_state);
-- rst;
-- start;
-- addr_send("0101100"); --This address is inverted
-- addr_send("0101101"); --This address is bad address
-- addr_send("0000000"); --This is the general address
-- rd_wrn_send('1');
-- pause;
-------------------------------------------------------------------------------
-- Performing a write according to ELMA crate needs
-------------------------------------------------------------------------------
-- Placing a reset produces an error in scl. It should be solved
-- rst;
-------------------------------------------------------------------------------
-- Indirect i2c write
-------------------------------------------------------------------------------
start;
addr_send("1011110"); -- MSB first
rd_wrn_send('0');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
wb_addr_i2c <= X"0302";
write_SDA(wb_addr_i2c(15 downto 8)); -- mirrored MSB
read_ACK("ACK@02: NACK received. Sending internal wishbone address high byte", "PASS -> Internal Wishbone Address High Byte ACKED");
write_SDA(wb_addr_i2c(7 downto 0)); -- mirrored LSB
read_ACK("ACK@03: NACK received. Sending internal wishbone address low byte", "PASS -> Internal Wishbone Address Low Byte ACKED");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 1st byte", "PASS -> 1st data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 2nd byte", "PASS -> 2nd data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 3rd byte", "PASS -> 3rd data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 4th byte", "PASS -> 4th data byte");
pause;
wait for 100*wb_clk_period;
-------------------------------------------------------------------------------
-- Indirect i2c read
-- This is divided in a write process to set the Wishbone slave and a i2c read
-------------------------------------------------------------------------------
start;
addr_send("1011110"); --This address is inverted in bit order
rd_wrn_send('0');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
wb_addr_i2c <= X"0302";
write_SDA(wb_addr_i2c(15 downto 8)); -- inverted MSB
read_ACK("ACK@02: NACK received. Sending internal wishbone address high byte", "PASS -> Internal Wishbone Address High Byte ACKED");
write_SDA(wb_addr_i2c(7 downto 0)); -- inverted LSB
read_ACK("ACK@03: NACK received. Sending internal wishbone address low byte", "PASS -> Internal Wishbone Address Low Byte ACKED");
-- At this point we must prefetch the data to be sent
-- write_DTX(X"DDCCBBAA");
start;
addr_send("1011110"); --This address is inverted in bit order
rd_wrn_send('1');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
read_SDA;
read_SDA;
read_SDA;
read_SDA;
pause;
wait;
wb_rst_i <= '1';
wait for c_WB_CLK_PERIOD*10;
wb_rst_i <= '0';
--! First we place a write
set_i2c_wb_feedback;
start_I2C;
--! Try to write into DTX addr position
write_I2C(c_VME_SLOT, X"0002", X"B16B00B5");
wait for c_WB_CLK_PERIOD*25;
--! Then we read from the FPGA
--unset_i2c_wb_feedback;
start_I2C;
--! We read addr 1 (LT) via I2C
--! Then, the core internally prefetchs via wishbone and then
--! write the register into I2C to the master
read_I2C(c_VME_SLOT, X"BAB1", X"B16B00B5");
wait for c_WB_CLK_PERIOD*25;
end process;
end;
-- TestBench Template
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity image1_top_tb is
end image1_top_tb;
architecture Behaviour of image1_top_tb is
component image1_top
generic(
g_NUMBER_OF_CHANNELS : INTEGER := 6
);
port(
rst_i : in STD_LOGIC;
clk_i : in STD_LOGIC;
pulse_i : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS -1 downto 0);
pulse_o : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS -1 downto 0);
sda_oen : out STD_LOGIC;
sda_i : in STD_LOGIC;
sda_o : out STD_LOGIC;
scl_oen : out STD_LOGIC;
scl_i : in STD_LOGIC;
scl_o : out STD_LOGIC;
GA : in STD_LOGIC_VECTOR (4 downto 0);
GAP : in STD_LOGIC
);
end component;
constant clk_i_period : TIME := 10 ns;
constant c_NUMBER_OF_CHANNELS : INTEGER := 6;
--Inputs
signal rst_i : STD_LOGIC;
signal clk_i : STD_LOGIC;
signal pulse_i : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS -1 downto 0);
signal pulse_o : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS -1 downto 0);
signal sda_oen : STD_LOGIC;
signal sda_i : STD_LOGIC := '0';
signal sda_o : STD_LOGIC;
signal scl_oen : STD_LOGIC;
signal scl_i : STD_LOGIC := '0';
signal scl_o : STD_LOGIC;
-- Clock period definitions
constant wb_clk_period : time := 50 ns; -- @ 20 MHz
constant scl_i_period : time := 2500 ns; -- @ 400 KHz
signal PRE_value : UNSIGNED(15 downto 0) := X"0032";
signal VME_crate_slot : UNSIGNED(4 downto 0) := "00001";
signal i2c_addr : STD_LOGIC_VECTOR(4 downto 0) := not(std_logic_vector(VME_crate_slot));
signal GAP : STD_LOGIC := '0';
signal wb_addr_i2c : STD_LOGIC_VECTOR (15 downto 0);
signal i2c_rcved_data : STD_LOGIC_VECTOR (7 downto 0);
constant bytes_ind_addr : STD_LOGIC_VECTOR (7 downto 6) := "10";
constant bytes_wr_state : STD_LOGIC_VECTOR (7 downto 0) := X"06";
constant bytes_rd_state : STD_LOGIC_VECTOR (7 downto 0) := X"04";
constant STA_addr : STD_LOGIC_VECTOR(3 downto 0) := X"0";
constant PRE_addr : STD_LOGIC_VECTOR(3 downto 0) := X"1";
constant CTR0_addr : STD_LOGIC_VECTOR(3 downto 0) := X"2";
constant CTR1_addr : STD_LOGIC_VECTOR(3 downto 0) := X"3";
constant DRXl_addr : STD_LOGIC_VECTOR(3 downto 0) := X"4";
constant DRXh_addr : STD_LOGIC_VECTOR(3 downto 0) := X"5";
constant DTX_addr : STD_LOGIC_VECTOR(3 downto 0) := X"6";
begin
image1_top_uut: image1_top
port map (
rst_i => rst_i,
clk_i => clk_i,
pulse_i => pulse_i,
pulse_o => pulse_o,
sda_oen => sda_oen,
sda_i => sda_i,
sda_o => sda_o,
scl_oen => scl_oen,
scl_i => scl_i,
scl_o => scl_o,
GA => i2c_addr,
GAP => GAP
);
-- Clock process definitions
clk_i_process :process
begin
clk_i <= '1';
wait for wb_clk_period/2;
clk_i <= '0';
wait for wb_clk_period/2;
end process;
scl_i_process :process
begin
scl_i <= '1';
wait for scl_i_period/2;
scl_i <= '0';
wait for scl_i_period/2;
end process;
-- Stimulus process
stim_proc: process
procedure init_cond is
begin
pulse_i <= (others => '0');
sda_i <= '1';
scl_i <= 'Z';
end init_cond;
procedure rst is
begin
wait for wb_clk_period*2;
rst_i <= '1';
wait for wb_clk_period*2;
rst_i <= '0';
wait for wb_clk_period*2;
end rst;
procedure start is
begin
sda_i <= '1';
wait until rising_edge(scl_i);
wait for scl_i_period/4;
sda_i <= '0';
end start;
procedure addr_send(addr : STD_LOGIC_VECTOR(6 downto 0)) is
begin
for i in 6 downto 0 loop
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= addr(i);
end loop;
end addr_send;
procedure rd_wrn_send(rd_wrn_bit: STD_LOGIC) is
begin
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= rd_wrn_bit;
end rd_wrn_send;
procedure read_ACK (ERRORmsg: STRING; OKmsg: STRING) is
begin
wait until falling_edge(scl_i);
wait for scl_i_period*3/4;
assert sda_o = '0' report ERRORmsg severity ERROR;
if (sda_o = '0') then
report OKmsg;
end if;
end read_ACK;
procedure write_ACK(ack_bit: STD_LOGIC) is
begin
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= ack_bit;
end write_ACK;
procedure write_SDA(byte: STD_LOGIC_VECTOR (7 downto 0)) is
begin
for i in 7 downto 0 loop
wait until falling_edge(scl_i);
wait for scl_i_period/4;
sda_i <= byte(i);
end loop;
end write_SDA;
procedure read_SDA is
begin
for i in 0 to 7 loop
i2c_rcved_data(i) <= sda_o;
wait for scl_i_period;
end loop;
sda_i <= '0';
wait for scl_i_period;
sda_i <= '1';
end read_SDA;
procedure pause is
begin
sda_i <= '0';
wait until rising_edge(scl_i);
wait for scl_i_period/4;
sda_i <= '1';
wait until falling_edge(scl_i);
wait for scl_i_period/4;
end pause;
-------------------------------------------------------------------------
-- Procedure for correctly setting up the i2c slave
-------------------------------------------------------------------------
-- procedure init_cfg_i2c_slave(PRE_data: STD_LOGIC_VECTOR(15 downto 0); CTR0_data : STD_LOGIC_VECTOR(15 downto 0) ; CTR1_data : STD_LOGIC_VECTOR(15 downto 0)) is
-- begin
-- write_CTR0(CTR0_data and X"0002");
-- wait for wb_clk_period;
-- write_PRE(PRE_data);
-- wait for wb_clk_period;
-- write_CTR0(CTR0_data and X"FF00");
-- wait for wb_clk_period;
-- write_CTR1(CTR1_data);
-- wait for wb_clk_period;
-- write_CTR0(CTR0_data); -- Enough to assert enable bit
-- end procedure;
begin
-- ERROR list
----> ACK erros
-- 01 Instruction byte
-- 02 Internal wishbone address high byte
-- 03 Internal wishbone address low byte
rst_i <= '0';
init_cond;
wait for 100ns;
----------------------------------------------------------------------------
-- i2c_slave_top initial configuration
----------------------------------------------------------------------------
rst;
--init_cfg_i2c_slave(std_logic_vector(PRE_value), '0'&i2c_addr&bytes_ind_addr&"0000"&"01", bytes_wr_state&bytes_rd_state);
-- rst;
-- start;
-- addr_send("0101100"); --This address is inverted
-- addr_send("0101101"); --This address is bad address
-- addr_send("0000000"); --This is the general address
-- rd_wrn_send('1');
-- pause;
-------------------------------------------------------------------------------
-- Performing a write according to ELMA crate needs
-------------------------------------------------------------------------------
-- Placing a reset produces an error in scl. It should be solved
-- rst;
-------------------------------------------------------------------------------
-- Indirect i2c write
-------------------------------------------------------------------------------
start;
addr_send("1011110"); -- MSB first
rd_wrn_send('0');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
wb_addr_i2c <= X"0302";
write_SDA(wb_addr_i2c(15 downto 8)); -- mirrored MSB
read_ACK("ACK@02: NACK received. Sending internal wishbone address high byte", "PASS -> Internal Wishbone Address High Byte ACKED");
write_SDA(wb_addr_i2c(7 downto 0)); -- mirrored LSB
read_ACK("ACK@03: NACK received. Sending internal wishbone address low byte", "PASS -> Internal Wishbone Address Low Byte ACKED");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 1st byte", "PASS -> 1st data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 2nd byte", "PASS -> 2nd data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 3rd byte", "PASS -> 3rd data byte");
write_SDA("10000000"); -- inverted
read_ACK("ACK@04: NACK received. Sending 4th byte", "PASS -> 4th data byte");
pause;
wait for 100*wb_clk_period;
-------------------------------------------------------------------------------
-- Indirect i2c read
-- This is divided in a write process to set the Wishbone slave and a i2c read
-------------------------------------------------------------------------------
start;
addr_send("1011110"); --This address is inverted in bit order
rd_wrn_send('0');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
wb_addr_i2c <= X"0302";
write_SDA(wb_addr_i2c(15 downto 8)); -- inverted MSB
read_ACK("ACK@02: NACK received. Sending internal wishbone address high byte", "PASS -> Internal Wishbone Address High Byte ACKED");
write_SDA(wb_addr_i2c(7 downto 0)); -- inverted LSB
read_ACK("ACK@03: NACK received. Sending internal wishbone address low byte", "PASS -> Internal Wishbone Address Low Byte ACKED");
-- At this point we must prefetch the data to be sent
-- write_DTX(X"DDCCBBAA");
start;
addr_send("1011110"); --This address is inverted in bit order
rd_wrn_send('1');
read_ACK("ACK@01: NACK received. Sending instruction byte (i2c addres + rd_wrn bit)", "PASS -> Instruction byte ACKED");
read_SDA;
read_SDA;
read_SDA;
read_SDA;
pause;
wait;
end process;
end;
library IEEE;
library work;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
--! Packages from IP cores
--use work.wishbone_pkg.ALL;
--use work.i2c_slave_pkg.ALL;
--use work.m25p32_pkg.ALL;
--use work.multiboot_pkg.ALL;
--use work.rtm_detector_pkg.ALL;
package image1_top_pkg is
constant c_NUMBER_OF_CHANNELS : NATURAL := 6;
component image1_top
generic(g_NUMBER_OF_CHANNELS : NATURAL := 6);
port (FPGA_CLK_P : in STD_LOGIC;
FPGA_CLK_N : in STD_LOGIC;
led_pw_o : out STD_LOGIC;
led_err_o : out STD_LOGIC;
led_ttl_o : out STD_LOGIC;
led_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
led_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_front : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_front : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_i_rear : in STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
pulse_o_rear : out STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
inv_i : in STD_LOGIC_VECTOR(4 downto 1);
inv_o : out STD_LOGIC_VECTOR(4 downto 1);
--! Lines for the i2c_slave
SCL_I : in STD_LOGIC;
SCL_O : out STD_LOGIC;
SCL_OE : out STD_LOGIC;
SDA_I : in STD_LOGIC;
SDA_O : out STD_LOGIC;
SDA_OE : out STD_LOGIC;
FPGA_GA : in STD_LOGIC_VECTOR(4 downto 0);
FPGA_GAP : in STD_LOGIC;
--! Pins of the SPI interface to write into the Flash memory
FPGA_PROM_CCLK : out STD_LOGIC;
FPGA_PROM_CSO_B_N : out STD_LOGIC;
FPGA_PROM_DIN : in STD_LOGIC;
FPGA_PROM_MOSI : out STD_LOGIC;
--! This LED will show the status of the PLL
led_link_up_o : out STD_LOGIC;
led_pps_o : out STD_LOGIC;
led_wr_ok_o : out STD_LOGIC;
fpga_o_en : out STD_LOGIC;
fpga_o_blo_en : out STD_LOGIC;
fpga_o_ttl_en : out STD_LOGIC;
fpga_o_inv_en : out STD_LOGIC;
level : in STD_LOGIC;
switch_i : in STD_LOGIC; --! General enable
manual_rst_n_o : out STD_LOGIC; --! It allows power sequencing of the
--! 24V rail after a security given
--! delay
FPGA_RTMM : in STD_LOGIC_VECTOR(2 downto 0);
FPGA_RTMP : in STD_LOGIC_VECTOR(2 downto 0));
end component;
type t_pulse_vector is
record
FRONT : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS - 1 downto 0);
REAR : STD_LOGIC_VECTOR(c_NUMBER_OF_CHANNELS - 1 downto 0);
end record;
subtype t_pulse_led_vector is t_pulse_vector;
type t_fpga_en is
record
GEN : STD_LOGIC;
BLO : STD_LOGIC;
TTL : STD_LOGIC;
INV : STD_LOGIC;
end record;
type t_I2C_master_out is
record
SCL : STD_LOGIC;
SDA : STD_LOGIC;
end record;
subtype t_I2C_slave_in is t_I2C_master_out;
type t_I2C_master_in is
record
SDA : STD_LOGIC;
end record;
subtype t_I2C_slave_out is t_I2C_master_in;
type t_SPI_master_out is
record
CCLK : STD_LOGIC;
CSO_B_N : STD_LOGIC;
MOSI : STD_LOGIC;
end record;
subtype t_SPI_slave_in is t_SPI_master_out;
type t_SPI_master_in is
record
DIN : STD_LOGIC;
end record;
subtype t_SPI_slave_out is t_SPI_master_in;
type t_RTM_id is
record
RTMM : STD_LOGIC_VECTOR(2 downto 0);
RTMP : STD_LOGIC_VECTOR(2 downto 0);
end record;
end image1_top_pkg;
package body image1_top_pkg is
end image1_top_pkg;
#Ignore LaTeX trash
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
project/*
project/*/
project/bitstream/*.*
!project/bitstream/basic_trigger_top.bit
!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
----------------------------------------------------------------------------------
-- Company: CERN, BE-CO-HT
-- Engineer: Carlos Gil Soriano
--
-- Create Date: 09:58:06 10/12/2011
--
-- Create Date: 09:58:06 10/12/2011
-- Design Name: HDL trigger top
-- Module Name: trigger - Behavioral
-- Module Name: trigger - Behavioral
-- Project Name: CTDAH
-- Target Devices: Spartan 6
-- Tool versions:
-- Tool versions:
-- Description: This is the wishbone trigger which receives a input
-- and outputs a trigger signal for the pulse converter.
-- It internally debounces the inputs and control the output
......@@ -15,9 +15,9 @@
-- The registers it has can be modified via wishbone access.
-- Dependencies: none
--
-- Revision:
-- Revision:
-- Revision 0.1
-- Additional Comments:
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
......@@ -30,8 +30,7 @@ use UNISIM.VCOMPONENTS.ALL;
entity basic_trigger_top is
generic(g_NUMBER_OF_CHANNELS : NATURAL := 6);
port (
FPGA_CLK_P : in STD_LOGIC;
FPGA_CLK_N : in STD_LOGIC;
clk_125m_i : in STD_LOGIC;
led_pw_o : out STD_LOGIC;
led_err_o : out STD_LOGIC;
......@@ -69,8 +68,8 @@ end basic_trigger_top;
architecture Behavioral of basic_trigger_top is
signal s_pulse_i : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_pulse_i_front : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_pulse_i : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_pulse_i_front : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_pulse_o : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_pulse_n_o : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
signal s_led : STD_LOGIC_VECTOR(g_NUMBER_OF_CHANNELS downto 1);
......@@ -127,8 +126,8 @@ begin
led_ttl_o <= not(s_level);
led_link_up_o <= not(s_locked);
led_pps_o <= '1';
led_wr_ok_o <= '1';
led_pps_o <= '1';
led_wr_ok_o <= '1';
--! s_level '1' means TTL input, as we have one inverter in the board we
--! invert here.
......@@ -151,12 +150,7 @@ begin
--! and a buffer in the output, there's no need
--! of invert here.
U_Buf_CLK_PLL : IBUFGDS
generic map (DIFF_TERM => TRUE,
IBUF_LOW_PWR => TRUE)
port map (O => s_clk_125m_i, -- Buffer output
I => FPGA_CLK_P,
IB => FPGA_CLK_N);
s_clk_125m_i <= clk_125m_i;
-- set up the fabric PLL_BASE to drive the BUFPLL
pll_base_inst : PLL_BASE
......@@ -195,13 +189,13 @@ begin
i_repetitors: for i in 1 to g_NUMBER_OF_CHANNELS generate
begin
trigger: basic_trigger_core
port map (
wb_rst_i => s_rst(c_RST_CLKS - 1),
wb_clk_i => s_clk_200m,
port map (
wb_rst_i => s_rst(c_RST_CLKS - 1),
wb_clk_i => s_clk_200m,
pulse_i => s_pulse_i(i),
pulse_o => s_pulse_o(i),
pulse_n_o => s_pulse_n_o(i),
pulse_i => s_pulse_i(i),
pulse_o => s_pulse_o(i),
pulse_n_o => s_pulse_n_o(i),
crop_o => open,
......
#Ignore LaTeX trash
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
project/*
project/*/
project/bitstream_async/*.*
!project/bitstream_async/basic_trigger_top.bit
!project/bitstream_async/basic_trigger_top.bit!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
#Ignore LaTeX trash
./doc/.*
./doc/.*.swo
./doc/.*.swp
./doc/Figures/*.eps
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
./project/
!/project/project.gise
!/project/project.xise
!/project/waveform/
project/*
project/*/
!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
./rtl/.*.swo
./rtl/.*.swp
./test/.*.swo
./test/.*.swp
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
......@@ -71,7 +71,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
......@@ -6555,7 +6555,10 @@
<g
style="fill:none;stroke:#c00000;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="translate(-76,0)"
id="g8125-6-7-5">
id="g8125-6-7-5"
inkscape:export-filename="/media/BACKUP/CERN/contrib/ohwr-git/conv-ttl-blo/hdl/i2c_slave_wb_master/doc/Figures/i2c_write.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300">
<g
style="fill:none;stroke:#c00000;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="g8051-7-4-98-5"
......@@ -6594,7 +6597,10 @@
<g
id="g8125-7-3-6-5"
style="fill:none;stroke:#c00000;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="translate(44,-1.7812499e-7)">
transform="translate(44,-1.7812499e-7)"
inkscape:export-filename="/media/BACKUP/CERN/contrib/ohwr-git/conv-ttl-blo/hdl/i2c_slave_wb_master/doc/Figures/i2c_write.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300">
<g
style="fill:none;stroke:#c00000;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="g8051-7-8-7-0-7"
......@@ -6636,7 +6642,10 @@
id="g8125-6-7-5-18">
<g
id="g15119"
transform="translate(-6.5213013,0)">
transform="translate(-6.5213013,0)"
inkscape:export-filename="/media/BACKUP/CERN/contrib/ohwr-git/conv-ttl-blo/hdl/i2c_slave_wb_master/doc/Figures/i2c_write.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300">
<g
style="fill:none;stroke:#c00000;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="g15107"
......@@ -6678,7 +6687,10 @@
</g>
<g
id="g15173"
transform="translate(12,0)">
transform="translate(12,0)"
inkscape:export-filename="/media/BACKUP/CERN/contrib/ohwr-git/conv-ttl-blo/hdl/i2c_slave_wb_master/doc/Figures/i2c_write.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300">
<g
style="fill:none;stroke:#0000be;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="g15107-1"
......
......@@ -169,11 +169,10 @@
<status xil_pn:value="SuccessfullyRun"/>
<status xil_pn:value="ReadyToRun"/>
</transform>
<transform xil_pn:end_ts="1352382626" xil_pn:in_ck="6441921431846390163" xil_pn:name="TRANEXT_xstsynthesize_spartan6" xil_pn:prop_ck="-8022121412301228921" xil_pn:start_ts="1352382619">
<status xil_pn:value="FailedRun"/>
<transform xil_pn:end_ts="1353947874" xil_pn:in_ck="6441921431846390163" xil_pn:name="TRANEXT_xstsynthesize_spartan6" xil_pn:prop_ck="-8022121412301228921" xil_pn:start_ts="1353947856">
<status xil_pn:value="SuccessfullyRun"/>
<status xil_pn:value="WarningsGenerated"/>
<status xil_pn:value="ReadyToRun"/>
<status xil_pn:value="OutOfDateForInputs"/>
<status xil_pn:value="InputChanged"/>
<outfile xil_pn:name="_xmsgs/xst.xmsgs"/>
<outfile xil_pn:name="i2c_bit.ngr"/>
<outfile xil_pn:name="i2c_slave_core.ngr"/>
......@@ -181,6 +180,7 @@
<outfile xil_pn:name="i2c_slave_top.ngc"/>
<outfile xil_pn:name="i2c_slave_top.ngr"/>
<outfile xil_pn:name="i2c_slave_top.prj"/>
<outfile xil_pn:name="i2c_slave_top.stx"/>
<outfile xil_pn:name="i2c_slave_top.syr"/>
<outfile xil_pn:name="i2c_slave_top.xst"/>
<outfile xil_pn:name="i2c_slave_top_tb_beh.prj"/>
......
......@@ -25,15 +25,15 @@
</file>
<file xil_pn:name="../rtl/i2c_regs.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="9"/>
<association xil_pn:name="Implementation" xil_pn:seqID="9"/>
<association xil_pn:name="Implementation" xil_pn:seqID="8"/>
</file>
<file xil_pn:name="../rtl/i2c_slave_core.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="8"/>
<association xil_pn:name="Implementation" xil_pn:seqID="8"/>
<association xil_pn:name="Implementation" xil_pn:seqID="7"/>
</file>
<file xil_pn:name="../rtl/i2c_slave_top.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="11"/>
<association xil_pn:name="Implementation" xil_pn:seqID="10"/>
<association xil_pn:name="Implementation" xil_pn:seqID="9"/>
</file>
<file xil_pn:name="../test/i2c_slave_top_tb.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="14"/>
......@@ -55,7 +55,7 @@
</file>
<file xil_pn:name="../../ctdah_lib/rtl/gc_clk_divider.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="0"/>
<association xil_pn:name="Implementation" xil_pn:seqID="7"/>
<association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file>
<file xil_pn:name="../../ctdah_lib/rtl/gc_counter.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="6"/>
......
......@@ -525,20 +525,24 @@ begin
end process;
--! @brief Small process that records the length of a
--! bit over the I2C interface.
--! @param i2c_SLA_fsm Actual value of the fsm
--! @param i2c_SLA_fsm_d0 One-wb_clocked delayed value of the fsm
p_LT_SCLP: process(i2c_SLA_fsm,
i2c_SLA_fsm_d0)
variable v_count : STD_LOGIC_VECTOR(23 downto 0);
--! @brief Small process that records the length of a
--! bit over the I2C interface.
--! @param clk Main clock
p_LT_SCLP: process(clk)
variable v_count : STD_LOGIC_VECTOR(23 downto 0);
begin
if i2c_SLA_fsm = S2A_I2C_ADDR_ACK
and i2c_SLA_fsm_d0 = S2_I2C_ADDR then
if rising_edge(clk) then
if i2c_SLA_fsm = R0_RESET then
s_LT.SCLP <= c_LT_default.SCLP;
else
if i2c_SLA_fsm = S2A_I2C_ADDR_ACK
and i2c_SLA_fsm_d0 = S2_I2C_ADDR then
--! Here we do a division bit 8, because the watchdog timer,
--! is counting for 8 scl clocks
v_count := s_watchdog_cnt_slv(24 - 1 + 3 downto 3);
s_LT.SCLP <= UNSIGNED(v_count);
v_count := s_watchdog_cnt_slv(24 - 1 + 3 downto 3);
s_LT.SCLP <= UNSIGNED(v_count);
end if;
end if;
end if;
end process;
......
......@@ -91,6 +91,7 @@ begin
pf_wb_addr_o <= s_pf_wb_addr;
rd_done_o <= s_rd_done;
wr_done_o <= s_wr_done;
--! Added for simulation
s_CTR0 <= f_CTR0(s_CTR0_slv);
inst_i2c_slave_core: i2c_slave_core
......
......@@ -62,10 +62,6 @@ architecture Behavioral of i2c_master_driver is
signal s_active_link : STD_LOGIC := '0';
signal s_i2c_addr_op : STD_LOGIC_VECTOR(7 downto 0);
signal s_DTX : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
begin
file_open(s_file_handler, c_LOG_PATH, WRITE_MODE);
......@@ -87,7 +83,7 @@ begin
p_sda: process
variable v_bit_number : NATURAL := 0;
variable v_write_data : STD_LOGIC_VECTOR(g_RD_DATA_LENGTH - 1 downto 0);
variable v_i2c_addr_op : STD_LOGIC_VECTOR(7 downto 0);
--! @brief Function that returns strings for the acked field to be
--! logged.
......@@ -118,17 +114,6 @@ begin
return v_return;
end function;
function order_i2c_addr_op(
i2c_addr_op : STD_LOGIC_VECTOR(7 downto 0))
return STD_LOGIC_VECTOR is
variable v_return : STD_LOGIC_VECTOR(7 downto 0);
begin
for i in 0 to 7 loop
v_return(7-i) := i2c_addr_op(i);
end loop;
return v_return;
end function;
--! @brief Function to reorder data before being sent by driver
--! through SDA
--! @param data Data to be reordered before being sent
......@@ -199,9 +184,10 @@ begin
wait until falling_edge(s_scl_clk);
end procedure;
--! @brieg Procedure to start/restart I2C communication
procedure start_restart_I2c is
begin
begin
if start_i = '1' then
wait until rising_edge(s_scl_clk);
wait for g_SCL_PERIOD/4;
s_sda_master_o <= '0';
......@@ -211,86 +197,22 @@ begin
s_start_done <= '1';
wait until rising_edge(tb_clk);
s_start_done <= '0';
end procedure;
--! @brief Procedure to pause I2c communication
procedure pause_I2C is
begin
wait for g_SCL_PERIOD/4;
s_sda_master_o <= '0';
wait until rising_edge(s_scl_clk);
wait for g_SCL_PERIOD/4;
s_sda_master_o <= '1';
s_active_link <= '1';
--! We allow one clock to let i2c_slave_core.vhd to react
wait until rising_edge(tb_clk);
s_pause_done <= '1';
wait until rising_edge(tb_clk);
s_pause_done <= '0';
s_active_link <= '0';
end procedure;
procedure read_bit is
variable v_bit_rcv : STD_LOGIC;
begin
wait until rising_edge(s_scl_clk);
v_bit_rcv := sda_master_i;
for i in 0 to (g_SCL_PERIOD/2)/(1 ns) - 1 loop
if v_bit_rcv /= sda_master_i then
--! Here we report an error
end if;
wait for 1 ns;
end loop;
wait until falling_edge(s_scl_clk);
s_DTX(s_DTX'length - 1) <= v_bit_rcv;
end procedure;
procedure shift_bit is
begin
for i in 1 to s_DTX'length - 1 loop
s_DTX(i-1) <= s_DTX(i);
end loop;
end procedure;
procedure read_byte is
begin
for i in 0 to 7 loop
read_bit;
shift_bit;
end loop;
--! At the end we are just in the falling edge of scl
end procedure;
procedure place_ack is
begin
elsif pause_i = '1' then
wait for g_SCL_PERIOD/4;
s_sda_master_o <= '0';
wait until falling_edge(s_scl_clk);
s_sda_master_o <= '1';
end procedure;
procedure place_nack is
begin
wait until rising_edge(s_scl_clk);
wait for g_SCL_PERIOD/4;
s_sda_master_o <= '1';
s_active_link <= '1';
wait until falling_edge(s_scl_clk);
s_sda_master_o <= '0';
end procedure;
begin
if start_i = '1' then
start_restart_I2c;
elsif pause_i = '1' then
pause_I2C;
s_pause_done <= '1';
wait for 1 ns;
s_pause_done <= '0';
elsif write_i = '1' then
s_test_id <= s_test_id + 1;
v_write_data := order_write_data(wr_data_i);
--! 1.- Send [ADDRESS|0]
v_i2c_addr_op := i2c_addr_op_i;
v_i2c_addr_op(0) := '0';
send_byte(order_i2c_addr_op(v_i2c_addr_op));
send_byte(i2c_addr_op_i);
check_ack(s_test_id, "WRITE", ADDRESS_0);
--! 2.- Send wishbone address high
send_byte(wishbone_addr_i(15 downto 8));
......@@ -310,47 +232,8 @@ begin
--! 7.- Send DATA3
send_byte(wr_data_i(31 downto 24));
check_ack(s_test_id, "WRITE", DATA3);
pause_I2C;
s_write_done <= '1';
wait until rising_edge(tb_clk);
s_write_done <= '0';
s_active_link <= '0';
elsif read_i = '1' then
s_test_id <= s_test_id + 1;
v_write_data := order_write_data(wr_data_i);
--! 1.- Send [ADDRESS|0]
v_i2c_addr_op := i2c_addr_op_i;
v_i2c_addr_op(0) := '0';
send_byte(order_i2c_addr_op(v_i2c_addr_op));
check_ack(s_test_id, " READ", ADDRESS_0);
--! 2.- Send wishbone address high
send_byte(wishbone_addr_i(15 downto 8));
check_ack(s_test_id, " READ", WISHBONE_HIGH);
--! 3.- Send wishbone address low
send_byte(wishbone_addr_i(7 downto 0));
check_ack(s_test_id, " READ", WISHBONE_LOW);
--! 4.- We have to place a start condition
start_restart_I2c;
--! 5.- Send [ADDRESS|1]
v_i2c_addr_op(7 downto 1) := i2c_addr_op_i(7 downto 1);
v_i2c_addr_op(0) := '1';
send_byte(order_i2c_addr_op(v_i2c_addr_op));
check_ack(s_test_id, " READ", ADDRESS_0);
--! 6.- Read DATA0
read_byte;
place_ack;
--! 7.- Read DATA1
read_byte;
place_ack;
--! 8.- Read DATA2
read_byte;
place_ack;
--! 9.- Read DATA3
read_byte;
place_ack;
pause_I2C;
s_read_done <= '1';
wait until rising_edge(tb_clk);
s_read_done <= '0';
end if;
wait until rising_edge(tb_clk);
end process;
......
#Ignore LaTeX trash
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
project/*
project/*/
!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
test/sv/*
#Ignore LaTeX trash
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
project/*
project/*/
!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
......@@ -45,11 +45,11 @@
</file>
<file xil_pn:name="../../ctdah_lib/test/wishbone_driver_pkg.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="6"/>
<association xil_pn:name="Implementation" xil_pn:seqID="36"/>
<association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file>
<file xil_pn:name="../../ctdah_lib/test/wishbone_driver.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="7"/>
<association xil_pn:name="Implementation" xil_pn:seqID="37"/>
<association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file>
</files>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -361,7 +361,7 @@ package body multiboot_pkg is
--! @brief STAT register translation function from r_STAT to slv
--! @param r_register slv to be translated
function f_STD_LOGIC_VECTOR (r_register : r_STAT) return STD_LOGIC_VECTOR is
variable v_return : STD_LOGIC_VECTOR(31 downto 0);
variable v_return : STD_LOGIC_VECTOR(15 downto 0);
begin
v_return(0) := r_register.CRC;
v_return(1) := r_register.ID;
......
......@@ -126,13 +126,19 @@ begin
when '0' =>
case v_wb_addr is
when CTR0_addr =>
s_wb_data_o <= f_STD_LOGIC_VECTOR(s_CTR0);
s_wb_data_o (31 downto 8) <= (others => '0');
s_wb_data_o ( 7 downto 0)
<= f_STD_LOGIC_VECTOR(s_CTR0);
s_wb_ack <= '1';
when CTR1_addr =>
s_wb_data_o <= f_STD_LOGIC_VECTOR(s_CTR1);
s_wb_data_o (31 downto 8) <= (others => '0');
s_wb_data_o ( 7 downto 0)
<= f_STD_LOGIC_VECTOR(s_CTR1);
s_wb_ack <= '1';
when STAT_addr =>
s_wb_data_o <= f_STD_LOGIC_VECTOR(s_STAT);
s_wb_data_o (31 downto 16) <= (others => '0');
s_wb_data_o (15 downto 0)
<= f_STD_LOGIC_VECTOR(s_STAT);
s_wb_ack <= '1';
when c_MBA_addr =>
s_wb_data_o <= f_STD_LOGIC_VECTOR(s_MBA);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
-----------------------------------------
----- multiboot_core_tb.vhd -----
-----------------------------------------
Test ID Status Description
0x0 OK GENERAL1_ICAP register initialization
0x1 OK GENERAL2_ICAP register initialization
0x2 OK GENERAL3_ICAP register initialization
0x3 OK GENERAL4_ICAP register initialization
0x4 OK STAT_ICAP register initialization
0x5 OK Multiboot sequence is correct
0x6 OK GENERAL1 write sequence is correct
0x7 OK GENERAL2 write sequence is correct
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -divider multiboot_regs.vhd
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/CTRL_s
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/STAT_s
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/GENERAL1_s
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/GENERAL2_s
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/GENERAL3_s
add wave -noupdate /multiboot_tb/uut/multiboot_regs_inst/GENERAL4_s
add wave -noupdate -divider multiboot_core.vhd
add wave -noupdate -divider multiboot_top.vhd
add wave -noupdate /multiboot_tb/wb_rst_i
add wave -noupdate /multiboot_tb/wb_clk
add wave -noupdate /multiboot_tb/wb_we_i
add wave -noupdate -group wb_ops /multiboot_tb/wb_stb_i
add wave -noupdate -group wb_ops /multiboot_tb/wb_cyc_i
add wave -noupdate -group wb_ops /multiboot_tb/wb_ack_o
add wave -noupdate -group wb_ops /multiboot_tb/wb_rty_o
add wave -noupdate -group wb_ops /multiboot_tb/wb_err_o
add wave -noupdate -group wb_data -radix hexadecimal /multiboot_tb/wb_data_i
add wave -noupdate -group wb_data -radix hexadecimal /multiboot_tb/wb_data_o
add wave -noupdate -group wb_data -radix hexadecimal /multiboot_tb/wb_addr_i
add wave -noupdate -divider multiboot_top_tb.vhd
add wave -noupdate -radix hexadecimal /multiboot_tb/GENERAL1_data
add wave -noupdate -radix hexadecimal /multiboot_tb/GENERAL2_data
add wave -noupdate -radix hexadecimal /multiboot_tb/GENERAL3_data
add wave -noupdate -radix hexadecimal /multiboot_tb/GENERAL4_data
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {125000 ps} 0}
configure wave -namecolwidth 388
configure wave -valuecolwidth 100
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {1470 ns}
#Ignore swap files
rtl/.*.*.swo
rtl/.*.*.swp
rtl/.swp
rtl/.swo
library IEEE;
library work;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.rtm_detector_pkg.ALL;
entity rtm_detector is
generic(g_identifier_RTMM : t_RTMM;
g_identifier_RTMP : t_RTMP);
port (RTMM_i : in STD_LOGIC_VECTOR(2 downto 0);
RTMP_i : in STD_LOGIC_VECTOR(2 downto 0);
ok_RTMM_o : out STD_LOGIC;
ok_RTMP_o : out STD_LOGIC);
end rtm_detector;
architecture Behavioral of rtm_detector is
signal s_identifier_RTMM : UNSIGNED(2 downto 0)
:= f_UNSIGNED(g_identifier_RTMM);
signal s_identifier_RTMP : UNSIGNED(2 downto 0)
:= f_UNSIGNED(g_identifier_RTMP);
signal s_RTMM : UNSIGNED(2 downto 0);
signal s_RTMP : UNSIGNED(2 downto 0);
begin
s_RTMM <= UNSIGNED(RTMM_i);
s_RTMP <= UNSIGNED(RTMP_i);
ok_RTMM_o <= '1' when s_RTMM = s_identifier_RTMM
else '0';
ok_RTMP_o <= '1' when s_RTMP = s_identifier_RTMP
else '0';
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.ALL;
package rtm_detector_pkg is
--! Please refer to:
--! http://www.ohwr.org/projects/conv-ttl-blo/wiki/RTM_board_detection
--! to see conventions used to guarantee consistency between front board
--! and read transition modules
--! It should be noted that the RTMM, and RTMP pins are pulled up in
--! all the Front boards.
--! On 27/Nov/2012 the correspondencies are:
--!
--! __________________________________________
--! | Board | RTMM[2] | RTMM[1] | RTMM[0] |
--! +-----------------------------------------+
--! | Error | '1' | '1' | '1' |
--! | RTMM_V1 | '1' | '1' | '0' |
--! | Reserved0 | '1' | '0' | '1' |
--! | Reserved1 | '1' | '0' | '0' |
--! | Reserved2 | '0' | '1' | '1' |
--! | Reserved3 | '0' | '1' | '0' |
--! | Reserved4 | '0' | '0' | '1' |
--! | Reserved5 | '0' | '0' | '0' |
--! +-----------+---------+---------+---------+
--!
--! _____________________________________________
--! | Board | RTMP[2] | RTMP[1] | RTMP[0] |
--! +-------------------------------------------+
--! | Error | '1' | '1' | '1' |
--! | Blocking_V1 | '1' | '1' | '0' |
--! | RS485_V1 | '1' | '0' | '1' |
--! | Reserved0 | '1' | '0' | '0' |
--! | Reserved1 | '0' | '1' | '1' |
--! | Reserved2 | '0' | '1' | '0' |
--! | Reserved3 | '0' | '0' | '1' |
--! | Reserved4 | '0' | '0' | '0' |
--! +-------------+---------+---------+---------+
--!
--! It should be noted that there is an inverter before the FPGA,
--! so the signals/constant will be negated in rtm_detector.vhd
type t_RTMM is (RTMM_ERROR,
RTMM_V1,
RESERVED0,
RESERVED1,
RESERVED2,
RESERVED3,
RESERVED4,
RESERVED5);
type t_RTMP is (RTMP_ERROR,
RTMP_BLOCKING_V1,
RTMP_RS485_V1,
RESERVED0,
RESERVED1,
RESERVED2,
RESERVED3,
RESERVED4);
constant c_RTMM_ERROR : UNSIGNED(2 downto 0) := "111";
constant c_RTMM_V1 : UNSIGNED(2 downto 0) := "110";
constant c_RTMM_RESERVED0 : UNSIGNED(2 downto 0) := "101";
constant c_RTMM_RESERVED1 : UNSIGNED(2 downto 0) := "100";
constant c_RTMM_RESERVED2 : UNSIGNED(2 downto 0) := "011";
constant c_RTMM_RESERVED3 : UNSIGNED(2 downto 0) := "010";
constant c_RTMM_RESERVED4 : UNSIGNED(2 downto 0) := "001";
constant c_RTMM_RESERVED5 : UNSIGNED(2 downto 0) := "000";
constant c_RTMP_ERROR : UNSIGNED(2 downto 0) := "111";
constant c_RTMP_BLOCKING_V1 : UNSIGNED(2 downto 0) := "110";
constant c_RTMP_RS485_V1 : UNSIGNED(2 downto 0) := "101";
constant c_RTMP_RESERVED0 : UNSIGNED(2 downto 0) := "100";
constant c_RTMP_RESERVED1 : UNSIGNED(2 downto 0) := "011";
constant c_RTMP_RESERVED2 : UNSIGNED(2 downto 0) := "010";
constant c_RTMP_RESERVED3 : UNSIGNED(2 downto 0) := "001";
constant c_RTMP_RESERVED4 : UNSIGNED(2 downto 0) := "000";
function f_UNSIGNED(identifier: t_RTMM) return UNSIGNED;
function f_UNSIGNED(identifier: t_RTMP) return UNSIGNED;
function f_RTMM(bit_code: UNSIGNED(2 downto 0)) return t_RTMM;
function f_RTMP(bit_code: UNSIGNED(2 downto 0)) return t_RTMP;
end rtm_detector_pkg;
package body rtm_detector_pkg is
--! @brief translation function from t_rtmp to unsigned
--! @param identifier t_rtmp type to be translated
function f_UNSIGNED(identifier: t_RTMM) return UNSIGNED is
variable v_return : UNSIGNED(2 downto 0);
begin
v_return := c_RTMM_ERROR;
case identifier is
when RTMM_ERROR =>
null;
when RTMM_V1 =>
v_return := c_RTMM_V1;
when RESERVED0 =>
v_return := c_RTMM_RESERVED0;
when RESERVED1 =>
v_return := c_RTMM_RESERVED1;
when RESERVED2 =>
v_return := c_RTMM_RESERVED2;
when RESERVED3 =>
v_return := c_RTMM_RESERVED3;
when RESERVED4 =>
v_return := c_RTMM_RESERVED4;
when RESERVED5 =>
v_return := c_RTMM_RESERVED5;
when others =>
null;
end case;
return v_return;
end f_UNSIGNED;
--! @brief translation function from t_rtmp to unsigned
--! @param identifier t_rtmp type to be translated
function f_UNSIGNED(identifier: t_RTMP) return UNSIGNED is
variable v_return : UNSIGNED(2 downto 0);
begin
v_return := c_RTMP_ERROR;
case identifier is
when RTMP_ERROR =>
null;
when RTMP_BLOCKING_V1 =>
v_return := c_RTMP_BLOCKING_V1;
when RTMP_RS485_V1 =>
v_return := c_RTMP_RS485_V1;
when RESERVED0 =>
v_return := c_RTMP_RESERVED0;
when RESERVED1 =>
v_return := c_RTMP_RESERVED1;
when RESERVED2 =>
v_return := c_RTMP_RESERVED2;
when RESERVED3 =>
v_return := c_RTMP_RESERVED3;
when RESERVED4 =>
v_return := c_RTMP_RESERVED4;
when others =>
null;
end case;
return v_return;
end f_UNSIGNED;
--! @brief translation function from unsigned to t_RTMM
--! @param bit_code bit_code to be translated
function f_RTMM(bit_code: UNSIGNED(2 downto 0)) return t_RTMM is
variable v_return : t_RTMM;
begin
v_return := RTMM_ERROR;
case bit_code is
when c_RTMM_ERROR =>
null;
when c_RTMM_V1 =>
v_return := RTMM_V1;
when c_RTMM_RESERVED0 =>
v_return := RESERVED0;
when c_RTMM_RESERVED1 =>
v_return := RESERVED1;
when c_RTMM_RESERVED2 =>
v_return := RESERVED2;
when c_RTMM_RESERVED3 =>
v_return := RESERVED3;
when c_RTMM_RESERVED4 =>
v_return := RESERVED4;
when c_RTMM_RESERVED5 =>
v_return := RESERVED5;
when others =>
null;
end case;
return v_return;
end f_RTMM;
--! @brief translation function from unsigned to t_RTMP
--! @param bit_code bit_code to be translated
function f_RTMP(bit_code: UNSIGNED(2 downto 0)) return t_RTMP is
variable v_return : t_RTMP;
begin
v_return := RTMP_ERROR;
case bit_code is
when c_RTMP_ERROR =>
null;
when c_RTMP_BLOCKING_V1 =>
v_return := RTMP_BLOCKING_V1;
when c_RTMP_RS485_V1 =>
v_return := RTMP_RS485_V1;
when c_RTMP_RESERVED0 =>
v_return := RESERVED0;
when c_RTMP_RESERVED1 =>
v_return := RESERVED1;
when c_RTMP_RESERVED2 =>
v_return := RESERVED2;
when c_RTMP_RESERVED3 =>
v_return := RESERVED3;
when c_RTMP_RESERVED4 =>
v_return := RESERVED4;
when others =>
null;
end case;
return v_return;
end f_RTMP;
end rtm_detector_pkg;
#Ignore LaTeX trash
doc/.*
doc/.*_*
doc/*.*
doc/.*.*.swp
doc/.*.*.swp
doc/Figures/*.eps
!doc/*.tex
!doc/*.pdf
#Ignore autotrash from ISE
project/*
project/*/
!project/project.gise
!project/project.xise
!project/waveform/
#Ignore swap files at rtl/ and test/ folders
rtl/.*.*.swo
rtl/.*.*.swp
test/.*.*.swo
test/.*.*.swp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment