Skip to content

Commit

Permalink
Merge pull request #1144 from slaclab/UdpEngineWrapper
Browse files Browse the repository at this point in the history
UdpEngineWrapper.vhd & _UdpEngine.py Updates
  • Loading branch information
ruck314 authored Mar 18, 2024
2 parents af26985 + 6b65c44 commit b2bc236
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ethernet/UdpEngine/rtl/UdpEngineWrapper.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ entity UdpEngineWrapper is
-- Local Configurations
localMac : in slv(47 downto 0); -- big-Endian configuration
localIp : in slv(31 downto 0); -- big-Endian configuration
softMac : out slv(47 downto 0); -- big-Endian configuration
softIp : out slv(31 downto 0); -- big-Endian configuration
-- Remote Configurations
clientRemotePort : in Slv16Array(CLIENT_SIZE_G-1 downto 0) := (others => x"0000");
clientRemoteIp : in Slv32Array(CLIENT_SIZE_G-1 downto 0) := (others => x"00000000");
Expand Down Expand Up @@ -82,6 +84,8 @@ end UdpEngineWrapper;
architecture rtl of UdpEngineWrapper is

type RegType is record
softMac : slv(47 downto 0);
softIp : slv(31 downto 0);
broadcastIp : slv(31 downto 0);
igmpIp : Slv32Array(IGMP_GRP_SIZE-1 downto 0);
clientRemotePort : Slv16Array(CLIENT_SIZE_G-1 downto 0);
Expand All @@ -91,6 +95,8 @@ architecture rtl of UdpEngineWrapper is
end record;

constant REG_INIT_C : RegType := (
softMac => (others => '0'),
softIp => (others => '0'),
broadcastIp => (others => '0'),
igmpIp => IGMP_INIT_G,
clientRemotePort => (others => (others => '0')),
Expand Down Expand Up @@ -240,13 +246,21 @@ begin
for i in IGMP_GRP_SIZE-1 downto 0 loop
axiSlaveRegister(regCon, toSlv((4*i)+4048, 12), 0, v.igmpIp(i)); -- big-Endian configuration
end loop;
axiSlaveRegister (regCon, x"FE4", 0, v.softIp);
axiSlaveRegister (regCon, x"FE8", 0, v.softMac);
axiSlaveRegister (regCon, x"FF0", 0, v.broadcastIp);
axiSlaveRegisterR(regCon, x"FF4", 0, dhcpIp);
axiSlaveRegisterR(regCon, x"FF8", 0, localMac);

-- Closeout the transaction
axiSlaveDefault(regCon, v.axilWriteSlave, v.axilReadSlave, AXI_RESP_DECERR_C);

-- Outputs
axilWriteSlave <= r.axilWriteSlave;
axilReadSlave <= r.axilReadSlave;
softIp <= r.softIp;
softMac <= r.softMac;

-- Synchronous Reset
if (rst = '1') then
v := REG_INIT_C;
Expand All @@ -261,10 +275,6 @@ begin
-- Register the variable for next clock cycle
rin <= v;

-- Outputs
axilWriteSlave <= r.axilWriteSlave;
axilReadSlave <= r.axilReadSlave;

end process comb;

seq : process (clk) is
Expand Down
36 changes: 36 additions & 0 deletions python/surf/ethernet/udp/_UdpEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,42 @@ def __init__(
# Local Config
##############

self.add(pr.RemoteVariable(
name = 'SoftIpRaw',
description = 'software configurable IP used when softIp connected to localIp in firmware (big-Endian configuration)',
offset = 0xFE4,
bitSize = 32,
mode = 'RW',
hidden = True,
))

self.add(pr.LinkVariable(
name = 'SoftIp',
description = 'Ip (human readable string)',
mode = 'RW',
linkedGet = udp.getIpValue,
linkedSet = udp.setIpValue,
dependencies = [self.variables['SoftIpRaw']],
))

self.add(pr.RemoteVariable(
name = 'SoftMacRaw',
description = 'software configurable MAC used when softMac connected to localMac in firmware (big-Endian configuration)',
offset = 0xFE8,
bitSize = 48,
mode = 'RW',
hidden = True,
))

self.add(pr.LinkVariable(
name = 'SoftMac',
description = 'MacAddress (human readable)',
mode = 'RW',
linkedGet = udp.getMacValue,
linkedSet = udp.setMacValue,
dependencies = [self.variables['SoftMacRaw']],
))

self.add(pr.RemoteVariable(
name = 'BroadcastIpRaw',
description = 'BroadcastIp (big-Endian configuration)',
Expand Down

0 comments on commit b2bc236

Please sign in to comment.