Commit f00d7ff1 authored by Javier Díaz's avatar Javier Díaz

pipelined wb slaves and dio adapter

parent e6a7b6c2
......@@ -15,6 +15,11 @@ Document compilation
use make command or
pandoc --toc -o wr-nic.pdf wr-nic.mkd
Additional info
=====================
Find peripherals register map from wbgen2 tool on NIC_peripheral_registers compressed file.
Problems?
------------
Check latex tools are installed and use command texhash
......@@ -32,7 +32,8 @@ The `GN4124 core` is a bridge between the GN4124 PCIe interface chip and the int
* The `NIC core` ensures communication between the host and the WRPC. More precisely, it interrupts the host and provides a descriptor that the host can use to fetch incoming frames. For outgoing frames, it receives a descriptor from the host, fetches the frame using PCIe via the GN4124 core and sends it to the WRPC using a pipelined Wishbone interface.
* The `TxTSU module` collect timestamps with associated Ethernet frame identifiers and puts them in a shared FIFO (port identifier is also included although not required for the SPEC card because only one Ethernet port is available but it is include to provide a common descriptor with the switch data). A IRQ is triggered when FIFO is not empty so drivers could read TX timestamps and frame/port identifiers.
In the next sections we provide a little more information about `DIO core` and the `WRPC (White Rabbit PTP Core)` in order to understand better how the whole system works.
In the next sections we provide a little more information about `DIO core` and the `WRPC (White Rabbit PTP Core)` in order to understand better how the whole system works.
Finally, it is important to know that current HDL code contains commented code to activate on-chip logic analyzer circuitry for debugging based on Chipscope of Xilinx. Top file as well as different peripherals include the signals TRIG0 - TRIG3 to help on this purpose. Nevertheless, by default they are commented to avoid wasting unnecessary resources.
WRPC (White Rabbit PTP Core)
----------------------------
......@@ -46,6 +47,8 @@ The `WRPC (White Rabbit PTP Core)` block is the HDL block that makes possible th
In this project, WRPC provides the timing information used for accurate output generation and input time stamping of the DIO signals. Note that this data is provided with an accuracy of 8 ns.
Please note that the current gateware contains the LM32 firmware (so the FPGA . Latest version is available at: `http://www.ohwr.org/projects/wrpc-sw/repository`. Gateware the wrc.ram file produced after firmware compilation.
It is important to remark that for this release the I2C bus of the FMC-DIO card is connected to WRPC. This is needed because current implementation of WRPC store configuration data on the FMC-DIO card EEPROM. Please be aware that for future releases this could change.
The whole description of the core goes beyond the scope of this documentation but the additional information is available at: `http://www.ohwr.org/projects/wr-cores/wiki/Wrpc_core` and in:
......@@ -131,24 +134,27 @@ Please note that each peripheral generating interrupts has own interrupts regist
For instance for the DIO core, please check the status of interrupt registers by looking at `wr_nic.wb ` as previously described.
Application & examples
======================
Software support and applications
=================================
This project could be used as starting demo with White-Rabbit technology, illustrating the timing capabilities of White-Rabbit technology. As already described, the current configuration allows to transform SPEC board on an Network Interface Card with White-Rabbit capabilities. In order of using it like this, some additional software is required:
* SPEC driver supporting the DIO card functionalities already described.
[JAVIER: THIS IS MUCH MORE FOR APPROPRIATED IN A GLOBAL DOCUMENT OR ONE ABOUT DEMO EXAMPLES / USE CASES. PERHAPS IT SHOULD BE DELETED FOR FUTURE VERSIONS]
* Applications examples.
This project could be used as starting demo with White-Rabbit technology. Between others, example applications are:
Both elements are described in the software manual of the WR-NIC project and it is out of the scope of current document to describe their functionalities. Please read that document in order to have a global understanding of the NIC project.
* Simple transmission of PPS from the master to the slave, with nothing hooked to the external inputs of the boards.
* The master is free-running. The master host reads system time and schedules a pulse output on the next second. Then it gets an interrupt and from then on it schedules a pulse on each second.
* The slave host does the same. Looking at the outputs on a scope we should see them perfectly aligned.
Finally, as working examples, current release already provide the following applications:
* Transmitting an external frequency in the 100 Hz range.
* The user supplies a ~100Hz square wave on one of the inputs of the master card. The master host reads the time value of the rising edge of the external pulse upon IRQ. Then it adds a constant time (something like 1 ms) and sends a frame with that value to the slave.
* The slave schedules a pulse to be produced at that time. On the scope we should see a constant time offset between the two pulses.
* Simple transmission of timing information from the master to the slave, with nothing hooked to the external inputs of the boards.
* The master host could be configured as grandmasters (if external PPS and 10 MHz signal is available from GPS or Cesium clock) or just work as simple master (free-running).
* The slave host schedule a pulse output each second. Looking at the outputs on a scope we should see them perfectly aligned.
* Network latency measurements. This is interesting if we connect a switch between the SPEC cards. By using the timestamps on Ethernet frames we could get the measurement of the network latency, verify it it is constant or how traffic affect this parameter.
* Many other options are possible. For instance, the measurement of the DIO card latency (we know when we generate a pulse and we could measure when it is received). Please fell free to propose new experiments!
Many other options are possible. For instance, we could transmit an external frequency and schedule a similar output with a fixed delay on both nodes. We should be able to see a constant time offset between the two pulses on the scope. New examples will be added on next releases.
Troubleshooting
......@@ -160,5 +166,5 @@ Please verify that the embedded LM32 processor has been loaded with the correspo
Further information will be provided.
T.B.D.
#!/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
-- 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.
-- Author: Javier Díaz (jdiaz@atc.ugr.es)
-- Date: 9 July 2012
......@@ -43,8 +43,8 @@ entity immed_pulse_counter is
clk_i : in std_logic;
rst_n_i : in std_logic; -- asynchronous system reset
pulse_start_i : in std_logic; -- strobe for pulse generation
pulse_length_i : in std_logic_vector(pulse_length_width-1 downto 0);
pulse_start_i : in std_logic; -- asynchronous strobe for pulse generation
pulse_length_i : in std_logic_vector(pulse_length_width-1 downto 0); -- asynchronous signal
pulse_output_o : out std_logic
);
......@@ -60,11 +60,35 @@ architecture rtl of immed_pulse_counter is
type counter_state is (WAIT_ST, COUNTING);
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
constant zeros : std_logic_vector(pulse_length_width-1 downto 0) := (others=>'0');
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)
begin
if (rst_n_i='0') then
......@@ -73,7 +97,7 @@ begin -- architecture rtl
elsif rising_edge(clk_i) then
case state is
when WAIT_ST =>
if pulse_start_i='1' and pulse_length_i/=zeros then
if pulse_start_d3='1' and nozerolength then
state <=COUNTING;
counter <=unsigned(pulse_length_i)-1;
else
......@@ -92,6 +116,7 @@ begin -- architecture rtl
end if;
end process;
output_process:process(counter, state)
begin
if (rst_n_i='0') then
......
......@@ -96,8 +96,9 @@ architecture rtl of pulse_gen_pl is
signal trig_valid_ref_p1 : std_logic;
-- Aux
constant zeros : std_logic_vector(27 downto 0) := (others=>'0');
signal counter : unsigned (27 downto 0);
constant zeros : std_logic_vector(27 downto 0) := (others=>'0');
signal counter : unsigned (27 downto 0);
signal nozerolength : boolean;
begin -- architecture rtl
......@@ -176,6 +177,7 @@ begin -- architecture rtl
trig_utc_ref <= trig_utc;
trig_cycles_ref <= trig_cycles;
pulse_length_ref <= pulse_length;
nozerolength<=pulse_length /= zeros;
end if;
end if;
end process trig_regs_ref;
......@@ -210,7 +212,7 @@ begin -- architecture rtl
elsif clk_ref_i'event and clk_ref_i='1' then
if tm_time_valid_i ='0' then
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';
counter <=unsigned(pulse_length_ref)-1;
elsif counter/=0 then
......
......@@ -178,8 +178,7 @@ U_WRAPPER_DIO : xwrsw_dio
wb_ack_o <= wb_out.ack;
wb_stall_o <= wb_out.stall;
wb_irq_o <= wb_out.int;
-----------------------------------------------------------------------------------
end rtl;
......
-- -*- 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 {
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";
hdl_entity="wrsw_dio_wb";
......
......@@ -3,7 +3,7 @@
---------------------------------------------------------------------------------------
-- File : wrsw_dio_wb.vhd
-- 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
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wrsw_dio.wb
......
......@@ -30,8 +30,8 @@
-- 0x000: DIO-ONEWIRE
-- 0x100: DIO-I2C
-- 0x200: DIO-GPIO
-- 0x300: DIO-REGISTERS
-- WARNING: only pipelined mode is supported (Intercon is pipelined only) - T.W.
-- 0x300: DIO-TIMING REGISTERS
-- 0x400: SDB-BRIDGE --> MAGIC NUMBER
library ieee;
use ieee.std_logic_1164.all;
......@@ -390,6 +390,9 @@ architecture rtl of xwrsw_dio is
signal slave_bypass_i : t_wishbone_slave_in;
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
signal dio_pulse : std_logic_vector(4 downto 0);
signal dio_pulse_prog : std_logic_vector(4 downto 0);
......@@ -467,7 +470,7 @@ begin
------------------------------------------------------------------------------
U_ONEWIRE : xwb_onewire_master
generic map (
g_interface_mode => PIPELINED,
g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity,
g_num_ports => 1)
port map (
......@@ -485,9 +488,13 @@ begin
------------------------------------------------------------------------------
-- 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
generic map (
g_interface_mode => PIPELINED,
g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity
)
......@@ -517,7 +524,7 @@ begin
------------------------------------------------------------------------------
U_GPIO : xwb_gpio_port
generic map (
g_interface_mode => PIPELINED,
g_interface_mode => g_interface_mode,
g_address_granularity => g_address_granularity,
g_num_pins => 32,
g_with_builtin_tristates => false)
......@@ -561,14 +568,14 @@ begin
slave_bypass_i.adr <= slave_i.adr;
slave_bypass_i.sel <= slave_i.sel;
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.stall <= slave_bypass_o.stall;
slave_o.int <= wb_dio_irq;
slave_o.dat <= slave_bypass_o.dat;
--slave_o.err <= slave_bypass_o.err;
--slave_o.rty <= slave_bypass_o.rty;
slave_o.err <= slave_bypass_o.err;
slave_o.rty <= slave_bypass_o.rty;
immediate_output_with_pulse_length: for i in 0 to 4 generate
immediate_output_component: immed_pulse_counter
......@@ -598,23 +605,45 @@ begin
gpio_in(29) <= dio_clk_i;
dio_sdn_ck_n_o <= gpio_out(30);
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_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
port map(
rst_n_i => rst_n_i,
clk_sys_i => clk_sys_i,
wb_adr_i => cbar_master_out(3).adr(7 downto 2), -- only word acesses are available
wb_dat_i => cbar_master_out(3).dat,
wb_dat_o => cbar_master_in(3).dat,
wb_cyc_i => cbar_master_out(3).cyc,
wb_sel_i => cbar_master_out(3).sel,
wb_stb_i => cbar_master_out(3).stb,
wb_we_i => cbar_master_out(3).we,
wb_ack_o => cbar_master_in(3).ack,
wb_stall_o => cbar_master_in(3).stall,
wb_adr_i => wb_dio_slave_in.adr(5 downto 0),
wb_dat_i => wb_dio_slave_in.dat,
wb_dat_o => wb_dio_slave_out.dat,
wb_cyc_i => wb_dio_slave_in.cyc,
wb_sel_i => wb_dio_slave_in.sel,
wb_stb_i => wb_dio_slave_in.stb,
wb_we_i => wb_dio_slave_in.we,
wb_ack_o => wb_dio_slave_out.ack,
wb_stall_o => wb_dio_slave_out.stall,
-- Crossbar could not propagate interrupt lines of several slaves => signal bypass
wb_int_o => wb_dio_irq,
clk_asyn_i => clk_ref_i,
......@@ -735,12 +764,17 @@ begin
-----------------------------------------------------------------------------------
------ signals for debugging
-----------------------------------------------------------------------------------
-- TRIG0 <= tag_utc(0)(31 downto 0);
-- TRIG1(27 downto 0) <= tag_cycles(0)(27 downto 0);
-- TRIG1(0) <= cbar_master_in(3).int;
-- TRIG2 <= tm_utc(31 downto 0);
-- TRIG3(2 downto 0) <= dio_in_i(0) & dio_out(0) & dio_pulse_immed(0);
--TRIG3(4 downto 0) <= dio_tsf_wr_req(0) & tag_valid_p1(0) & gpio_out(1) & dio_in_i(0) & dio_out(0);
TRIG0(21 downto 0 ) <= tag_seconds(0)(21 downto 0);
TRIG0(22) <= irq_nempty(0);
TRIG0(23) <= tm_time_valid_i;
TRIG0(31 downto 24) <= pulse_length(0)(7 downto 0);
TRIG1(27 downto 0) <= tag_cycles(0)(27 downto 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) <=
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
......
......@@ -3,7 +3,7 @@
---------------------------------------------------------------------------------------
-- File : nic_wbgen2_pkg.vhd
-- Author : auto-generated by wbgen2 from wr_nic.wb
-- Created : Thu Jan 12 17:37:53 2012
-- Created : Fri Jul 27 17:22:06 2012
-- Standard : VHDL'87
---------------------------------------------------------------------------------------
-- THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wr_nic.wb
......@@ -67,6 +67,7 @@ package nic_wbgen2_pkg is
);
function "or" (left, right: t_nic_in_registers) return t_nic_in_registers;
function f_x_to_zero (x:std_logic) return std_logic;
function f_x_to_zero (x:std_logic_vector) return std_logic_vector;
end package;
package body nic_wbgen2_pkg is
......@@ -78,15 +79,27 @@ else
return x;
end if;
end function;
function f_x_to_zero (x:std_logic_vector) return std_logic_vector is
variable tmp: std_logic_vector(x'length-1 downto 0);
begin
for i in 0 to x'length-1 loop
if(x(i) = 'X' or x(i) = 'U') then
tmp(i):= '0';
else
tmp(i):=x(i);
end if;
end loop;
return tmp;
end function;
function "or" (left, right: t_nic_in_registers) return t_nic_in_registers is
variable tmp: t_nic_in_registers;
begin
tmp.sr_bna_i := left.sr_bna_i or right.sr_bna_i;
tmp.sr_rec_i := left.sr_rec_i or right.sr_rec_i;
tmp.sr_tx_done_i := left.sr_tx_done_i or right.sr_tx_done_i;
tmp.sr_tx_error_i := left.sr_tx_error_i or right.sr_tx_error_i;
tmp.sr_cur_tx_desc_i := left.sr_cur_tx_desc_i or right.sr_cur_tx_desc_i;
tmp.sr_cur_rx_desc_i := left.sr_cur_rx_desc_i or right.sr_cur_rx_desc_i;
tmp.sr_bna_i := f_x_to_zero(left.sr_bna_i) or f_x_to_zero(right.sr_bna_i);
tmp.sr_rec_i := f_x_to_zero(left.sr_rec_i) or f_x_to_zero(right.sr_rec_i);
tmp.sr_tx_done_i := f_x_to_zero(left.sr_tx_done_i) or f_x_to_zero(right.sr_tx_done_i);
tmp.sr_tx_error_i := f_x_to_zero(left.sr_tx_error_i) or f_x_to_zero(right.sr_tx_error_i);
tmp.sr_cur_tx_desc_i := f_x_to_zero(left.sr_cur_tx_desc_i) or f_x_to_zero(right.sr_cur_tx_desc_i);
tmp.sr_cur_rx_desc_i := f_x_to_zero(left.sr_cur_rx_desc_i) or f_x_to_zero(right.sr_cur_rx_desc_i);
return tmp;
end function;
end package body;
This diff is collapsed.
......@@ -127,16 +127,17 @@ architecture rtl of xwrsw_nic is
component nic_wishbone_slave
port (
rst_n_i : in std_logic;
wb_clk_i : in std_logic;
wb_addr_i : in std_logic_vector(6 downto 0);
wb_data_i : in std_logic_vector(31 downto 0);
wb_data_o : out std_logic_vector(31 downto 0);
clk_sys_i : in std_logic;
wb_adr_i : in std_logic_vector(6 downto 0);
wb_dat_i : in std_logic_vector(31 downto 0);
wb_dat_o : out std_logic_vector(31 downto 0);
wb_cyc_i : in std_logic;
wb_sel_i : in std_logic_vector(3 downto 0);
wb_stb_i : in std_logic;
wb_we_i : in std_logic;
wb_ack_o : out std_logic;
wb_irq_o : out std_logic;
wb_stall_o : out std_logic;
wb_int_o : out std_logic;
irq_rcomp_i : in std_logic;
irq_rcomp_ack_o : out std_logic;
irq_tcomp_i : in std_logic;
......@@ -267,7 +268,7 @@ begin -- rtl
U_Adapter : wb_slave_adapter
generic map (
g_master_use_struct => true,
g_master_mode => CLASSIC,
g_master_mode => PIPELINED,
g_master_granularity => WORD,
g_slave_use_struct => true,
g_slave_mode => g_interface_mode,
......@@ -287,19 +288,21 @@ begin -- rtl
regs_towb <= regs_towb_tx or regs_towb_rx or regs_towb_main;
-- SUPPORTING PIPELINE WBGEN2 SLAVES
U_WB_SLAVE : nic_wishbone_slave
port map (
rst_n_i => rst_n_i,
wb_clk_i => clk_sys_i,
wb_addr_i => wb_in.adr(6 downto 0),
wb_data_i => wb_in.dat,
wb_data_o => wb_rdata_slave,
clk_sys_i => clk_sys_i,
wb_adr_i => wb_in.adr(6 downto 0),
wb_dat_i => wb_in.dat,
wb_dat_o => wb_rdata_slave,
wb_cyc_i => wb_cyc_slave,
wb_sel_i => wb_in.sel,
wb_stb_i => wb_in.stb,
wb_we_i => wb_in.we,
wb_ack_o => wb_ack_slave,
wb_irq_o => wb_out.int,
wb_stall_o=> wb_out.stall,
wb_int_o => wb_out.int,
regs_o => regs_fromwb,
......
#!/bin/bash
mkdir -p doc
wbgen2 -D ./doc/txtsu.htm -V wrsw_txtsu_wb.vhd --cstyle defines --lang vhdl -K ../../sim/tx_tstsu_regs.vh wrsw_txtsu.wb
This diff is collapsed.
......@@ -81,16 +81,17 @@ architecture syn of xwrsw_tx_tsu is
component wrsw_txtsu_wb
port (
rst_n_i : in std_logic;
wb_clk_i : in std_logic;
wb_addr_i : in std_logic_vector(2 downto 0);
wb_data_i : in std_logic_vector(31 downto 0);
wb_data_o : out std_logic_vector(31 downto 0);
clk_sys_i : in std_logic;
wb_adr_i : in std_logic_vector(2 downto 0);
wb_dat_i : in std_logic_vector(31 downto 0);
wb_dat_o : out std_logic_vector(31 downto 0);
wb_cyc_i : in std_logic;
wb_sel_i : in std_logic_vector(3 downto 0);
wb_stb_i : in std_logic;
wb_we_i : in std_logic;
wb_ack_o : out std_logic;
wb_irq_o : out std_logic;
wb_stall_o : out std_logic;
wb_int_o : out std_logic;
txtsu_tsf_wr_req_i : in std_logic;
txtsu_tsf_wr_full_o : out std_logic;
txtsu_tsf_wr_empty_o : out std_logic;
......@@ -129,7 +130,7 @@ begin -- syn
U_Adapter : wb_slave_adapter
generic map (
g_master_use_struct => true,
g_master_mode => CLASSIC,
g_master_mode => PIPELINED,
g_master_granularity => WORD,
g_slave_use_struct => true,
g_slave_mode => g_interface_mode,
......@@ -198,16 +199,17 @@ begin -- syn
U_WB_SLAVE : wrsw_txtsu_wb
port map (
rst_n_i => rst_n_i,
wb_clk_i => clk_sys_i,
wb_addr_i => wb_in.adr(2 downto 0),
wb_data_i => wb_in.dat,
wb_data_o => wb_out.dat,
clk_sys_i => clk_sys_i,
wb_adr_i => wb_in.adr(2 downto 0),
wb_dat_i => wb_in.dat,
wb_dat_o => wb_out.dat,
wb_cyc_i => wb_in.cyc,
wb_sel_i => wb_in.sel,
wb_stb_i => wb_in.stb,
wb_we_i => wb_in.we,
wb_ack_o => wb_out.ack,
wb_irq_o => wb_out.int,
wb_stall_o => wb_out.stall,
wb_int_o => wb_out.int,
txtsu_tsf_wr_req_i => txtsu_tsf_wr_req,
txtsu_tsf_wr_full_o => txtsu_tsf_wr_full,
txtsu_tsf_wr_empty_o => txtsu_tsf_wr_empty,
......
......@@ -6,10 +6,10 @@ fetchto = "../../ip_cores"
syn_device = "xc6slx45t"
syn_grade = "-3"
syn_package = "fgg484"
syn_top = "wr_nic_top"
syn_top = "wr_nic_sdb_top"
syn_project = "wr_nic.xise"
modules = { "local" :
[ "../../top/spec",
"../../platform/xilinx/chipscope" ]
"../../platform/xilinx/chipscope" ]
}
......@@ -2,7 +2,7 @@ action = "simulation"
fetchto = "../../ip_cores"
vlog_opt="+incdir+../../sim +incdir+gn4124_bfm"
files = [ "main.sv" ]
files = [ "main.sv", "../../ip_cores/wr-cores/platform/xilinx/wr_xilinx_pkg.vhd" ]
modules = { "local" : [ "../..", "../../top/spec", "./gn4124_bfm"] }
files = ["mem_model.vhd", "textutil.vhd", "gn412x_bfm.vhd", "util.vhd"]
files = ["mem_model.vhd", "textutil.vhd", "gn412x_bfm.vhd", "util.vhd", "gn4124_bfm.svh"]
......@@ -11,8 +11,9 @@ module main;
wire clk_sys;
wire rst_n;
wire clk_sys_dly;
wire time_valid;
//wire clk_sys_dly;
reg [39:0] tm_seconds=1;
reg [27:0] tm_cycles=0;
IWishboneMaster WB (
.clk_i(clk_sys),
......@@ -27,50 +28,61 @@ module main;
.rst_n_o(rst_n));
assign #10 clk_sys_dly = clk_sys;
assign #1 time_valid =1'b1;
//assign #10 clk_sys_dly = clk_sys;
//assign #10ns time_valid =1'b1;
wrsw_dio
#(
.g_interface_mode(PIPELINED),
.g_address_granularity(BYTE))
.g_address_granularity(WORD))
DUT(
.clk_sys_i (clk_sys),
.clk_ref_i (clk_ref),
.rst_n_i (rst_n),
.tm_time_valid_i(time_valid),
.wb_cyc_i (WB.master.cyc),
.wb_stb_i (WB.master.stb),
.wb_we_i (WB.master.we),
.wb_sel_i (4'b1111),
.wb_adr_i (WB.master.adr[31:0]),
.wb_dat_i (WB.master.dat_o),
.wb_dat_o (WB.master.dat_i),
.wb_ack_o (WB.master.ack),
.wb_stall_o(WB.master.stall)
.tm_time_valid_i(1'b1),
.tm_seconds_i(tm_seconds),
.tm_cycles_i(tm_cycles),
.wb_adr_i (WB.master.adr[31:0]),
.wb_dat_i (WB.master.dat_o),
.wb_dat_o (WB.master.dat_i),
.wb_sel_i (4'b1111),
.wb_we_i (WB.master.we),
.wb_cyc_i (WB.master.cyc),
.wb_stb_i (WB.master.stb),
.wb_ack_o (WB.master.ack),
.wb_stall_o (WB.master.stall)
);
always @(posedge clk_ref) begin
tm_cycles++;
if (tm_cycles==0)
tm_seconds++;
end;
initial begin
CWishboneAccessor acc;
uint64_t data;
@(posedge rst_n);
repeat(3) @(posedge clk_sys);
#1us;
acc = WB.get_accessor();
#1us;
acc = WB.get_accessor();
acc.set_mode(PIPELINED);
#1us;
acc.write(32'h00000000, 'h11111111);
#1us;
acc.write(32'h00000000, 'hdeadbeef);
//acc.write(32'h00008000, 'hdeadbeef);
#40ns
acc.read (32'h00000000, data);
//acc.write(32'h00008000, 'hdeadbeef);
//#1us;
acc.write(32'h00000004, 'hcafebabe);
//acc.write(32'h00000004, 'hcafebabe);
//acc.write(32'h00008004, 'hcafebabe);
/* acc.read(32'h00000000, data);
......
......@@ -3,7 +3,7 @@ quietly WaveActivateNextPane {} 0
add wave -noupdate /main/DUT/clk_sys_i
add wave -noupdate /main/DUT/clk_ref_i
add wave -noupdate /main/DUT/rst_n_i
add wave -noupdate /main/DUT/tm_time_valid_i
add wave -divider WB
add wave -noupdate /main/DUT/wb_cyc_i
......@@ -16,6 +16,10 @@ add wave -noupdate /main/DUT/wb_dat_o
add wave -noupdate /main/DUT/wb_ack_o
add wave -noupdate /main/DUT/wb_stall_o
add wave -divider wr-core_time_input
add wave -noupdate /main/DUT/tm_time_valid_i
add wave -noupdate /main/DUT/tm_seconds_i
add wave -noupdate /main/DUT/tm_cycles_i
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {90685000000 fs} 0}
......
......@@ -54,8 +54,8 @@
-- 0x000: DIO-ONEWIRE
-- 0x100: DIO-I2C
-- 0x200: DIO-GPIO
-- 0x300: DIO-REGISTERS
-- 0x300: DIO-TIMING REGISTERS
-- 0x00063000: SDB-BRIDGE --> MAGIC NUMBER
library IEEE;
use IEEE.STD_LOGIC_1164.all;
......@@ -378,29 +378,29 @@ architecture rtl of wr_nic_sdb_top is
slave_o : out t_wishbone_slave_out
);
end component; --DIO core
--
-- -- DEBUG STUFF
-- component chipscope_ila
-- port (
-- CONTROL : inout std_logic_vector(35 downto 0);
-- CLK : in std_logic;
-- TRIG0 : in std_logic_vector(31 downto 0);
-- TRIG1 : in std_logic_vector(31 downto 0);
-- TRIG2 : in std_logic_vector(31 downto 0);
-- TRIG3 : in std_logic_vector(31 downto 0));
-- end component;
--
-- signal CONTROL : std_logic_vector(35 downto 0);
-- signal CLK : std_logic;
-- signal TRIG0 : std_logic_vector(31 downto 0);
-- signal TRIG1 : std_logic_vector(31 downto 0);
-- signal TRIG2 : std_logic_vector(31 downto 0);
-- signal TRIG3 : std_logic_vector(31 downto 0);
--
-- component chipscope_icon
-- port (
-- CONTROL0 : inout std_logic_vector (35 downto 0));
-- end component;
component chipscope_ila
port (
CONTROL : inout std_logic_vector(35 downto 0);
CLK : in std_logic;
TRIG0 : in std_logic_vector(31 downto 0);
TRIG1 : in std_logic_vector(31 downto 0);
TRIG2 : in std_logic_vector(31 downto 0);
TRIG3 : in std_logic_vector(31 downto 0));
end component;
signal CONTROL : std_logic_vector(35 downto 0);
signal CLK : std_logic;
signal TRIG0 : std_logic_vector(31 downto 0);
signal TRIG1 : std_logic_vector(31 downto 0);
signal TRIG2 : std_logic_vector(31 downto 0);
signal TRIG3 : std_logic_vector(31 downto 0);
component chipscope_icon
port (
CONTROL0 : inout std_logic_vector (35 downto 0));
end component;
------------------------------------------------------------------------------
-- Constants declaration
......@@ -696,6 +696,7 @@ begin
master_o => cbar_master_o
);
------------------------------------------------------------------------------
-- Gennun Core
......@@ -819,7 +820,7 @@ begin
g_with_external_clock_input => true,
g_aux_clks => 1,
g_ep_rxbuf_size => 1024,
g_dpram_initf => "",
g_dpram_initf => "../../../wrpc-sw/wrc.ram", -- Path to the lm32 file (wrc.ram) of the wrpc_sw repository
g_dpram_size => 20480,
g_interface_mode => PIPELINED,
g_address_granularity => BYTE)
......@@ -1078,15 +1079,15 @@ begin
dio_ga_o => open,
tm_time_valid_i => tm_time_valid,
tm_seconds_i => tm_seconds,
tm_seconds_i => tm_seconds,
tm_cycles_i => tm_cycles,
slave_i => cbar_master_o(4),
slave_o => cbar_master_i(4)
slave_i => cbar_master_o(4),
slave_o => cbar_master_i(4),
-- Chipscope, debugging signals
--TRIG0 => TRIG0,
--TRIG1 => TRIG1,
TRIG0 => TRIG0,
TRIG1 => TRIG1
--TRIG2 => TRIG2,
--TRIG3 => TRIG3,
);
......@@ -1118,66 +1119,52 @@ begin
);
-- .............................................
-- ............... DEBUGGING ...................
-- .............................................
-- DEBUGGING.......................
-- U_Extend_PPS : gc_extend_pulse
-- generic map (
-- g_width => 10000000)
-- chipscope_ila_1 : chipscope_ila
-- port map (
-- clk_i => clk_125m_pllref,
-- rst_n_i => local_reset_n,
-- pulse_i => pps,
-- extended_o => dio_led_top_o);
-- process(clk_sys, rst)
-- begin
-- if rising_edge(clk_sys) then
-- led_divider <= led_divider + 1;
-- end if;
-- end process;
-- dio_led_bot_o <= '0';
-- dio_out(0) <= pps;
-- dio_oe_n_o(0) <= '0';
-- dio_oe_n_o(4 downto 1) <= (others => '0');
-- CONTROL => CONTROL,
-- CLK => clk_sys,
-- TRIG0 => TRIG0,
-- TRIG1 => TRIG1,
-- TRIG2 => TRIG2,
-- TRIG3 => TRIG3);
--
-- dio_onewire_b <= '0' when owr_en(1) = '1' else 'Z';
-- owr_i(1) <= dio_onewire_b;
-- chipscope_icon_1 : chipscope_icon
-- port map (
-- CONTROL0 => CONTROL
-- );
--
-- dio_term_en_o <= (others => '0');
-- -- Genumm wb bus
-- TRIG2(18 downto 0) <= cbar_slave_i.adr (18 downto 0);
-- TRIG2(19) <= cbar_slave_i.stb;
-- --TRIG2(20) <= cbar_slave_i.dat;
-- TRIG2(21) <= cbar_slave_i.cyc;
-- TRIG2(22) <= cbar_slave_i.we;
-- TRIG2(26 downto 23) <= cbar_slave_i.sel;
-- TRIG2(27) <= cbar_slave_o.ack;
-- TRIG2(28) <= cbar_slave_o.stall;
--
-- -- Global interrupts
-- TRIG2(30 downto 29) <= GPIO(1 downto 0);
-- TRIG2(31) <= vic_irq;
--
-- -- DIO wb bus
-- TRIG3(18 downto 0) <= cbar_master_o(4).adr (18 downto 0);
-- TRIG3(19) <= cbar_master_o(4).stb;
-- --TRIG3(20) <= cbar_master_o(4).dat;
-- TRIG3(21) <= cbar_master_o(4).cyc;
-- TRIG3(22) <= cbar_master_o(4).we;
-- TRIG3(26 downto 23) <= cbar_master_o(4).sel;
-- TRIG3(27) <= cbar_master_i(4).ack;
-- TRIG3(28) <= cbar_master_i(4).stall;
--
-- dio_sdn_ck_n_o <= '1';
-- dio_sdn_n_o <= '1';
--chipscope_ila_1 : chipscope_ila
-- port map (
-- CONTROL => CONTROL,
-- CLK => clk_sys,
-- TRIG0 => TRIG0,
-- TRIG1 => TRIG1,
-- TRIG2 => TRIG2,
-- TRIG3 => TRIG3);
--chipscope_icon_1 : chipscope_icon
-- port map (
-- CONTROL0 => CONTROL
-- );
--TRIG0 <= cbar_slave_i.adr;
--TRIG1 <= cbar_slave_i.dat;
--TRIG2(0) <= cbar_slave_i.cyc;
--TRIG2(1) <= cbar_slave_i.stb;
--TRIG2(2) <= cbar_slave_i.we;
--TRIG2(6 downto 3) <= cbar_slave_i.sel;
--TRIG2(7) <= cbar_slave_o.ack;
--TRIG2(8) <= cbar_slave_o.stall;
--TRIG2(9) <= cbar_master_o(0).cyc;
--TRIG2(10) <= cbar_master_o(1).cyc;
--TRIG2(11) <= cbar_master_o(2).cyc;
--TRIG2(12) <= cbar_master_o(3).cyc;
--TRIG2(13) <= cbar_master_o(4).cyc;
--TRIG3 <= cbar_master_i(0).dat;
-- -- Peripherals interrupts
-- TRIG3(29) <= vic_slave_irq(0);
-- TRIG3(30) <= vic_slave_irq(1);
-- TRIG3(31) <= vic_slave_irq(2);
end rtl;
......
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