Commit a78517b2 authored by Javier Díaz's avatar Javier Díaz Committed by Miguel Jimenez Lopez

pipelined wb slaves and dio adapter

parent b0e208d2
#!/bin/bash
mkdir -p doc
wbgen2 -D ./doc/dio.html -V wrsw_dio_wb.vhd --cstyle defines --lang vhdl -K ../../sim/dio_timing_regs.vh wrsw_dio.wb
# wbgen2 -D ./doc/dio.html -V wrsw_dio_wb.vhd --cstyle defines --lang vhdl -p dio_wbgen2_pkg.vhd -H record -K ../../sim/dio_timing_regs.vh wrsw_dio.wb
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Entity: immed_pulse counter -- Entity: immed_pulse counter
-- File: immed_pulse counter.vhd -- File: immed_pulse counter.vhd
-- Description: a simple synchronous output based on strobe inputs that produces a N-ticks -- Description: a simple synchronous output based on asynchronous strobe inputs that produces a N-ticks
-- length pulse. -- length pulse.
-- Author: Javier Díaz (jdiaz@atc.ugr.es) -- Author: Javier Díaz (jdiaz@atc.ugr.es)
-- Date: 9 July 2012 -- Date: 9 July 2012
...@@ -43,8 +43,8 @@ entity immed_pulse_counter is ...@@ -43,8 +43,8 @@ entity immed_pulse_counter is
clk_i : in std_logic; clk_i : in std_logic;
rst_n_i : in std_logic; -- asynchronous system reset rst_n_i : in std_logic; -- asynchronous system reset
pulse_start_i : in std_logic; -- strobe for pulse generation pulse_start_i : in std_logic; -- asynchronous strobe for pulse generation
pulse_length_i : in std_logic_vector(pulse_length_width-1 downto 0); pulse_length_i : in std_logic_vector(pulse_length_width-1 downto 0); -- asynchronous signal
pulse_output_o : out std_logic pulse_output_o : out std_logic
); );
...@@ -60,11 +60,35 @@ architecture rtl of immed_pulse_counter is ...@@ -60,11 +60,35 @@ architecture rtl of immed_pulse_counter is
type counter_state is (WAIT_ST, COUNTING); type counter_state is (WAIT_ST, COUNTING);
signal state : counter_state; signal state : counter_state;
-- Signal for synchronization (in fact they are not so necessary for current system...)
signal pulse_start_d0, pulse_start_d1, pulse_start_d2, pulse_start_d3 : std_logic;
signal nozerolength : boolean;
-- Aux -- Aux
constant zeros : std_logic_vector(pulse_length_width-1 downto 0) := (others=>'0'); constant zeros : std_logic_vector(pulse_length_width-1 downto 0) := (others=>'0');
begin -- architecture rtl begin -- architecture rtl
synchronization: process(clk_i, rst_n_i)
begin
if (rst_n_i='0') then
pulse_start_d0 <='0';
pulse_start_d1 <='0';
pulse_start_d2 <='0';
pulse_start_d3 <='0';
elsif rising_edge(clk_i) then
pulse_start_d0<=pulse_start_i;
pulse_start_d1<=pulse_start_d0;
pulse_start_d2<=pulse_start_d1;
pulse_start_d3<=pulse_start_d2;
if (pulse_start_d2='1' and pulse_start_d1='0') then
nozerolength<=pulse_length_i/=zeros;
end if;
end if;
end process;
state_process : process(clk_i, rst_n_i) state_process : process(clk_i, rst_n_i)
begin begin
if (rst_n_i='0') then if (rst_n_i='0') then
...@@ -73,7 +97,7 @@ begin -- architecture rtl ...@@ -73,7 +97,7 @@ begin -- architecture rtl
elsif rising_edge(clk_i) then elsif rising_edge(clk_i) then
case state is case state is
when WAIT_ST => when WAIT_ST =>
if pulse_start_i='1' and pulse_length_i/=zeros then if pulse_start_d3='1' and nozerolength then
state <=COUNTING; state <=COUNTING;
counter <=unsigned(pulse_length_i)-1; counter <=unsigned(pulse_length_i)-1;
else else
...@@ -92,6 +116,7 @@ begin -- architecture rtl ...@@ -92,6 +116,7 @@ begin -- architecture rtl
end if; end if;
end process; end process;
output_process:process(counter, state) output_process:process(counter, state)
begin begin
if (rst_n_i='0') then if (rst_n_i='0') then
......
...@@ -96,8 +96,9 @@ architecture rtl of pulse_gen_pl is ...@@ -96,8 +96,9 @@ architecture rtl of pulse_gen_pl is
signal trig_valid_ref_p1 : std_logic; signal trig_valid_ref_p1 : std_logic;
-- Aux -- Aux
constant zeros : std_logic_vector(27 downto 0) := (others=>'0'); constant zeros : std_logic_vector(27 downto 0) := (others=>'0');
signal counter : unsigned (27 downto 0); signal counter : unsigned (27 downto 0);
signal nozerolength : boolean;
begin -- architecture rtl begin -- architecture rtl
...@@ -176,6 +177,7 @@ begin -- architecture rtl ...@@ -176,6 +177,7 @@ begin -- architecture rtl
trig_utc_ref <= trig_utc; trig_utc_ref <= trig_utc;
trig_cycles_ref <= trig_cycles; trig_cycles_ref <= trig_cycles;
pulse_length_ref <= pulse_length; pulse_length_ref <= pulse_length;
nozerolength<=pulse_length /= zeros;
end if; end if;
end if; end if;
end process trig_regs_ref; end process trig_regs_ref;
...@@ -210,7 +212,7 @@ begin -- architecture rtl ...@@ -210,7 +212,7 @@ begin -- architecture rtl
elsif clk_ref_i'event and clk_ref_i='1' then elsif clk_ref_i'event and clk_ref_i='1' then
if tm_time_valid_i ='0' then if tm_time_valid_i ='0' then
pulse_o <= '0'; pulse_o <= '0';
elsif tm_utc_i=trig_utc_ref and tm_cycles_i=trig_cycles_ref and pulse_length_ref/=zeros then elsif tm_utc_i=trig_utc_ref and tm_cycles_i=trig_cycles_ref and nozerolength then
pulse_o <= '1'; pulse_o <= '1';
counter <=unsigned(pulse_length_ref)-1; counter <=unsigned(pulse_length_ref)-1;
elsif counter/=0 then elsif counter/=0 then
......
...@@ -178,8 +178,7 @@ U_WRAPPER_DIO : xwrsw_dio ...@@ -178,8 +178,7 @@ U_WRAPPER_DIO : xwrsw_dio
wb_ack_o <= wb_out.ack; wb_ack_o <= wb_out.ack;
wb_stall_o <= wb_out.stall; wb_stall_o <= wb_out.stall;
wb_irq_o <= wb_out.int; wb_irq_o <= wb_out.int;
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
end rtl; end rtl;
......
-- -*- Mode: LUA; tab-width: 2 -*- -- -*- Mode: LUA; tab-width: 2 -*-
-- White-Rabbit dio spec
-- author: JDiaz <jdiaz@atc.ugr.es>
--
-- Use wbgen2 to generate code, documentation and more.
-- wbgen2 is available at:
-- http://www.ohwr.org/projects/wishbone-gen
--
peripheral { peripheral {
name = "FMC-DIO-5chttla"; name = "FMC-DIO-5chttla",
description = "This core for adding timing information to a standard GPIO based on WR-CORE information. \
\
Operation \
~~~~~~~~~~ \
The registers used on this module allows to time-stamping input values, generate and immediate output or programmed output at a given time. \
\
* Programmable output: Use seconds and cycles registers for specify trigger time for each channel. Strobe signal is mandatory to latch these values otherwise no output will be generated. \
* Immediate output could be generate by making active the corresponding bits of the 'Pulse generate immediately' register. \
* Pulse length can be adjusted by writing a integer value at corresponding registers. The duration will be its value x 8 ns. \
* There are some few clock cycles that the system is not ready to latch new time information to triggers. This could be checked by checking dio trigger signals. In addition to pooling, interrupts are generated. Note that because is no ready time is about 200 ns, it would almost always available for the PC. \
* To activate programmable or immediate output generation, please remember to set corresponding bits of the output configuration registers. Otherwise this system behaves as normal GPIO without additional timing features. \
* FIFOs store seconds and cycles values of time-stamped events. Note that the FIFO depth is 256 and that output generated signals will be also stored in the FIFOs in the same why that external input do. \
* Interrupts are handle based on EIC registers. FIFOs not empty as well as ready signals of each GPIO are the interrupt sources. \
\
Todo \
~~~~ \
* Improve documentation. \
\
Known issues \
~~~~~~~~~~~ \
* None";
prefix="dio"; prefix="dio";
hdl_entity="wrsw_dio_wb"; hdl_entity="wrsw_dio_wb";
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- File : wrsw_dio_wb.vhd -- File : wrsw_dio_wb.vhd
-- Author : auto-generated by wbgen2 from wrsw_dio.wb -- Author : auto-generated by wbgen2 from wrsw_dio.wb
-- Created : Mon Jul 9 16:40:54 2012 -- Created : Fri Jul 27 17:57:07 2012
-- Standard : VHDL'87 -- Standard : VHDL'87
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wrsw_dio.wb -- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wrsw_dio.wb
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
-- 0x000: DIO-ONEWIRE -- 0x000: DIO-ONEWIRE
-- 0x100: DIO-I2C -- 0x100: DIO-I2C
-- 0x200: DIO-GPIO -- 0x200: DIO-GPIO
-- 0x300: DIO-REGISTERS -- 0x300: DIO-TIMING REGISTERS
-- WARNING: only pipelined mode is supported (Intercon is pipelined only) - T.W. -- 0x400: SDB-BRIDGE --> MAGIC NUMBER
library ieee; library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_1164.all;
...@@ -390,6 +390,9 @@ architecture rtl of xwrsw_dio is ...@@ -390,6 +390,9 @@ architecture rtl of xwrsw_dio is
signal slave_bypass_i : t_wishbone_slave_in; signal slave_bypass_i : t_wishbone_slave_in;
signal slave_bypass_o : t_wishbone_slave_out; signal slave_bypass_o : t_wishbone_slave_out;
signal wb_dio_slave_in : t_wishbone_slave_in;
signal wb_dio_slave_out : t_wishbone_slave_out;
-- DIO related signals -- DIO related signals
signal dio_pulse : std_logic_vector(4 downto 0); signal dio_pulse : std_logic_vector(4 downto 0);
signal dio_pulse_prog : std_logic_vector(4 downto 0); signal dio_pulse_prog : std_logic_vector(4 downto 0);
...@@ -467,7 +470,7 @@ begin ...@@ -467,7 +470,7 @@ begin
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
U_ONEWIRE : xwb_onewire_master U_ONEWIRE : xwb_onewire_master
generic map ( generic map (
g_interface_mode => PIPELINED, g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity, g_address_granularity => g_address_granularity,
g_num_ports => 1) g_num_ports => 1)
port map ( port map (
...@@ -485,9 +488,13 @@ begin ...@@ -485,9 +488,13 @@ begin
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- WB I2C MASTER -- WB I2C MASTER
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- i2c core does not handle extra signals.
-- cbar_master_in(1).err<='0';
-- cbar_master_in(1).rty<='0';
U_I2C : xwb_i2c_master U_I2C : xwb_i2c_master
generic map ( generic map (
g_interface_mode => PIPELINED, g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity g_address_granularity => g_address_granularity
) )
...@@ -517,7 +524,7 @@ begin ...@@ -517,7 +524,7 @@ begin
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
U_GPIO : xwb_gpio_port U_GPIO : xwb_gpio_port
generic map ( generic map (
g_interface_mode => PIPELINED, g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity, g_address_granularity => g_address_granularity,
g_num_pins => 32, g_num_pins => 32,
g_with_builtin_tristates => false) g_with_builtin_tristates => false)
...@@ -561,14 +568,14 @@ begin ...@@ -561,14 +568,14 @@ begin
slave_bypass_i.adr <= slave_i.adr; slave_bypass_i.adr <= slave_i.adr;
slave_bypass_i.sel <= slave_i.sel; slave_bypass_i.sel <= slave_i.sel;
slave_bypass_i.dat <= slave_i.dat; slave_bypass_i.dat <= slave_i.dat;
slave_bypass_i.we <= slave_i.we; slave_bypass_i.we <= slave_i.we;
slave_o.ack <= slave_bypass_o.ack; slave_o.ack <= slave_bypass_o.ack;
slave_o.stall <= slave_bypass_o.stall; slave_o.stall <= slave_bypass_o.stall;
slave_o.int <= wb_dio_irq; slave_o.int <= wb_dio_irq;
slave_o.dat <= slave_bypass_o.dat; slave_o.dat <= slave_bypass_o.dat;
--slave_o.err <= slave_bypass_o.err; slave_o.err <= slave_bypass_o.err;
--slave_o.rty <= slave_bypass_o.rty; slave_o.rty <= slave_bypass_o.rty;
immediate_output_with_pulse_length: for i in 0 to 4 generate immediate_output_with_pulse_length: for i in 0 to 4 generate
immediate_output_component: immed_pulse_counter immediate_output_component: immed_pulse_counter
...@@ -598,23 +605,45 @@ begin ...@@ -598,23 +605,45 @@ begin
gpio_in(29) <= dio_clk_i; gpio_in(29) <= dio_clk_i;
dio_sdn_ck_n_o <= gpio_out(30); dio_sdn_ck_n_o <= gpio_out(30);
dio_sdn_n_o <= gpio_out(31); dio_sdn_n_o <= gpio_out(31);
-- Adapter of wbgen2 salve signals to top wb mode and granularity
U_Adapter : wb_slave_adapter
generic map (
g_master_use_struct => true,
g_master_mode => PIPELINED,
g_master_granularity => WORD, -- only word acesses are available for wbgen2 slaves
g_slave_use_struct => true,
g_slave_mode => g_interface_mode,
g_slave_granularity => g_address_granularity)
port map (
clk_sys_i => clk_sys_i,
rst_n_i => rst_n_i,
slave_i => cbar_master_out(3),
slave_o => cbar_master_in (3),
master_i => wb_dio_slave_out,
master_o => wb_dio_slave_in);
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- WB DIO control registers -- WB DIO control registers
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
wb_dio_slave_out.err<='0';
wb_dio_slave_out.rty<='0';
wb_dio_slave_out.int<='0'; -- Real signal we bypass to crossbar
-- SUPPORTING PIPELINE WBGEN2 SLAVES
U_DIO_REGISTERS : wrsw_dio_wb U_DIO_REGISTERS : wrsw_dio_wb
port map( port map(
rst_n_i => rst_n_i, rst_n_i => rst_n_i,
clk_sys_i => clk_sys_i, clk_sys_i => clk_sys_i,
wb_adr_i => cbar_master_out(3).adr(7 downto 2), -- only word acesses are available wb_adr_i => wb_dio_slave_in.adr(5 downto 0),
wb_dat_i => cbar_master_out(3).dat, wb_dat_i => wb_dio_slave_in.dat,
wb_dat_o => cbar_master_in(3).dat, wb_dat_o => wb_dio_slave_out.dat,
wb_cyc_i => cbar_master_out(3).cyc, wb_cyc_i => wb_dio_slave_in.cyc,
wb_sel_i => cbar_master_out(3).sel, wb_sel_i => wb_dio_slave_in.sel,
wb_stb_i => cbar_master_out(3).stb, wb_stb_i => wb_dio_slave_in.stb,
wb_we_i => cbar_master_out(3).we, wb_we_i => wb_dio_slave_in.we,
wb_ack_o => cbar_master_in(3).ack, wb_ack_o => wb_dio_slave_out.ack,
wb_stall_o => cbar_master_in(3).stall, wb_stall_o => wb_dio_slave_out.stall,
-- Crossbar could not propagate interrupt lines of several slaves => signal bypass -- Crossbar could not propagate interrupt lines of several slaves => signal bypass
wb_int_o => wb_dio_irq, wb_int_o => wb_dio_irq,
clk_asyn_i => clk_ref_i, clk_asyn_i => clk_ref_i,
...@@ -735,12 +764,17 @@ begin ...@@ -735,12 +764,17 @@ begin
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
------ signals for debugging ------ signals for debugging
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
-- TRIG0 <= tag_utc(0)(31 downto 0); TRIG0(21 downto 0 ) <= tag_seconds(0)(21 downto 0);
-- TRIG1(27 downto 0) <= tag_cycles(0)(27 downto 0); TRIG0(22) <= irq_nempty(0);
-- TRIG1(0) <= cbar_master_in(3).int; TRIG0(23) <= tm_time_valid_i;
-- TRIG2 <= tm_utc(31 downto 0); TRIG0(31 downto 24) <= pulse_length(0)(7 downto 0);
-- TRIG3(2 downto 0) <= dio_in_i(0) & dio_out(0) & dio_pulse_immed(0); TRIG1(27 downto 0) <= tag_cycles(0)(27 downto 0);
--TRIG3(4 downto 0) <= dio_tsf_wr_req(0) & tag_valid_p1(0) & gpio_out(1) & dio_in_i(0) & dio_out(0); TRIG1(28) <= slave_bypass_o.int;
TRIG1(29) <= slave_bypass_o.ack;
TRIG1(30) <= dio_pulse(0);
TRIG1(31) <= gpio_out(0);
--TRIG3(2 downto 0) <=
--TRIG3(4 downto 0) <=
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
......
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