Skip to content

Commit

Permalink
[WIP] fofb_sys_id: first production abi
Browse files Browse the repository at this point in the history
This new ABI version exposes all PRBS-related registers.

NOTE: The previous ABI (v0.1) wasn't broken.

TODO: connect RAM to prbs_bpm_pos_distort.
  • Loading branch information
guilhermerc committed Apr 27, 2023
1 parent 37d6f3d commit a4ad0fb
Show file tree
Hide file tree
Showing 8 changed files with 1,598 additions and 99 deletions.
51 changes: 32 additions & 19 deletions hdl/modules/fofb_ctrl_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use work.fofb_sys_id_pkg.all;

package fofb_ctrl_pkg is

constant c_SP_WIDTH : natural := c_FOFB_SP_WIDTH;
type t_sp_arr is array (natural range <>) of signed(c_SP_WIDTH-1 downto 0);

type t_fofb_cc_packet is record
bpm_id : unsigned(NodeW-1 downto 0);
bpm_data_x : signed((def_PacketDataXMSB - def_PacketDataXLSB) downto 0);
Expand Down Expand Up @@ -599,25 +602,35 @@ package fofb_ctrl_pkg is

component xwb_fofb_sys_id is
generic (
g_BPM_POS_INDEX_WIDTH : natural := 9;
g_MAX_NUM_BPM_POS : natural := c_MAX_NUM_P2P_BPM_POS/2;
g_INTERFACE_MODE : t_wishbone_interface_mode := CLASSIC;
g_ADDRESS_GRANULARITY : t_wishbone_address_granularity := WORD;
g_WITH_EXTRA_WB_REG : boolean := false
g_BPM_POS_INDEX_WIDTH : natural := 9;
g_MAX_NUM_BPM_POS : natural := c_MAX_NUM_P2P_BPM_POS/2;
g_CHANNELS : natural := 12;
g_INTERFACE_MODE : t_wishbone_interface_mode := CLASSIC;
g_ADDRESS_GRANULARITY : t_wishbone_address_granularity := WORD;
g_WITH_EXTRA_WB_REG : boolean := false
);
port (
clk_i : in std_logic;
rst_n_i : in std_logic;
bpm_pos_i : in signed(c_BPM_POS_WIDTH-1 downto 0);
bpm_pos_index_i : in unsigned(g_BPM_POS_INDEX_WIDTH-1 downto 0);
bpm_pos_valid_i : in std_logic;
bpm_pos_flat_clear_i : in std_logic;
bpm_pos_flat_x_o : out t_bpm_pos_arr(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_x_rcvd_o : out std_logic_vector(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_y_o : out t_bpm_pos_arr(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_y_rcvd_o : out std_logic_vector(g_MAX_NUM_BPM_POS-1 downto 0);
wb_slv_i : in t_wishbone_slave_in;
wb_slv_o : out t_wishbone_slave_out
clk_i : in std_logic;
rst_n_i : in std_logic;
bpm_pos_i : in signed(c_BPM_POS_WIDTH-1 downto 0);
bpm_pos_index_i : in unsigned(g_BPM_POS_INDEX_WIDTH-1 downto 0);
bpm_pos_valid_i : in std_logic;
bpm_pos_flat_clear_i : in std_logic;
sp_arr_i : in t_sp_arr(g_CHANNELS-1 downto 0);
sp_valid_arr_i : in std_logic_vector(g_CHANNELS-1 downto 0);
prbs_valid_i : in std_logic;
bpm_pos_flat_x_o : out t_bpm_pos_arr(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_x_rcvd_o : out std_logic_vector(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_y_o : out t_bpm_pos_arr(g_MAX_NUM_BPM_POS-1 downto 0);
bpm_pos_flat_y_rcvd_o : out std_logic_vector(g_MAX_NUM_BPM_POS-1 downto 0);
distort_bpm_pos_index_o : out unsigned(g_BPM_POS_INDEX_WIDTH-1 downto 0);
distort_bpm_pos_o : out signed(c_BPM_POS_WIDTH-1 downto 0);
distort_bpm_pos_valid_o : out std_logic;
distort_sp_arr_o : out t_sp_arr(g_CHANNELS-1 downto 0);
distort_sp_valid_arr_o : out std_logic_vector(g_CHANNELS-1 downto 0);
prbs_o : out std_logic;
wb_slv_i : in t_wishbone_slave_in;
wb_slv_o : out t_wishbone_slave_out
);
end component;

Expand Down Expand Up @@ -715,7 +728,7 @@ package fofb_ctrl_pkg is
-- FOFB system identification
constant c_xwb_fofb_sys_id_regs_sdb : t_sdb_device := (
abi_class => x"0000", -- undocumented device
abi_ver_major => x"00",
abi_ver_major => x"01",
abi_ver_minor => x"00",
wbd_endian => c_sdb_endian_big,
wbd_width => x"4", -- 32-bit port granularity (0100)
Expand All @@ -726,7 +739,7 @@ package fofb_ctrl_pkg is
vendor_id => x"1000000000001215", -- LNLS
device_id => x"4b2f4872", -- Last 8 chars of "FOFB_SYS_ID_REGS" md5sum
version => x"00000001",
date => x"20230404",
date => x"20230427",
name => "FOFB_SYS_ID_REGS ")));

end fofb_ctrl_pkg;
Expand Down
150 changes: 150 additions & 0 deletions hdl/modules/fofb_sys_id/cheby/wb_fofb_sys_id_regs.cheby
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,153 @@ memory-map:
[base_bpm_id, base_bpm_id + max_num_cte) -> BPM x positions; and
[base_bpm_id + 256, base_bpm_id + 256 + max_num_cte) -> BPM y
positions. The valid range of this register is [0, 255].
- block:
name: prbs
description: Interface to PRBS-related regs
address: next
children:
- reg:
name: ctl
width: 32
access: rw
address: next
description: |
General PRBS control register
children:
- field:
name: rst
x-hdl:
type: autoclear
range: 0
description: |
Resets PRBS

write 0: no effect
write 1: resets PRBS (this bit autoclears)
- reg:
name: step_duration
width: 16
access: rw
address: next
description: |
Duration of each PRBS step in FOFB cycles (max: 0x03FF)

write 0x0000: new PRBS iteration at each FOFB cycle
write 0x0001: new PRBS iteration at each 2 FOFB cycles
...
write 0x03FF: new PRBS iteration at each 1024 FOFB cycles
- reg:
name: lfsr_length
width: 8
access: rw
address: next
description: |
Length of internal LFSR (max: 0x1E)
Together with step_duration, defines the duration of PRBS,
which is given by [2^(lfsr_length + 2) - 1]*(step_duration + 1)

write 0x00: set LFSR length to 2
write 0x01: set LFSR length to 3
...
write 0x1E: set LFSR length to 32
- block:
name: bpm_pos_distort
description: Interface to prbs_bpm_pos_distort regs
address: next
children:
- reg:
name: ctl
width: 32
access: rw
address: next
description: |
PRBS-based distortion for BPM positions control register
children:
- field:
name: en_distort
range: 0
description: |
Enables/disables PRBS-based distortion on BPM
positions

write 0: distortion disabled
write 1: distortion enabled
- memory:
name: distort_ram
memsize: 2k
address: next
description: Distortion levels RAM
children:
- reg:
name: levels
width: 32
access: rw
description: |
Two S16FP0-bit distortion levels, one for each PRBS
value.

15 - 0: distortion level for PRBS value 0
31 - 16: distortion level for PRBS value 1
children:
- field:
name: level_0
range: 15-0
description: |
Distortion level for PRBS value 0 in
nanometers
- field:
name: level_1
range: 31-16
description: |
Distortion level for PRBS value 1 in
nanometers
- block:
name: sp_distort
description: Interface to prbs_sp_distort regs
address: next
children:
- reg:
name: ctl
width: 32
access: rw
address: next
description: |
PRBS-based distortion for setpoints control register
children:
- field:
name: en_distort
range: 0
description: |
Enables/disables PRBS-based distortion on setpoints

write 0: distortion disabled
write 1: distortion enabled
- repeat:
name: ch
count: 12
description: |
Distortion levels registers (one for each channel)
children:
- reg:
name: levels
width: 32
access: rw
description: |
Two S16FP0-bit distortion levels, one for each PRBS
value.

15 - 0: distortion level for PRBS value 0
31 - 16: distortion level for PRBS value 1
children:
- field:
name: level_0
range: 15-0
description: |
Distortion level for PRBS value 0 in
nanometers
- field:
name: level_1
range: 31-16
description: |
Distortion level for PRBS value 1 in
nanometers
Loading

0 comments on commit a4ad0fb

Please sign in to comment.