// =============================================================================
// Generated by efx_ipmgr
// Version: 2025.2.288.2.10
// IP Version: 7.1
// =============================================================================

////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013-2025 Efinix Inc. All rights reserved.              
//
// This   document  contains  proprietary information  which   is        
// protected by  copyright. All rights  are reserved.  This notice       
// refers to original work by Efinix, Inc. which may be derivitive       
// of other work distributed under license of the authors.  In the       
// case of derivative work, nothing in this notice overrides the         
// original author's license agreement.  Where applicable, the           
// original license agreement is included in it's original               
// unmodified form immediately below this header.                        
//                                                                       
// WARRANTY DISCLAIMER.                                                  
//     THE  DESIGN, CODE, OR INFORMATION ARE PROVIDED “AS IS” AND        
//     EFINIX MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH               
//     RESPECT THERETO, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES,  
//     INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF          
//     MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR    
//     PURPOSE.  SOME STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED       
//     WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE.           
//                                                                       
// LIMITATION OF LIABILITY.                                              
//     NOTWITHSTANDING ANYTHING TO THE CONTRARY, EXCEPT FOR BODILY       
//     INJURY, EFINIX SHALL NOT BE LIABLE WITH RESPECT TO ANY SUBJECT    
//     MATTER OF THIS AGREEMENT UNDER TORT, CONTRACT, STRICT LIABILITY   
//     OR ANY OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY INDIRECT,      
//     SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES OF ANY    
//     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF      
//     GOODWILL, DATA OR PROFIT, WORK STOPPAGE, OR COMPUTER FAILURE OR   
//     MALFUNCTION, OR IN ANY EVENT (II) FOR ANY AMOUNT IN EXCESS, IN    
//     THE AGGREGATE, OF THE FEE PAID BY LICENSEE TO EFINIX HEREUNDER    
//     (OR, IF THE FEE HAS BEEN WAIVED, $100), EVEN IF EFINIX SHALL HAVE 
//     BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO 
//     NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR            
//     CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT   
//     APPLY TO LICENSEE.                                                
//
////////////////////////////////////////////////////////////////////////////////

`define IP_UUID _4c19f37180ff465ca20760e199a0613f
`define IP_NAME_CONCAT(a,b) a``b
`define IP_MODULE_NAME(name) `IP_NAME_CONCAT(name,`IP_UUID)
module gTSE
(
    input mac_reset,
    input proto_reset,
    output rx_mac_aclk,
    input tx_mac_aclk,
    output [2:0] eth_speed,
    input rx_axis_clk,
    output rx_axis_mac_tuser,
    output rx_axis_mac_tlast,
    output rx_axis_mac_tvalid,
    input rx_axis_mac_tready,
    input tx_axis_clk,
    input tx_axis_mac_tvalid,
    input tx_axis_mac_tlast,
    input tx_axis_mac_tuser,
    output tx_axis_mac_tready,
    output [3:0] rgmii_txd_HI,
    output [3:0] rgmii_txd_LO,
    output rgmii_tx_ctl_HI,
    output rgmii_tx_ctl_LO,
    output rgmii_txc_HI,
    output rgmii_txc_LO,
    input [3:0] rgmii_rxd_HI,
    input [3:0] rgmii_rxd_LO,
    input rgmii_rx_ctl_HI,
    input rgmii_rx_ctl_LO,
    input rgmii_rxc,
    input s_axi_aclk,
    output [7:0] rx_axis_mac_tdata,
    input [7:0] tx_axis_mac_tdata,
    input [0:0] tx_axis_mac_tstrb,
    output [0:0] rx_axis_mac_tstrb,
    output MdoEn,
    output Mdo,
    input Mdi,
    output Mdc,
    input [9:0] s_axi_araddr,
    output s_axi_arready,
    input s_axi_arvalid,
    input [9:0] s_axi_awaddr,
    output s_axi_awready,
    input s_axi_awvalid,
    input s_axi_bready,
    output [1:0] s_axi_bresp,
    output s_axi_bvalid,
    output [31:0] s_axi_rdata,
    input s_axi_rready,
    output [1:0] s_axi_rresp,
    output s_axi_rvalid,
    input [31:0] s_axi_wdata,
    output s_axi_wready,
    input s_axi_wvalid
);
`IP_MODULE_NAME(efx_mac1gbe)
#(
    .VERSION (16),
    .TXFIFO_EN (1'b1),
    .RXFIFO_EN (1'b1),
    .TXFIFO_DTH (4096),
    .RXFIFO_DTH (4096),
    .PHY_INTF_MODE (0),
    .AXIS_DW (8),
    .RGMII_RXC_EDGE (1'b1),
    .RGMII_TXC_DLY (1'b1),
    .INTER_PACKET_GAP (6'd12),
    .MTU_FRAME_LENGTH (16'd1518),
    .MAC_SOURCE_ADDRESS (48'd0),
    .ENABLE_BROADCAST_FILTERING (1'b1),
    .LOOPBACK_EN (1'b1),
    .APBIF (1'b0),
    .FAMILY ("TITANIUM")
)
u_efx_mac1gbe
(
    .mac_reset ( mac_reset ),
    .proto_reset ( proto_reset ),
    .rx_mac_aclk ( rx_mac_aclk ),
    .tx_mac_aclk ( tx_mac_aclk ),
    .eth_speed ( eth_speed ),
    .rx_axis_clk ( rx_axis_clk ),
    .rx_axis_mac_tuser ( rx_axis_mac_tuser ),
    .rx_axis_mac_tlast ( rx_axis_mac_tlast ),
    .rx_axis_mac_tvalid ( rx_axis_mac_tvalid ),
    .rx_axis_mac_tready ( rx_axis_mac_tready ),
    .tx_axis_clk ( tx_axis_clk ),
    .tx_axis_mac_tvalid ( tx_axis_mac_tvalid ),
    .tx_axis_mac_tlast ( tx_axis_mac_tlast ),
    .tx_axis_mac_tuser ( tx_axis_mac_tuser ),
    .tx_axis_mac_tready ( tx_axis_mac_tready ),
    .rgmii_txd_HI ( rgmii_txd_HI ),
    .rgmii_txd_LO ( rgmii_txd_LO ),
    .rgmii_tx_ctl_HI ( rgmii_tx_ctl_HI ),
    .rgmii_tx_ctl_LO ( rgmii_tx_ctl_LO ),
    .rgmii_txc_HI ( rgmii_txc_HI ),
    .rgmii_txc_LO ( rgmii_txc_LO ),
    .rgmii_rxd_HI ( rgmii_rxd_HI ),
    .rgmii_rxd_LO ( rgmii_rxd_LO ),
    .rgmii_rx_ctl_HI ( rgmii_rx_ctl_HI ),
    .rgmii_rx_ctl_LO ( rgmii_rx_ctl_LO ),
    .rgmii_rxc ( rgmii_rxc ),
    .s_axi_aclk ( s_axi_aclk ),
    .rx_axis_mac_tdata ( rx_axis_mac_tdata ),
    .tx_axis_mac_tdata ( tx_axis_mac_tdata ),
    .tx_axis_mac_tstrb ( tx_axis_mac_tstrb ),
    .rx_axis_mac_tstrb ( rx_axis_mac_tstrb ),
    .MdoEn ( MdoEn ),
    .Mdo ( Mdo ),
    .Mdi ( Mdi ),
    .Mdc ( Mdc ),
    .s_axi_araddr ( s_axi_araddr ),
    .s_axi_arready ( s_axi_arready ),
    .s_axi_arvalid ( s_axi_arvalid ),
    .s_axi_awaddr ( s_axi_awaddr ),
    .s_axi_awready ( s_axi_awready ),
    .s_axi_awvalid ( s_axi_awvalid ),
    .s_axi_bready ( s_axi_bready ),
    .s_axi_bresp ( s_axi_bresp ),
    .s_axi_bvalid ( s_axi_bvalid ),
    .s_axi_rdata ( s_axi_rdata ),
    .s_axi_rready ( s_axi_rready ),
    .s_axi_rresp ( s_axi_rresp ),
    .s_axi_rvalid ( s_axi_rvalid ),
    .s_axi_wdata ( s_axi_wdata ),
    .s_axi_wready ( s_axi_wready ),
    .s_axi_wvalid ( s_axi_wvalid )
);
endmodule

//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AnxLCEXIwWGNUbKODuvDDj9z3+IsvyasQalysUi/itDT2wwInQ3bBdLVigviyZBs
KfNqHVcHh1PkyYw6Tc63TbVvrM0JlKHeRk9d4Ni755Frdl+e0Yeh82+Cu7JAI77V
toSbtXAPtD6vOVPzzed5ozvhLM0NSdRFehAG9pksl3iYjKFZP6TayMWce09NBstN
j+KnL6lB7cNlu0ejMJXS7VgJ8dx8NGBDtFHQEZ5XfZo3IKXu2RTPmQkW3pU8QhlH
F8qGcX2EikZvcV+7xxJnVc8CjsdqEa+f2tIVEtB7gpGdCQYhsfE4ScprrVpuFhH+
2Rn6AkA5iTdD385b26iafw==
//pragma protect end_key_block
//pragma protect digest_block
45gGFciNrCTJZXxwMOIqQD36VKE=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 11895 characters]
//pragma protect end_data_block
//pragma protect digest_block
ccHJ1CIvmCRS+nbWgLQWKS78CiY=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ARIzM20qvQsOhlemikp1MkhOGVvOqdCptklMFViFENgrk/BZmZ/vFkAL+ZtNt+Rt
gKaoV3CumDZiaq6j1xjRczEEuHtJJdWTPTpDnzJNsuHqOJA15YIcT7YAiS+pDPrH
ba6+VIqZO/0yjRlkoCPVqy9LkQ/xrWMKVbYMlmy0Id69u06KGbU1p5j4cb76uOMu
4bWZZrwVWlKStkTuJxrQaxY4reE/4p1IFspfvCOMNbfhGS5T9NLNuz4Ar+fLhiG4
h0eIDLgy4gRmRu5lYBBfFDJkzEwoXKCyIu4bc2aTEbIes/iyxQmnggy0jAde8A39
TdTlABcW1iLl/z9STeHQ+Q==
//pragma protect end_key_block
//pragma protect digest_block
n10L4UZBiziO4pZGJcyPwOagmTY=
//pragma protect end_digest_block
//pragma protect data_block
ks92l8Pg0utWHydDDfUWK9bco9hKy99Ce8wQI89GnW51fDBoSkKipLRroDYR4L4Q
KMxBd6gEhA6tCEBZ5pXXPbMQVWfaTgWvgmvmgJM+Q87n4H2sIERbqjFxtVA4jsAQ
GKjqpvPoUxomiwwwnkEhSBcn4Ln/INnrnN5uwLCndauYhelZ6qq5wwVTsXZ18oiF
muvBDozzgaFd6dsWb6tMSgKGByOe2tbPQ3Ze64+pl6wB+UsLu8Nqrx1MybBEYqhd
XpM9Z2OoRtbv3goP0Q9FMC0F63Q0/M9t4ZMaR788I5ZOhgXiPyeovcj0cB6JgEV5
fufSyfhl3czHHTjcBqoqKlwcS23nyyugFwexhqMTa9oF7U2q8qancROWTSHDIBzL
IAy4xMe/+jC6iDSpG6X3Av7yKHUlT0gErKDciaW5NxJl6yoTx3Y8wF00QiOHTSjT
7IULO5VkuSn1wXa5uSOzKaRV+7uLVS70BtKW8IqacaGerzIohmYqxrtCa5A8tKSP
epAJld5IzBrNY430eue5o45udqkxEu9fcm+AYLm/w7lErz4Q5JDtoyDFBlRVJMXb
8PyqE3cavcbcj52fiqDfpO2upZkj5HXjknZV5vWg3ed8CC4ftVuMQjYJnDrkMtVL
a31AaGyx1vjrolR18SJn4AL46lDUF57Vfx5qPmX6/yczhMV0n5CvtwonTEtHdsRL
ceUWg+UakzBg9U+v9SOxF5G4q1dK08XqqeIWp3n/B8uy86/eAcsSZfMqGoiQ9t3k
qZF5bmYZU4a/brz5QmvqEPpEO9H1c6H4D0Y01gxeVhIT7kMyaUsLXoLx8Ou4Fcsz
YZ+jQGqXlXkMwjKdh/NTbPjZzkrwJF0JsBGFY12Sked5opcpjQca3MjF4WB4lGSB
PokbR4TTMd8r/YYSFm5C77f4HqTUUzvcUQIRUblxO4P6GD65frrIcK922fuEYvaz
//pragma protect end_data_block
//pragma protect digest_block
6Z3kBITlGBQ1queo/RSCimERKpE=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
Atz8tucueABxi6tE+6GDTFGVUzFguCPXX4a1GvHwgkopw6puuI6B/bguieeIeHkL
tgEqfHMU6A0PrYo8SKDzwI5DlGQY/DNWJhbkmWmo/igpJ24aMcFurAskETQkgSIw
IvhTjwwxL0DMnTN0Nn82TOAVMnrBgcDSPDk3+xiL00APePbf79ybpd7wV8gc5FE2
VkXmLpxK6HxOdbeNRXpD0EwIwh0rz9cRbRNhKklPnAhKLokzOFTALpd6HxvLxg+u
PXAhC0TBY0AfXEfxX9EkGMTXSRFuL4e/Z4hvMY2GFC92HLrzm+zpmFYIIXpSdqmm
mJ1+NJbHvwYN0VTqmYim+w==
//pragma protect end_key_block
//pragma protect digest_block
Hr63lrg3B3IJZh8a3CEdfiqq8kk=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 8710 characters]
EcH41tzIcqRMZZrUqZMgihUivPdTtXZRaKnaRozuPyo=
//pragma protect end_data_block
//pragma protect digest_block
NoNN/+HOL/6XnNdLy3d9uw2O3HQ=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AbCzhd0qNN1a3YD2COxnxD9tA4+Q8AthzDbzjUhGr06Te3TXX9nYsgo3lUXkiQvh
TCqgcIyaHSmj7N4taHx2OHQM65fqZ9Kxlkmcs4uwd5L5keLAE/xHBK+oOX+mAu0n
wi9qZnDk2POmSmxaLIinPJJLXmbOu1tKcNUqryv6jGSZqxHFGYNuIrCWEPHGhH8z
ScFwZj1MH7MLTBso3FGbgqoMfAGglrHtPPIRqQToZJ5UyrJ5OnliZvjjHUct4lAt
oxuezsQeVftgh7ARe0q/34Uw5IB+tFu0T648sWtQrbOuK2lirrsT70RyQVaFNJOB
afEEkSjZUwZJ8Gim6nx7fA==
//pragma protect end_key_block
//pragma protect digest_block
ANmuh8+Z/fi0NpDa8f8OOgJt3vE=
//pragma protect end_digest_block
//pragma protect data_block
W6sMrQihbaMdI2RPKLIUTNwA3Gc4uUMkomlzSKCIsSnwjupA8mz6SVNbXWxoov96
Wq6a1C1N/Dm3topALugkZTReuwtDwAKkfPoY/lqmvwI/ZbudZA8SPZ7O5w7UAHMe
sOgMxf79xE5rvAq4xKQnAM0VLBqegLEUtz66mw4srVKttRDNIhNDpaJ47ApsJxY0
SQs98wsAI8U9feEarxvg8T1zgq5eiO9dPIa8j8lwI9bOmA1ZkuwQZ9L1UPTfDf1A
c15Aqge5ZRwClqgCuP4LrrtlPbdba15wIXIM4SrZmkT8Ymb3H6prJJvzW+LFOfTt
7JuJ4TTuwrO0F81xm25CnwSiYvzR4UeaGwMfhjU0wBKcBOD0B4XYxUVOVpqw8CnX
w7Pf4LLrSwmUMgRCHfTe2wSRUlT8/W5lGXCCKzTIeFc7e66Tv5F0dVQoTezOretn
IdrxIs+FluvZltCHWNK7wTsCYe5ZF+E1BYE6+PPZrnsEJXa9SeeWq0cssknmR14T
miF2IVo5HoRSlCrEwRGMa+oK8DVIE0ohMX/7YORCTp3m8Hco5S8vFq26NBv/w2m/
asV+1/y7N6Suk/PnG2VEwnjlliJf0CZTkY1Cgovfm6yzc1diAXGMxKdb0HTlPcKH
U+4yv2lrROslwGbgT99x7R0pecjwY5Z8v8jUn2xowXnuH5mtNAUIsWsT63+/l2wY
hzujAJnunUhPzEpiSPMlgxcCnQnZy33MXUf1ZtkooAtEfZt98i26L7QcAjDZx0/F
hQW3sMRyKlPh04dpEHWKW+lsYwXVPVIou0TbEVwnQ1rdhJH3aq9pHXc2TVBpLjjy
zZQg6ett6jU87uoffZXg0TRVVGGMH1KprdoGZR3XRg/L30ED5H5nBQ7l4Yuf/7eS
bXYec6xDUGxLDKG87iSacHYFC4hsTd2HRDggVPwAwItZCP2hsO5nrYWIgod/3ZnY
OY0gaLqbF4/fZNKr6KQUVDTP1VP1iaiFVYLNDHZ3Jw1taicnfUkIgpuOcieXHL19
1FQi7ljYZDHDLBdg/UpR50JWsGPSXrFFCyBAZdqu+Gl+doYXRD2QWqCbrHr4YFce
v0DtSjB9EUvQXQaUfj0zBpFBnmQ3alpUu3TttlGuRRwfNtnf71DclD1tqwPVF6Ii
Y+ovFZTAl6984V5t6Q9ioZWc/Ru9tB2K+Cl5/pkSCq54UMVJnYVM+aa6P3Ssb7dx
45lGpqjNKrfQ89TN9eqo63jDAKCwGFiuPQoUxDunlJpXonbZVy/UhbdtMqIW5ESI
33D0BeXiqgHE+KCNft8aBJFM3tQ8/ZoN4MzD6ZCHOuurrxsGUz0aS1SongSJFfQX
0GBsRwhzaoEgkVqAhNEkLJHG45LSLUlklYLeD5c4KWZKSYtggqLk5g+TlK72akQV
eZe/gvQQJsNIVq0A5fQoOWXoRXmKYtBSfd9VlXxbImc+Mm6OAHDk2LsYG0qNJ6hp
hPM/c2+wML7iK0uLJX6T28Gyw4dvKYEJT2pJn/RlVlggOV4vcO4VDaRLu2VPO6DY
1ne5XtWtqEEmQo6qcjo+hNHKPaLmZeuiHLLfSi0p9BKd1E5PwRejhCDp2Tl/ohut
pGAxleOWkKh3F1p5lB5/oRievr0g3KiIskFHL2CxJvG2olL3OBmeL4x/QxELGj8N
m+1cKH3PsPsIbCPjDFFVLC6dEYQQ4bnY24/o5IBwxJDUm+gaiMRVX+JaSE54DqM4
VkEMQ8d+RTEcVlORJOYYRs7bNdH6s4bIz3rtH9cZHHRIBQAQzhe5nTtWWMr01dXw
neNWPmRn4tTkXzQYmqazhY0JBUBQyyIUNoR09Wg/kkXaKaNPCxzzpoa4c5swx3Ct
WbWpkOf8uqehUOTyZ5jnccJItbhFwhV2SnbVK5RMEn0=
//pragma protect end_data_block
//pragma protect digest_block
d1Onj9prOJmn4JcwcCCC8cvvcYw=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AsnvdlQQG2G/k9b5qztkkW7Dv+FAZiPWR6QAUQ+DxyO86/iCpkBlRR6oSVI7Og+p
9CtGpeXkbt4RrFe90nWZGjqvKgB7RxmhXppMUa7bi5yTGg6r1eOI3gAVzAd0YjMy
25rpc2ixPCo14GQPh++XOQ9s40V4LBII16ArZidT3TUwXSob65RLazB/eIV/sUNy
5eBEKR7/xyx/F+evqlp6SnUvcfFe0SuOopPUCAACMa/w2N6o2t6qUgzpnKjvfpyy
aL6wquWnMYxt1ZWghTs3ESImUnkDXkLHeOrJnpqOt4oal8yNil8aDRGPYogUCq9v
nwUaPfDpVSeVWP85S9g4tg==
//pragma protect end_key_block
//pragma protect digest_block
I+eFsI6owEDO8y+cCD4HefhLDZ4=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 11440 characters]
Jln3muh6n766T6bMjhuhm7QBJeFlziBT4B8zvPSS7ms=
//pragma protect end_data_block
//pragma protect digest_block
D7e/03/mF2BL9YuHkWwHU2Ux1m4=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
Abb/aU6vd4NK5iXNnimYoWO7UYIoJonmB0a4Z6SFd+HXx2lY6uqbs9SGpllvwPAM
Wb5IV0DhyUtyh2WTfgW93UdYA6et2F4f4KFsV1HrIgx6YyTvefxkddDkXJ2Hdt0i
DVY7dOwl8pi5G0G/iVLsg++KpwuRAqFdKMIQM5kdDn7yvb9J4fwdXXBHtykep1+4
RrEaIf+oTgqDzfalR4V1G1WlQz+6HOac8ohOpYDiASBMMrbEZBkNnw4F58YLsweu
ZFwlILhLIQ0p8ZXVNlvdC4j03Ir8B5UguySAxZby07M2EMi0wFLqi4PD493fVPKz
iiVHouTBWJlaPEyX51xzQA==
//pragma protect end_key_block
//pragma protect digest_block
pWD285A16E48GpWKY9w7PswvVQg=
//pragma protect end_digest_block
//pragma protect data_block
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
//pragma protect end_data_block
//pragma protect digest_block
q8FQ8IPkH9SC749Sk1McZpJf12E=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AuMoHPX8Pd3mqbQO1GA1lDwNRW4jVDSCCnolu3a6qpNdY5kHzBOGmD+lMc+C6ham
DMiMRT9V4xdB/+OwhRUdvnDdS8ZdNEzgQ16Gp2C+bb8C8fxGtMhNxkoUVWf587Kn
BgG/gBlTbJeO63zuzFdgGYvAyJ2VnKYt5wWMlOEkPu9ltYfcrLIG3R13kjyTD1Ci
XIHkBgGaddrqRpVONdrM+FKVtXZ57ZAqBgLbG6DP1TCMKkiChSMPG8h480WRmgKc
dQ0b22rh00a8vsr/qVARmzjRyOJSx4rgZOEhGRcQ8evgL7SOZxu3JXy3m0oErgqT
QVYOONJeCKkvOy9Jgs+EaQ==
//pragma protect end_key_block
//pragma protect digest_block
8qSCHJneLBb6XVLZi9bJi6+NcUw=
//pragma protect end_digest_block
//pragma protect data_block
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
//pragma protect end_data_block
//pragma protect digest_block
fISjrQLVTMznoejKTXLxneEH1rM=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
Alh+zpnsJ6NtMNwzGSTrfbMl+vFsUFiQe7E8ZGxfpOO4gXH+R8hi3eZ5VwT90lvV
JhwMoeTUKOhlOXbWgCgWxu2KaM6oRZagJxI/qLkZbLXOlM24Altu2z3sJT7Ymbi7
SifwsoPrd55gSeSnwTmdwAU/3m/+fyVWBK9zo5tri2VJTLDpm2DCcT+5aerLXXPg
ScpwP3go0xQ69IrJdZ9wx9Z2Qb+mbafejlACthfrI/qHqz0+KfF7JU3xnktro9EK
H7agWTVWTyfwEes3oAnLjcgrxQtygl2JcZ384L7W2ohbVxq0M6xNdZ4dc5E1Jd/8
wWwZ5PjU8hN3vfbePgjZkA==
//pragma protect end_key_block
//pragma protect digest_block
TtmbDmxdMg1zJG/PERb8Ra+Pms8=
//pragma protect end_digest_block
//pragma protect data_block
k+n69WuR4H8EJmfWtnuPsWo8FraZu4DfWYL2PY5YqjsXpkNVPDjqEZdDsG3SqNTN
2S1NZ870LhHCGvBBARLdJA1VLkqWryMAuNBirOylR5IF0321LM6vzQn3Wi9TWmfc
bFEeI3OJeikRfzPkLvH1aLGNjqWEAnQ0M4hS1oMTed7NQFZDLfd7E2MjGMUZPShr
UBv40r3fj+D8GVgPsHkbOLPmp/3nKpGql0CUOocKPoyICPDj7IGwrwNd7oeuDA7v
zQCcZm5LS0THPD2SIa2ass1gWjm7tCNlrh2k4IYRm32YFovPvXQFRgfOvgTxg6JQ
77hKZwhD2x19eRMm0+HXZxjrBXEMKB8rFJNVPC9dWtETwHUJab3lzrXCr4Fgwzgk
jFcwTSIvH0RVVw3fj/cJvUCBX6hCjRqrch6UmteqvuJ6IFGi7aekfL+T8v3Ws2iu
aCQwxfCXMtw30H3obauMB9I/w4hjSFGSCD4u5FH2F1Mqpn0uC6Kk+iRMRPCWbiTm
dxJoJvLlTTUkT1iZj/gOhjRowBboxZlGAEh2is5t9ed8icK6cJuniTKdCndoSnri
9MBhURyF1lipG+3/530Hc5udwnTKXQFlaVzeuPme6+yy3PFkD5Sx2Xjf9qjF8kDx
pwz7GB8IUaRwNK0rkoIk6Jtcx2/xrtxmzsRVkFIsd044rIKyMHdc2YV+1qAzjaVK
miG89UzKseUjt/58f6GBRjHUTbNzeMYrJvqbI++ridb1nwEPo+Yh/0GLq7ykgk5o
x3NpQqxg2FOEIT2wQKDCyJrS9SyYNcDqLSnzTxewDbm77l2WlUE+X7xKaa5RMs06
dcXJR8GLKF1fDzMdBOj/mUmJBOEtkUSWWhBL7yuGja4BgSdDzMxXvQf9UW+j6ERe
JIPco270nVyQCHrhCkINoj0OPa3rbtmMZxjN3UnloY0wXt6F+vxKcaveXUKsu20R
xzJ9Fk7NiL4xws9qG9B1dJShV9stkYdqRjRM1q4Mjx6zO4dE3IXEovLi3EZTGfH9
m/PQwWGTXz/14BXn78imWB7C5/rjP3eG3Az4YF8CkB/oYO1bmoG7JOYGT44nuhG0
hHDN0ZLDnY9cXqdENEuqvfe1SJn1yNIa2QBiIfPwWZ/mpjlMinq04ZS/QWv+F4YP
GADlxVl3fEa/D7UV9PZ733h2MGvM813eA+6dP+7nQ6izER+aqnxXVSR6108m9Fhh
Qlw5p2O5H2uzgB5FMAIflWj7J8eZKu2W28EllU+YNwvoN3mlYNmxBToH2cj1XgQp
btS2r6Xj/F0UXqGwkjO23ySxQ05FwmWPmPRe17S0vfb/tX/q7BagnZH70jjtvKtC
sfF7mVTEWER3JP0QX5QNBej4MsNBRjBd7mkxhuvV28p00rLc/I8rs84VgVPtRRRN
nLJqPgqXxWdZqA1cGh5PjX1oqI2/mfHaePtCCQ/wAXOmnkUCOu0APDCIpVtHvZkI
b9TzbKp2iL3FyLl+enDkH8LoIIBxlF3M8IiKNj2HvTjMGZFYqenhTYoSv36LdtvF
ltyEQMfmJDDgb/QEn0tc+FY2rl04em2Nq/cCjuFc0lgO0zCObt6PnIAPas7Pgfn/
2+Sk3ypPrp6C8vesKbDAUydYzSN/6veQ43B2srBEX0KyPDHX+1Zh7xxHiY1XdXQv
luUl3pbLoq8CDzpIqLs/KnLFWDqpN732dEXe0gnrx3ZPgalnL4o0y+8kUpj0XRMp
tVxHQqGwuU0K+aqMcZHWORJwolnNtwyjmmFi6HGcbq7WlMaryZxJgSVGqG2dfn/W
CRazQU8VPjZao0tcu3PWMKwVZo9lkCvv3gXksbWFoR2Ql1GTv+ZPTmw/xypk6dhG
kOeDd6N04JrlfkPnM4yh3INLmxUDLAeJepsZdYLCskwLqW0VUtpenQ6kObflHJSH
8zJZNOkiiYrYhxOATiRMxxYJR/tjenOebx7jvKJ3SZ0VwRobUsXbaB5JtVeSLR7A
GOXHVR+DRtrcevCsezaYMmA8lajykBiIvbyU5Oqw+MsmaUxGfacjBcYVtM8P5502
HWRl1s6zySX0awWWKtAG0cJ/vw/8fJyqOrTXAxPLqG0gKhjjLiAzewbmehoygDXE
mfMm24jUzVvRPm3QpQXRdhUaZdNvwYaLhX+Wm+Onbo3Aq7okNDq8zfBIsuCMN4Mw
1ZshNtS9QWHvWdJoUUEbOPo5YyU0drWX/mS8vkq8uTYfyu/fIWw+rnEfT48iv7p3
imY1H+2cuaqwEHqslEkhKv2Z3dLI1hO1YJtJFGLYpP8ddFU7CPRu5U9t0MHD1WAf
Gq22GHJFJXt1YXWxgAnZiTLKNgIB1NEtzR1JC6YOMi8Z3rQuasl5FtVGxQ7mjpWi
ZqniCdVTIFgRAU4U2C8YLbW3q1UtBXgzPDsaAYl2lfVpy0DkxyUt2MKuQXcIOsL8
BWUIHVG8ElfLBQWKzx7sly9V+O3ud0WcgnmXbt2AihDescA3xeGYtFiLLLRMv3j0
2ya3EGX2R0hDeN9THnTLBGoBvc66vCnwM/PEFJsEsUDYLHBBFRP+KWfJxVtk6nSk
GWa0XA85vqK/MohEtiDg9c6G3uHVWwk5EtN8XBnQJt7l3Wn01FPeonDnz+v4jB4A
sPAL/UUV5RC3g1v3kvjYNEB6vMoTy1/ngzvRpeO0KxeoUshPExPLcp7m8hakQP/2
ZaMZ2EfnqXVTw9RVTa0VYvY501PDLvJX9HGF/IeDpo3zgloNBBlYazbKsBPdGY+t
iumUOdyMEEWizwEslLqNp2K9GKkZpR2sukxCRUdAQwG/y3SebZVwDU0CBwnJSOmx
DXle5Z+JwkuORjN8rlC+SOowLJM3SWAb6/UlQbj77DMdbv/uCN7QnipP7khrcTKk
fa7CiQIaz60uq27MECrP8AhwO6tfecCloHvmz4L5ys5W+Y5RDQVYOd74J/Jm9pTH
97fEhrJS8s/thV8H95E26kcNUTq0mdRrpG8XN3yIzkWgmD3Nhl8LsqRCvxf2xqYM
pcam8WaqfVSaDZh4uRdj0q6no7WnGAz3J64NcGAqKJKlIA1RK03GBLH4wnS7Msy/
Xw9eQUc3V5cqL/qv4naKd80+m8GLxlvzh+NUJYzNETs6f99BaWGsoIaWX5fJzG2k
igEdeEMCOivBYJei6tsn39IvHGzU3u9me6I2/Qxnk8cwiIUrdLVnrcKSgagUSfRc
hFOgMejL1W4G2vfgvQ3E6jJ1Gw7/GpUM9BTQwgOS+xgLicT5e9qZjwyDmBtARtDu
YXy9CBo1iVhlcW4U9C67bbBLJkY87ruw4vtIpDCnnVguGP8hfD7CQIMzY/x/3BiT
noB5VtC5pCS3sc9Kw+KjrhOKirM5rgqra8zQG2uXJOpqLWJb928CrkMBmSqvpAmP
HXwztnlmJ1j24kGYS4eMQqq7H8Y2mTB9UInwMwkLgUUvJNeEFIiQoIh7DGnm0WUf
yehkk1ElESPD7idNa0WYSM14QEBhnsSIlYRDx7WLkPJdhiXR0/pPftNS1d8M8sm+
sk7FazVQEW2aJovwsGYvxEvifNXdLZOPIwTWeMMVRoewTnOmfFGup2RRdifqo3BF
B1My3eFaaTpYg8j54SPjUrbhwQH7SWpKHPUSBb7t8zUplKEKXDOBCuC4mXCC+5Qv
GwJl8wljjwbCdNHrAvQTerZYmjlLuDND3uaU8xqbqKBT0zkWlx7zMApJYisgL9a5
gvr3wqZj7IbSdZL49oLWQtawz6y9+vPchronN9xhEhgf6oo4N9CXE00eylTzdqFW
hZ4UsVFT9Qbm1/aUmSsHuRHq7NQCP8O44kdDGvCoXO4HhX0qMcRBJ1RdSdfL2GDV
DQR66hnhj5sr3fniKtsFFcXsW/wQ0McEfMPzmbaayvk869DgAGM/HhqN1lCpUdkz
//pragma protect end_data_block
//pragma protect digest_block
Dp33pnOzrjzNeFbe/SSVyHl2kAc=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ADDkpHBcv1QLYI/vnbFUVBLH/vblpSm2j60Iblf8+01HHOD98Yh22bALNGILAwKs
9gQVwKC2DPK94E95kFvX/0oIAboT2fXoRjUne3mjg9Bgg6srz/UjPaq9my7Gxlp3
mZIJKplYwCFZQ/vV7OFM4LSihaRrcdzBCKY0fkk37axv3XVjuxXw08yClc1SWhob
1iNAzAl1o5YyjeSrMGjox8D3NalxWvLqTkgGJuZ/oRxlAi+t/rk9+Nec8ZCp8IrH
6lbK/r2RCMcJ0tI9SuPpOoahoEYRf7IdN6CLyP7Hoi4pDgDXpmj98vs8cRlUhfr4
46L2gqFzbwedeQRHmEcDRA==
//pragma protect end_key_block
//pragma protect digest_block
XyTDHV4JZRt+wfV76/WwR7YhVcs=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 23010 characters]
//pragma protect end_data_block
//pragma protect digest_block
nWrq3EPDMtEXfKvYGGpSQArDy4k=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AXMNUgx+35APeT+Uh1zoekyaEw7FKPAaxxyAa6Q8Epve4926p5t6aOUqjm31poWm
YkzJXrFJDf+MY5a65f9vjXEYavFbWfqstM5gzpnVEYrCosK5VL4V5haz6/0zm4W8
3KFU071+dSKb0Ufe4/PRgxBz5L6UD2Q6qbk8pFHXdHqOsuoYxm4jLa0FBY4eoMeF
B3X4RqxbqpDnTDp4VR0rxrbeVE6WR8yH7k/V/F98ngoo+vTi+QAfgYdJqZxlP6nx
g/VBlSVclqWtZDmfhCtSKb81AWK8TVGSJG8BSZvZv/QruxskN8UKeHq3mNnFNA0i
BAQDMmBq+wwHTXv4864ICQ==
//pragma protect end_key_block
//pragma protect digest_block
9CbqG9Bv4IqyciYIBinQCrA58GE=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 26195 characters]
//pragma protect end_data_block
//pragma protect digest_block
U9YB8/0V+ciChAhgBpR+Mjh1AqA=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AdFY3ddNMI5ObsRGTGZotARFS3CJ+vRLMss+z4M2RCmeWnJYSwbOVqDZT//3v1XS
eZCzvuRSef58imif0HkcVPAPNYx88rZ5R5Wx/QsXAvOU+xzC7nw4m79rzsNreJKW
TECIEiIMrfMnM8TuBS4RJ8ixg2QUxCNyypIpEwob+xA9sLT53CWnVC7PL+RGHtbm
dMfCpH7nsJAzmsF5GPYyCnYnSLmABwHoG3M+7cd1fRbjm1u0yGMCX/Vsir61hSWL
MRns9UFy1BN9D0IV7AmqeDx1lY2NfQm/6bM2X90oIAQ4R15r3rNgs/KRoFmNhAfo
l9LZHRSmPOz3WQkMiwp+vA==
//pragma protect end_key_block
//pragma protect digest_block
LMsSFqJZAXHDtTSKQpoQfkCpEXM=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 49790 characters]
QlVOyLz3qNshjbld8wsPsg==
//pragma protect end_data_block
//pragma protect digest_block
Yac1UeXsmBvviCciB/hrnaEqr10=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AbhYTtNJq/FK+w1fFKm+6xLsSwJOb+mq9T3w8qXIOEgIUR34Njn53155UJnoKrVk
evQKf3BDVcJFLDEZFnCWmDCVW7pjhfevjP3nsAWwNYyEp75//Bba7WgJNlMzpJfT
SrvHXafsyhaZR0ZyxMM7Z2XXjvjBnjZK8vYLfi0J1br/pcztvahh/83ZQLzzfd5S
lqNwBQNiIIxS758t26qAl9x+srdZXs1gKnQgWogadySoK5ww7L7eG2yYNBXrIgnR
A6b5wT61eo+qS+69D8BjfXZ//UskIbXEXsm3bFs9DBhUZt+f8aJgupsuOVODnQly
2epty4jyyW9j/bg7csrOfA==
//pragma protect end_key_block
//pragma protect digest_block
Y5+OOUWvj9rO8MVfeQiy9t9WFcg=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 9620 characters]
//pragma protect end_data_block
//pragma protect digest_block
B3TkFI+3N0Wc2L+4rgj86RNP7kM=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ANaeKJ7tSaIxxZfCymrxd1tPx/DBPXQg9P7ADT/kL709RAii9I85IereWkupiW6X
fY7mD+I0mTNaDYB55jD6uk/Tb/bYwk98jdHLh13Oiftml/rqOBjYa5s8RCFlCzqi
zH9uP6y6Poj227jCJTzfWZJaJIsGUpHvR3s+DzzFkDJQfleeW+f4VtylG3SgJckZ
b2s8xuNsNfcm1Drn1nYh8yX3AdzGbZ2UWhHYzDdqdLGLa1v8P0CGufu5lLcq1K2G
hjyMxuyqZ+cExm67cN7Y7GUi8gv/mX2r3ESjEZrKTWk9q9qQv1DcL+WaNoBn3I3T
nxFVy3bqck4R+XXscCf5qQ==
//pragma protect end_key_block
//pragma protect digest_block
qtP42qWnCaGHeHrx5eafulg95k4=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 40950 characters]
//pragma protect end_data_block
//pragma protect digest_block
6N9u26hVMpcbyyfmRwuCf6Az/lU=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AT1EB0I/npWqScdRvpJcRO4gQZmZ32n55aokvX66dpBReWYyfJe+e8xu3FsuL0hj
xFTYzPqCsokjEbxWJcQ7AqcTcNtY92dNwmIFk+9mtQL11nDQuEcAz+9qG+DzKQE0
wEFxB1EFOwxq3BFrmHDuIOBCt4mqLXAlzSTZW5xJI34SVmPvvsg9ljtOu5ovC1fo
qrj4xbbiOv9JlswWSL87kY3/EAlJB93cTi8uIzDi7mLeylEdcn2Jw5H8S/Vwyafw
pM9YxN44/wv1Sm/j6jj5BDCKjFZ+0zxNMHtlB96vfvM2pNIgnswgk6ZCMT8kyGMR
eLKSDiJKdiLlAm3AiIYAxg==
//pragma protect end_key_block
//pragma protect digest_block
IjTle94Bs2ph1I75fY7zPvZwn7c=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 68835 characters]
knQYNzLuo/0bvSCkEVcmFb8ZOGNyNhMNm5QrNt1OEBA=
//pragma protect end_data_block
//pragma protect digest_block
oVKojFyDpw5GaFjaBy/xgPtTTkw=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ALEP0YMKgY2hG6kMs04J3ytNSCr7F/iMNJKtSVcQNf2nURIh8tgmUuQpfKedON+G
spusQvansFOzVgoi8JYjVQQzMHgqtriLVUNC6Goo7dbuaEy3NYy5IyBYJ5iwOYdL
X7cIbkKxnAFeMusuwsWRkdfDLft/pCqr0wo+76mQW9Jwx+DD5JzOtHwRCqoHT21n
nrg9qzdGO7eKZEqtQ/fvFHYJr01/zn85jGx+JlaDX6ZILJP68eAUjBLbaCxb8rVM
Yi0+qmto+QZkkuAI0Lul2JJkTYGpQ6a3MMsia70DpLOnt4TBdRCMwsdmtCG4sLmS
MXuDTBs8Hpzg7J0glGHLRA==
//pragma protect end_key_block
//pragma protect digest_block
H0bopUu32ivTFDA3K9T8J8SS43U=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 7215 characters]
mWeiKaLpTPGDMCLExxB59sIZN8ESJwvTleBjAXJg2Lk=
//pragma protect end_data_block
//pragma protect digest_block
1Okcq3Bx+b3XH43kFoKz4zxqo5g=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AQeRdzVOqJ4iwDoe99zvboXiU5lXFKDvlhNtq/WoiJqz4LI8dneGqViS0qW8E5cW
dFrNY74BxRuU1zUyWX2q7ND72HLZ7b43cP7d8Tx0UViZ4YnpFDbDdItwoawze53j
e7dyCusjEq4t/mD6olfwd9QnMg1orJWxZ8cPJ5j5xikDWP7ePgP4c277SWzoxnac
zaPxeAhOFGBJeIchq5UPEmXGUYcv58Xb5AlMc9yeTKOd+qgNHT2a7+6pvw0nC/Xu
X53tQILJGS8ZfJDFjSphdOcpjwpyF/M3/LJvhukvC3FT+TWVdtiq9wFcgfuQvGgP
b2syN15Zt9silhfUS78i/Q==
//pragma protect end_key_block
//pragma protect digest_block
ITI7TKpnea8mGeIScDpwDiMkohE=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 8060 characters]
//pragma protect end_data_block
//pragma protect digest_block
GB4TclGiedNPwOlCGOg+lt+8X2M=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
Ansv9YAwGh1QaXL1XvJIO4maHH0snzDgp0De9+9uCOGT7CK9+Roc9kV8pfYNuPlx
wSpH0ULhTI6FHPRKT6sQFmLuiJ6xFw7VzoVhPmHhpZSF57Tnwzae65R/Q1wuBFsS
VF8eDk0UtJJQ46qXepGqz24I13aL9v3MvqCcL5GprH5TkwDCgArozzr2Iwg5KsYG
fwuEPi78tJuSZd8J+iQ1mJhN1xRT4EEGZq7Q0SEJk74s8r5DQYoVZLfrqtInkP9i
gBebjMdYOLNlwGBFQJxa7r6QuNiRihf9E/lxc9CsNGzgLcfF4KFl36kNJJcMORRP
yKmksiA1VTS/ApNZ0EH+uw==
//pragma protect end_key_block
//pragma protect digest_block
0tRm4qYvLsm4+VVCglvfy7MBywQ=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 5070 characters]
P2AOvclZP5+DvLIqnfK8wOtD8kvDQOzj+nEvuWR4rgY=
//pragma protect end_data_block
//pragma protect digest_block
QmYdJtuhCo0aZM4+JP1v/m9eIME=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
Amajp3mby2UDUQLdpbYiAw9tFvXWC0k0x3RvEBRx1c7yL98M0GQX9AuQAM7ZWGKJ
cFuoIgVye3DoC/kXHvDRAzLJVaNEIXzaL9LtEBb0LITuFKpVhVAiUouMtvCcp0gm
C3y/rHeZEZelkSb4CpYPOF3H6YmH1phTaLaahAXTntOJAvxxNABVVs68XwhFaOe+
KEuopJkLi3hkRYWeaEyhj9kqC9IBrmXHUJYQ4qcIGIAl4tgHZPBv+0C35Cyg1Kqc
iW4Iczy8v7iNdsFAB/MxgW9Q/RNowBYIpnf61pXBeMFbwIsKxe8bTS1xu6R3+/19
3kwGS0I922iDeQiFN3Ir/w==
//pragma protect end_key_block
//pragma protect digest_block
6EuaYA9k9pp62W1ll3O8D6cdfeE=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 43485 characters]
//pragma protect end_data_block
//pragma protect digest_block
X+tWUYKDSvSQwlcpHm5Nf2KNUiQ=
//pragma protect end_digest_block
//pragma protect end_protected


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2021 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   simple_dual_port_ram_fifo.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      EFX FIFO
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
//
// *******************************

module `IP_MODULE_NAME(efx_fifo_top) # (
    parameter FAMILY             = "TRION",       // New Param
    parameter SYNC_CLK           = 0,
    parameter BYPASS_RESET_SYNC  = 0,             // New Param
    parameter SYNC_STAGE         = 2,             // New Param
    parameter MODE               = "STANDARD",
    parameter DEPTH              = 512,           // Reverted (Equivalent to WDATA_DEPTH) 
    parameter DATA_WIDTH         = 32,            // Reverted (Equivalent to WDATA_WIDTH)
    parameter PIPELINE_REG       = 1,             // Reverted (By default is ON)
    parameter OPTIONAL_FLAGS     = 1,             // Reverted
    parameter OUTPUT_REG         = 0,
    parameter PROGRAMMABLE_FULL  = "STATIC_DUAL", // Set to "NONE" if not require this feature
    parameter PROG_FULL_ASSERT   = 27,
    parameter PROG_FULL_NEGATE   = 23,
    parameter PROGRAMMABLE_EMPTY = "STATIC_DUAL", // Set to "NONE" if not require this feature
    parameter PROG_EMPTY_ASSERT  = 5,
    parameter PROG_EMPTY_NEGATE  = 7,
    parameter ALMOST_FLAG        = OPTIONAL_FLAGS,
    parameter HANDSHAKE_FLAG     = OPTIONAL_FLAGS,
    parameter ASYM_WIDTH_RATIO   = 4,
    parameter WADDR_WIDTH        = depth2width(DEPTH),
    parameter RDATA_WIDTH        = rdwidthcompute(ASYM_WIDTH_RATIO,DATA_WIDTH),
    parameter RD_DEPTH           = rddepthcompute(DEPTH,DATA_WIDTH,RDATA_WIDTH),
    parameter RADDR_WIDTH        = depth2width(RD_DEPTH),
    parameter ENDIANESS		      = 0,
    parameter OVERFLOW_PROTECT   = 1,
    parameter UNDERFLOW_PROTECT  = 1,
    parameter RAM_STYLE          = "block_ram"

)(
    input  wire                   a_rst_i,
    input  wire                   a_wr_rst_i,
    input  wire                   a_rd_rst_i,
    input  wire                   clk_i,
    input  wire                   wr_clk_i,
    input  wire                   rd_clk_i,
    input  wire                   wr_en_i,
    input  wire                   rd_en_i,
    input  wire [DATA_WIDTH-1:0]  wdata,
    output wire                   almost_full_o,
    output wire                   prog_full_o,
    output wire                   full_o,
    output wire                   overflow_o,
    output wire                   wr_ack_o,
    output wire [WADDR_WIDTH :0]  datacount_o,
    output wire [WADDR_WIDTH :0]  wr_datacount_o,
    output wire                   empty_o,
    output wire                   almost_empty_o,
    output wire                   prog_empty_o,
    output wire                   underflow_o,
    output wire                   rd_valid_o,
    output wire [RDATA_WIDTH-1:0] rdata,
    output wire [RADDR_WIDTH :0]  rd_datacount_o,
    output wire                   rst_busy
); 

localparam WR_DEPTH      = DEPTH;
localparam WDATA_WIDTH   = DATA_WIDTH;
localparam RAM_MUX_RATIO = (RDATA_WIDTH <= WDATA_WIDTH/32) ? 32 :
                           (RDATA_WIDTH <= WDATA_WIDTH/16) ? 16 :
                           (RDATA_WIDTH <= WDATA_WIDTH/8)  ? 8  :
                           (RDATA_WIDTH <= WDATA_WIDTH/4)  ? 4  :
                           (RDATA_WIDTH <= WDATA_WIDTH/2)  ? 2  :
                           (RDATA_WIDTH <= WDATA_WIDTH)    ? 1  :
                           (RDATA_WIDTH <= WDATA_WIDTH*2)  ? 2  :
                           (RDATA_WIDTH <= WDATA_WIDTH*4)  ? 4  :
                           (RDATA_WIDTH <= WDATA_WIDTH*8)  ? 8  :
                           (RDATA_WIDTH <= WDATA_WIDTH*16) ? 16 : 32;           

wire                   wr_rst_int;
wire                   rd_rst_int;
wire                   wr_en_int;
wire                   rd_en_int;
wire [WADDR_WIDTH-1:0] waddr;
wire [RADDR_WIDTH-1:0] raddr;
wire                   wr_clk_int;
wire                   rd_clk_int;
wire [WADDR_WIDTH :0]  wr_datacount_int;
wire [RADDR_WIDTH :0]  rd_datacount_int;

generate
    if (ASYM_WIDTH_RATIO == 4) begin
        if (SYNC_CLK) begin
            assign wr_clk_int     = clk_i;    
            assign rd_clk_int     = clk_i;
            assign datacount_o    = wr_datacount_int;
            assign wr_datacount_o = {(WADDR_WIDTH+1){1'b0}};
            assign rd_datacount_o = {(RADDR_WIDTH+1){1'b0}};
        end
        else begin
            assign wr_clk_int     = wr_clk_i;    
            assign rd_clk_int     = rd_clk_i;
            assign datacount_o    = {(WADDR_WIDTH+1){1'b0}};
            assign wr_datacount_o = wr_datacount_int;
            assign rd_datacount_o = rd_datacount_int;
        end
    end
    else begin
        assign datacount_o    = {(WADDR_WIDTH+1){1'b0}};
        assign wr_datacount_o = wr_datacount_int;
        assign rd_datacount_o = rd_datacount_int;
        if (SYNC_CLK) begin
            assign wr_clk_int     = clk_i;    
            assign rd_clk_int     = clk_i;
        end
        else begin
            assign wr_clk_int     = wr_clk_i;    
            assign rd_clk_int     = rd_clk_i;
        end
    end    

    if (!SYNC_CLK) begin
        //(* async_reg = "true" *) reg [1:0] wr_rst;
        //(* async_reg = "true" *) reg [1:0] rd_rst;
        //
        //always @ (posedge wr_clk_int or posedge a_rst_i) begin
        //    if (a_rst_i) 
        //        wr_rst <= 2'b11;
        //    else 
        //        wr_rst <= {wr_rst[0],1'b0};            
        //end
        //
        //always @ (posedge rd_clk_int or posedge a_rst_i) begin
        //    if (a_rst_i) 
        //        rd_rst <= 2'b11;
        //    else 
        //        rd_rst <= {rd_rst[0],1'b0};            
        //end
        

        if (BYPASS_RESET_SYNC) begin
            assign wr_rst_int = a_wr_rst_i;
            assign rd_rst_int = a_rd_rst_i; 
            assign rst_busy   = 1'b0;
        end 
        else begin
            `IP_MODULE_NAME(efx_resetsync) #(
               .ACTIVE_LOW (0)
            ) efx_resetsync_wr_rst (
               .clk   (wr_clk_int),
               .reset (a_rst_i),
               .d_o   (wr_rst_int)
            );

            `IP_MODULE_NAME(efx_resetsync) #(
               .ACTIVE_LOW (0)
            ) efx_resetsync_rd_rst (
               .clk   (rd_clk_int),
               .reset (a_rst_i),
               .d_o   (rd_rst_int)
            );
            assign rst_busy   = wr_rst_int | rd_rst_int;
        end

    end
    else begin
        //(* async_reg = "true" *) reg [1:0] a_rst;
        //
        //always @ (posedge clk_i or posedge a_rst_i) begin
        //    if (a_rst_i) 
        //        a_rst <= 2'b11;
        //    else 
        //        a_rst <= {a_rst[0],1'b0};            
        //end
        wire   a_rst;

        `IP_MODULE_NAME(efx_resetsync) #(
           .ACTIVE_LOW (0)
        ) efx_resetsync_a_rst (
           .clk   (clk_i),
           .reset (a_rst_i),
           .d_o   (a_rst)
        );

        if (BYPASS_RESET_SYNC) begin
            assign wr_rst_int = a_rst_i;
            assign rd_rst_int = a_rst_i;
            assign rst_busy   = 1'b0;
        end
        else begin
            assign wr_rst_int = a_rst;
            assign rd_rst_int = a_rst;   
            assign rst_busy   = wr_rst_int | rd_rst_int;
        end
    end 
endgenerate

`IP_MODULE_NAME(efx_fifo_ram) # (
    .FAMILY        (FAMILY),
    .WR_DEPTH      (WR_DEPTH),
    .RD_DEPTH      (RD_DEPTH),
    .WDATA_WIDTH   (WDATA_WIDTH),
    .RDATA_WIDTH   (RDATA_WIDTH),
    .WADDR_WIDTH   (WADDR_WIDTH),
    .RADDR_WIDTH   (RADDR_WIDTH),
    .OUTPUT_REG    (OUTPUT_REG),
    .RAM_MUX_RATIO (RAM_MUX_RATIO),
    .ENDIANESS	    (ENDIANESS),
    .RAM_STYLE     (RAM_STYLE)
) xefx_fifo_ram (
    .wdata (wdata), 
    .waddr (waddr),
    .raddr (raddr), 
    .we    (wr_en_int), 
    .re    (rd_en_int),
    .wclk  (wr_clk_int),
    .rclk  (rd_clk_int),
    .rdata (rdata)
);

`IP_MODULE_NAME(efx_fifo_ctl) # (
    .SYNC_CLK           (SYNC_CLK),
    .SYNC_STAGE         (SYNC_STAGE),
    .MODE               (MODE),
    .WR_DEPTH           (WR_DEPTH),
    .WADDR_WIDTH        (WADDR_WIDTH),
    .RADDR_WIDTH        (RADDR_WIDTH),
    .ASYM_WIDTH_RATIO   (ASYM_WIDTH_RATIO),
    .RAM_MUX_RATIO      (RAM_MUX_RATIO),
    .PIPELINE_REG       (PIPELINE_REG),
    .ALMOST_FLAG        (ALMOST_FLAG),
    .PROGRAMMABLE_FULL  (PROGRAMMABLE_FULL),
    .PROG_FULL_ASSERT   (PROG_FULL_ASSERT),
    .PROG_FULL_NEGATE   (PROG_FULL_NEGATE),
    .PROGRAMMABLE_EMPTY (PROGRAMMABLE_EMPTY),
    .PROG_EMPTY_ASSERT  (PROG_EMPTY_ASSERT),
    .PROG_EMPTY_NEGATE  (PROG_EMPTY_NEGATE),
    .OUTPUT_REG         (OUTPUT_REG),
    .HANDSHAKE_FLAG     (HANDSHAKE_FLAG),
    .OVERFLOW_PROTECT   (OVERFLOW_PROTECT),
    .UNDERFLOW_PROTECT  (UNDERFLOW_PROTECT)
) xefx_fifo_ctl (
    .wr_rst          (wr_rst_int),
    .rd_rst          (rd_rst_int),
    .wclk            (wr_clk_int),
    .rclk            (rd_clk_int),
    .we              (wr_en_i),
    .re              (rd_en_i),
    .wr_full         (full_o),
    .wr_ack          (wr_ack_o),
    .rd_empty        (empty_o),
    .wr_almost_full  (almost_full_o),
    .rd_almost_empty (almost_empty_o),
    .wr_prog_full    (prog_full_o),
    .rd_prog_empty   (prog_empty_o),
    .wr_en_int       (wr_en_int),
    .rd_en_int       (rd_en_int),
    .waddr           (waddr),
    .raddr           (raddr),
    .wr_datacount    (wr_datacount_int),
    .rd_datacount    (rd_datacount_int),
    .rd_vld          (rd_valid_o),
    .wr_overflow     (overflow_o),
    .rd_underflow    (underflow_o)
);

function integer depth2width;
input [31:0] depth;
begin : fnDepth2Width
    if (depth > 1) begin
        depth = depth - 1;
        for (depth2width=0; depth>0; depth2width = depth2width + 1)
            depth = depth>>1;
        end
    else
       depth2width = 0;
end
endfunction 

function integer width2depth;
input [31:0] width;
begin : fnWidth2Depth
    width2depth = width**2;
end
endfunction

function integer rdwidthcompute;
input [31:0] asym_option;
input [31:0] wr_width;
begin : RdWidthCompute
    rdwidthcompute = (asym_option==0)? wr_width/16 :
                     (asym_option==1)? wr_width/8  :
                     (asym_option==2)? wr_width/4  :
                     (asym_option==3)? wr_width/2  :
                     (asym_option==4)? wr_width/1  :
                     (asym_option==5)? wr_width*2  :
                     (asym_option==6)? wr_width*4  :
                     (asym_option==7)? wr_width*8  :
                     (asym_option==8)? wr_width*16 : wr_width/1;
end
endfunction

function integer rddepthcompute;
input [31:0] wr_depth;
input [31:0] wr_width;
input [31:0] rd_width;
begin : RdDepthCompute
    rddepthcompute = (wr_depth * wr_width) / rd_width;
end
endfunction

endmodule


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2021 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   simple_dual_port_ram_fifo.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      EFX FIFO
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
//
// *******************************

module `IP_MODULE_NAME(efx_fifo_ram) #(
    parameter FAMILY        = "TRION",
    parameter WR_DEPTH      = 512,
    parameter RD_DEPTH      = 512,
    parameter WDATA_WIDTH   = 8,
    parameter RDATA_WIDTH   = 8,
    parameter WADDR_WIDTH   = 9,
    parameter RADDR_WIDTH   = 9,
    parameter OUTPUT_REG    = 1,
    parameter RAM_MUX_RATIO = 4,
    parameter ENDIANESS 	 = 0, //0: Big endian (default)   1: Little endian 
    parameter RAM_STYLE     = "block_ram"
) (
    input  wire                     wclk,
    input  wire                     rclk,
    input  wire                     we,
    input  wire                     re,
    input  wire [(WDATA_WIDTH-1):0] wdata,
    input  wire [(WADDR_WIDTH-1):0] waddr,
    input  wire [(RADDR_WIDTH-1):0] raddr,
    output wire [(RDATA_WIDTH-1):0] rdata
);

localparam MEM_DEPTH         = (WR_DEPTH > RD_DEPTH) ? WR_DEPTH : RD_DEPTH;
localparam MEM_DATA_WIDTH    = (WDATA_WIDTH > RDATA_WIDTH) ? RDATA_WIDTH : WDATA_WIDTH;   
localparam LSB_WIDTH         = (WADDR_WIDTH > RADDR_WIDTH) ? (WADDR_WIDTH - RADDR_WIDTH) : (RADDR_WIDTH - WADDR_WIDTH);
localparam RDATA_WDATA_RATIO = (RDATA_WIDTH <= WDATA_WIDTH/32) ? "ONE_THIRTYTWO" :
                               (RDATA_WIDTH <= WDATA_WIDTH/16) ? "ONE_SIXTEENTH" :
                               (RDATA_WIDTH <= WDATA_WIDTH/8)  ? "ONE_EIGHTH"    :
                               (RDATA_WIDTH <= WDATA_WIDTH/4)  ? "ONE_FOURTH"    :
                               (RDATA_WIDTH <= WDATA_WIDTH/2)  ? "ONE_HALF"      :
                               (RDATA_WIDTH <= WDATA_WIDTH)    ? "ONE"           :
                               (RDATA_WIDTH <= WDATA_WIDTH*2)  ? "TWO_TIMES"     :
                               (RDATA_WIDTH <= WDATA_WIDTH*4)  ? "FOUR_TIMES"    :
                               (RDATA_WIDTH <= WDATA_WIDTH*4)  ? "EIGHT_TIMES"   :
                               (RDATA_WIDTH <= WDATA_WIDTH*4)  ? "SIXTEEN_TIMES" : "THIRTYTWO_TIMES";

(* syn_ramstyle = RAM_STYLE *) reg [MEM_DATA_WIDTH-1:0] ram[MEM_DEPTH-1:0];
reg [RDATA_WIDTH-1:0]    r_rdata_1P;
reg [RDATA_WIDTH-1:0]    r_rdata_2P;

wire                     re_int;

generate
    if (FAMILY == "TRION") begin
        if (RDATA_WDATA_RATIO == "ONE") begin
            always @ (posedge wclk) begin
                if (we)
                    ram[waddr] <= wdata;
            end
    
            always @ (posedge rclk) begin
                if (re_int) begin
                    r_rdata_1P <= ram[raddr];
                end
                r_rdata_2P <= r_rdata_1P;
            end
        end
        
        else if (RDATA_WDATA_RATIO == "ONE_THIRTYTWO" || RDATA_WDATA_RATIO == "ONE_SIXTEENTH" || RDATA_WDATA_RATIO == "ONE_EIGHTH" || RDATA_WDATA_RATIO == "ONE_FOURTH"  || RDATA_WDATA_RATIO == "ONE_HALF" ) begin
            if (ENDIANESS == 0) begin 
            	integer i;
            	always @ (posedge wclk) begin
                	for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (we) begin
                            ram[{waddr,LSB_WIDTH'(RAM_MUX_RATIO-1-i)}] <= wdata[((WDATA_WIDTH/RAM_MUX_RATIO)*i) +: WDATA_WIDTH/RAM_MUX_RATIO];
                        end
                    end
                end
                always @ (posedge rclk) begin 
                	if (re_int) begin
                		r_rdata_1P <= ram[raddr];
                    end
                		r_rdata_2P <= r_rdata_1P;
                end
            end
            else begin //endianess == 1
            	integer i;
            	always @ (posedge wclk) begin
            		for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (we) begin
                            ram[{waddr,LSB_WIDTH'(i)}] <= wdata[((WDATA_WIDTH/RAM_MUX_RATIO)*i) +: WDATA_WIDTH/RAM_MUX_RATIO];
                        end
                    end
                end
                always @ (posedge rclk) begin 
                	if (re_int) begin
                		r_rdata_1P <= ram[raddr];
                	end
                		r_rdata_2P <= r_rdata_1P;
                end
            end
        end
        
        else if (RDATA_WDATA_RATIO == "TWO_TIMES" || RDATA_WDATA_RATIO == "FOUR_TIMES"  || RDATA_WDATA_RATIO == "EIGHT_TIMES"  || RDATA_WDATA_RATIO == "SIXTEEN_TIMES"  ||RDATA_WDATA_RATIO == "THIRTYTWO_TIMES" ) begin
            //integer i;
        	if (ENDIANESS == 0) begin
        		always @ (posedge wclk) begin
        			if (we)
        				ram[waddr] <= wdata;
        		end
        		integer i;
        		always @ (posedge rclk) begin
        			for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (re_int) begin
                    		r_rdata_1P[((RDATA_WIDTH/RAM_MUX_RATIO)*i) +: RDATA_WIDTH/RAM_MUX_RATIO] <= ram[{raddr,LSB_WIDTH'(RAM_MUX_RATIO-1-i)}];
                    	end
                        	r_rdata_2P <= r_rdata_1P;
                    end
                end 
            end
            else begin //endianess == 1
            	always @ (posedge wclk) begin
        			if (we)
        				ram[waddr] <= wdata;
        		end
        		integer i;
        		always @ (posedge rclk) begin
        			for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (re_int) begin
                    		r_rdata_1P[((RDATA_WIDTH/RAM_MUX_RATIO)*i) +: RDATA_WIDTH/RAM_MUX_RATIO] <= ram[{raddr,LSB_WIDTH'(i)}];
                    	end
                        	r_rdata_2P <= r_rdata_1P;
                    end
                end
            end
        end
        if (OUTPUT_REG) begin
            assign re_int = re;
            assign rdata  = r_rdata_2P;            
        end
        else begin
            assign re_int = re;
            assign rdata  = r_rdata_1P;
        end
    end
    else begin
        if (RDATA_WDATA_RATIO == "ONE") begin
            always @ (posedge wclk) begin
                if (we)
                    ram[waddr] <= wdata;
            end
    
            always @ (posedge rclk) begin
                if (re_int) begin
                    r_rdata_1P <= ram[raddr];
                    r_rdata_2P <= r_rdata_1P;
                end
            end
        end 
        else if (RDATA_WDATA_RATIO == "ONE_THIRTYTWO" || RDATA_WDATA_RATIO == "ONE_SIXTEENTH" || RDATA_WDATA_RATIO == "ONE_EIGHTH" || RDATA_WDATA_RATIO == "ONE_FOURTH"  || RDATA_WDATA_RATIO == "ONE_HALF" ) begin
            //integer i;
            if (ENDIANESS == 0) begin
            	integer i;
            	always @ (posedge wclk) begin
            		for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (we) begin
                            	ram[{waddr,LSB_WIDTH'(RAM_MUX_RATIO-1-i)}] <= wdata[((WDATA_WIDTH/RAM_MUX_RATIO)*i) +: WDATA_WIDTH/RAM_MUX_RATIO];
                        end
                    end
                 end
               	always @ (posedge rclk) begin 
               		if (re_int) begin
               			r_rdata_1P <= ram[raddr];
               			r_rdata_2P <= r_rdata_1P;
               		end
               	end
            end
            
            else begin //endianess == 1
            	integer i;
            	always @ (posedge wclk) begin
            		for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (we) begin
                            	ram[{waddr,LSB_WIDTH'(i)}] <= wdata[((WDATA_WIDTH/RAM_MUX_RATIO)*i) +: WDATA_WIDTH/RAM_MUX_RATIO];
                        end
                    end
                 end
               	always @ (posedge rclk) begin 
               		if (re_int) begin
               			r_rdata_1P <= ram[raddr];
               			r_rdata_2P <= r_rdata_1P;
               		end
               	end
            end
        end
        else if (RDATA_WDATA_RATIO == "TWO_TIMES" || RDATA_WDATA_RATIO == "FOUR_TIMES"  || RDATA_WDATA_RATIO == "EIGHT_TIMES"  || RDATA_WDATA_RATIO == "SIXTEEN_TIMES"  || RDATA_WDATA_RATIO == "THIRTYTWO_TIMES" ) begin
        	//integer i;
        	if (ENDIANESS == 0) begin
        		always @ (posedge wclk) begin
        			if (we)
        				ram[waddr] <= wdata;
        		end
        		integer i;
            	always @ (posedge rclk) begin
            		for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (re_int) begin
                    		r_rdata_1P[((RDATA_WIDTH/RAM_MUX_RATIO)*i) +: RDATA_WIDTH/RAM_MUX_RATIO] <= ram[{raddr,LSB_WIDTH'(RAM_MUX_RATIO-1-i)}];
                    		r_rdata_2P                                                               <= r_rdata_1P;
                    	end
                    end
                end 
            end
            
            else begin //endianess ==1
        		always @ (posedge wclk) begin
        			if (we)
        				ram[waddr] <= wdata;
        		end
        		integer i;
            	always @ (posedge rclk) begin
            		for (i=0; i<RAM_MUX_RATIO; i=i+1) begin
                    	if (re_int) begin
                    		r_rdata_1P[((RDATA_WIDTH/RAM_MUX_RATIO)*i) +: RDATA_WIDTH/RAM_MUX_RATIO] <= ram[{raddr,LSB_WIDTH'(i)}];
                    		r_rdata_2P                                                               <= r_rdata_1P;
                    	end
                    end
                end 
            end
        end
        // NIC
        //if (MODE == "STANDARD") begin     
        //    if (OUTPUT_REG) begin
        //        reg re_r;
        //        always @ (posedge rclk) begin
        //            re_r <= re;
        //        end
        //        assign re_int = re | re_r;        
        //        assign rdata  = r_rdata_2P;            
        //    end
        //    else begin
        //        assign re_int = re;
        //        assign rdata  = r_rdata_1P;
        //    end
        //end
        //else begin
        //    assign re_int = re;
        //    assign rdata  = r_rdata_1P;
        //end    
        if (OUTPUT_REG) begin
            reg re_r;
            always @ (posedge rclk) begin
                re_r <= re;
            end
            assign re_int = re | re_r;        
            assign rdata  = r_rdata_2P;            
        end
        else begin
            assign re_int = re;
            assign rdata  = r_rdata_1P;
        end    
    end
endgenerate

endmodule

////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013-2021 Efinix Inc. All rights reserved.              
//
// This   document  contains  proprietary information  which   is        
// protected by  copyright. All rights  are reserved.  This notice       
// refers to original work by Efinix, Inc. which may be derivitive       
// of other work distributed under license of the authors.  In the       
// case of derivative work, nothing in this notice overrides the         
// original author's license agreement.  Where applicable, the           
// original license agreement is included in it's original               
// unmodified form immediately below this header.                        
//
// WARRANTY DISCLAIMER.                                                  
//     THE  DESIGN, CODE, OR INFORMATION ARE PROVIDED “AS IS” AND        
//     EFINIX MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH               
//     RESPECT THERETO, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES,  
//     INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF          
//     MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR    
//     PURPOSE.  SOME STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED       
//     WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE.           
//
// LIMITATION OF LIABILITY.                                              
//     NOTWITHSTANDING ANYTHING TO THE CONTRARY, EXCEPT FOR BODILY       
//     INJURY, EFINIX SHALL NOT BE LIABLE WITH RESPECT TO ANY SUBJECT    
//     MATTER OF THIS AGREEMENT UNDER TORT, CONTRACT, STRICT LIABILITY   
//     OR ANY OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY INDIRECT,      
//     SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES OF ANY    
//     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF      
//     GOODWILL, DATA OR PROFIT, WORK STOPPAGE, OR COMPUTER FAILURE OR   
//     MALFUNCTION, OR IN ANY EVENT (II) FOR ANY AMOUNT IN EXCESS, IN    
//     THE AGGREGATE, OF THE FEE PAID BY LICENSEE TO EFINIX HEREUNDER    
//     (OR, IF THE FEE HAS BEEN WAIVED, $100), EVEN IF EFINIX SHALL HAVE 
//     BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO 
//     NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR            
//     CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT   
//     APPLY TO LICENSEE.
//
////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   gray2bin.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      Gray to Binary Encoding Convertor
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************

`resetall
`timescale 1ns/1ps

module `IP_MODULE_NAME(efx_fifo_gray2bin)
#(parameter WIDTH=5)
(// outputs
 output wire [WIDTH-1:0] bin_o,
 // input
 input [WIDTH-1:0] gray_i);

//---------------------------------------------------------------------
// Recursive Module
// Description: reduction xor
generate
   if (WIDTH > 1) begin
      wire [1:0] bin_1;
      assign bin_1 = {gray_i[WIDTH-1], gray_i[WIDTH-1]^gray_i[WIDTH-2]};
      if (WIDTH == 2) begin
	 assign bin_o = bin_1;
      end
      else begin
	 assign bin_o[WIDTH-1] = bin_1[1];
	 `IP_MODULE_NAME(efx_fifo_gray2bin) #(.WIDTH(WIDTH-1)) u_gray2bin (.bin_o(bin_o[WIDTH-2:0]), .gray_i({bin_1[0], gray_i[WIDTH-3:0]}));
      end
   end
   else /* if (WIDTH == 1) */
     assign bin_o = gray_i;
endgenerate
   
endmodule 

////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013-2020 Efinix Inc. All rights reserved.              
//
// This   document  contains  proprietary information  which   is        
// protected by  copyright. All rights  are reserved.  This notice       
// refers to original work by Efinix, Inc. which may be derivitive       
// of other work distributed under license of the authors.  In the       
// case of derivative work, nothing in this notice overrides the         
// original author's license agreement.  Where applicable, the           
// original license agreement is included in it's original               
// unmodified form immediately below this header.                        
//
// WARRANTY DISCLAIMER.                                                  
//     THE  DESIGN, CODE, OR INFORMATION ARE PROVIDED “AS IS” AND        
//     EFINIX MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH               
//     RESPECT THERETO, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES,  
//     INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF          
//     MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR    
//     PURPOSE.  SOME STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED       
//     WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE.           
//
// LIMITATION OF LIABILITY.                                              
//     NOTWITHSTANDING ANYTHING TO THE CONTRARY, EXCEPT FOR BODILY       
//     INJURY, EFINIX SHALL NOT BE LIABLE WITH RESPECT TO ANY SUBJECT    
//     MATTER OF THIS AGREEMENT UNDER TORT, CONTRACT, STRICT LIABILITY   
//     OR ANY OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY INDIRECT,      
//     SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES OF ANY    
//     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF      
//     GOODWILL, DATA OR PROFIT, WORK STOPPAGE, OR COMPUTER FAILURE OR   
//     MALFUNCTION, OR IN ANY EVENT (II) FOR ANY AMOUNT IN EXCESS, IN    
//     THE AGGREGATE, OF THE FEE PAID BY LICENSEE TO EFINIX HEREUNDER    
//     (OR, IF THE FEE HAS BEEN WAIVED, $100), EVEN IF EFINIX SHALL HAVE 
//     BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO 
//     NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR            
//     CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT   
//     APPLY TO LICENSEE.
//
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   pipe_reg.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      Parallel Pipelining Shift Register
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************

module `IP_MODULE_NAME(efx_fifo_datasync) #(
    parameter STAGE = 32,
    parameter WIDTH = 4
) (
 input  wire             clk_i,
 input  wire [WIDTH-1:0] d_i,
 output wire [WIDTH-1:0] d_o
);

(* async_reg = "true" *) reg [WIDTH-1:0] pipe_reg [STAGE-1:0];
integer i;

always @(posedge clk_i) begin
  for (i=STAGE-1; i>0; i = i - 1) begin
    pipe_reg[i] <= pipe_reg[i-1];
  end
  pipe_reg[0] <= d_i;
end
assign d_o = pipe_reg[STAGE-1];
   

endmodule

////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013-2020 Efinix Inc. All rights reserved.              
//
// This   document  contains  proprietary information  which   is        
// protected by  copyright. All rights  are reserved.  This notice       
// refers to original work by Efinix, Inc. which may be derivitive       
// of other work distributed under license of the authors.  In the       
// case of derivative work, nothing in this notice overrides the         
// original author's license agreement.  Where applicable, the           
// original license agreement is included in it's original               
// unmodified form immediately below this header.                        
//
// WARRANTY DISCLAIMER.                                                  
//     THE  DESIGN, CODE, OR INFORMATION ARE PROVIDED “AS IS” AND        
//     EFINIX MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH               
//     RESPECT THERETO, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES,  
//     INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF          
//     MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR    
//     PURPOSE.  SOME STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED       
//     WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE.           
//
// LIMITATION OF LIABILITY.                                              
//     NOTWITHSTANDING ANYTHING TO THE CONTRARY, EXCEPT FOR BODILY       
//     INJURY, EFINIX SHALL NOT BE LIABLE WITH RESPECT TO ANY SUBJECT    
//     MATTER OF THIS AGREEMENT UNDER TORT, CONTRACT, STRICT LIABILITY   
//     OR ANY OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY INDIRECT,      
//     SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES OF ANY    
//     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF      
//     GOODWILL, DATA OR PROFIT, WORK STOPPAGE, OR COMPUTER FAILURE OR   
//     MALFUNCTION, OR IN ANY EVENT (II) FOR ANY AMOUNT IN EXCESS, IN    
//     THE AGGREGATE, OF THE FEE PAID BY LICENSEE TO EFINIX HEREUNDER    
//     (OR, IF THE FEE HAS BEEN WAIVED, $100), EVEN IF EFINIX SHALL HAVE 
//     BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO 
//     NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR            
//     CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT   
//     APPLY TO LICENSEE.
//
////////////////////////////////////////////////////////////////////////////////



// synopsys translate_off
`timescale 1 ns / 1 ps													
// synopsys translate_on

module `IP_MODULE_NAME(efx_resetsync) #(
    parameter ASYNC_STAGE = 2,
    parameter ACTIVE_LOW = 1
) (
    input  wire             clk,
    input  wire             reset,
    output wire             d_o
);


generate
   if (ACTIVE_LOW == 1) begin: active_low
      `IP_MODULE_NAME(efx_asyncreg) #(
         .WIDTH      (1),
         .ACTIVE_LOW (1),
         .RST_VALUE  (0)
      ) efx_resetsync_active_low (
         .clk     (clk),
         .reset_n (reset),
         .d_i     (1'b1),
         .d_o     (d_o)
      );
   end
   else begin: active_high
      `IP_MODULE_NAME(efx_asyncreg) #(
         .WIDTH      (1),
         .ACTIVE_LOW (0),
         .RST_VALUE  (1)
      ) efx_resetsync_active_high (
         .clk     (clk),
         .reset_n (reset),
         .d_i     (1'b0),
         .d_o     (d_o)
      );
   end
endgenerate

endmodule



// synopsys translate_off
`timescale 1 ns / 1 ps													
// synopsys translate_on

module `IP_MODULE_NAME(efx_asyncreg) #(
    parameter ASYNC_STAGE = 2,
    parameter WIDTH = 4,
    parameter ACTIVE_LOW = 1, // 0 - Active high reset, 1 - Active low reset
    parameter RST_VALUE = 0,
    parameter OFF_ASSERTION = 0 // 1 = Turn off PULSE_WIDTH_CHK assertion for a particular instance 
) (
    input  wire             clk,
    input  wire             reset_n,
    input  wire [WIDTH-1:0] d_i,
    output wire [WIDTH-1:0] d_o
);










`pragma protect begin_protected
`pragma protect version = 1
`pragma protect author = "author-a" , author_info = "author-a-details"
`pragma protect encrypt_agent = "QuestaSim" , encrypt_agent_info = "2023.4"
`pragma protect key_keyowner = "Efinix Inc." , key_keyname = "EFX_K01"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 256 )
`pragma protect key_block
IjzmeF2ACtI8q/MHPcSQakfCyuQSUgg747Z3U+BWZdCStFbqF/Rhg0VPl8JT+91V
o/8Ohsiw6GnpSIX69XazqGYmhEjb+W7W2ngBYentEXdSyzUYvEbr8i71cL04f1fE
El78uYgSvjFwoDyocXOVYk8JA0v7y6WnabkL02lAqASKGQK55nzfKeUVbJHKHjAY
kIT3Nf7JWK2NVVymI1Zs5QttwrNgKBSqoiPvmy4+16bTQMx4R205Bb4rT1MqSqIc
/5U5/Z1e1tZzOqoEyhfcMMKW0emdBIdByNvteK05ZATt11Uzj2M/Vn1r9KmYd0h1
uYJaS5tuGEuFInBHa7oO8g==
`pragma protect key_keyowner = "Cadence Design Systems." , key_keyname = "CDS_RSA_KEY_VER_2"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 256 )
`pragma protect key_block
ABJo/BvEH9XbZrt+xPOQ2C7yeLcnebDlRELbHyCdXeeNkZRVZ9m0ie+1HufS/I+3
fC63lnVTenVdf9s4tm1RLd5VBkmFb37ikgaESy2aRKWsdLG6x2OyuODoMDRCjYUa
rxhnwLWh5E55yR3XVZgM2k7/NPP2cTL7iOSCjH4No38siNjs4Fapyc4FFq0TOsQq
PMqsZ5jgmM+ZT8cil0wMt5tpdEOwvchbe1GcZLIhcIFLD/Gb2XtP0Q0QkOlNzuiL
DNyobLTjDkV5si+/23Ng2E7tDq+SX+vJP4ciI63kXtsmQdn1ff2Y64ibNXJtpu/w
K3OoKmk3zFeArSsql8B4/Q==
`pragma protect key_keyowner = "Synopsys" , key_keyname = "SNPS-VCS-RSA-2"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 128 )
`pragma protect key_block
RAoMYYsrw2j05cvQ8NR0lCh+Ia/OGVfdwZqq0pwIkgDzO3Z7ol96oQmQzFfIQY/M
GzEOFdYJTfjnxPvhSPxT1tpq2Fgx6PbC2FMWFtN6/TrG/s01ifIWIZ9Wrfo8Q01l
6XTAESHR1htrOOx6AiDHAQLOlBb0zgfZjayGJBRX7FI=
`pragma protect key_keyowner = "Aldec" , key_keyname = "ALDEC15_001"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 256 )
`pragma protect key_block
YclPuIbYLW/ftZYybucr9ooblGFkJDcdUWf6kCJBGKpIRjItUB3LdSwcREekRWqf
RGiSRFoyrOTiScT06zZ4fkm+PEKj8O3RU1VMMzDjuEUqkAEELJHNOH71tCSC6MWk
1dop7MZy8BSXhzg3W3RXIA8IGSJRDibliv+SjkbUzg/WceDI176fJmUwGUji93Tw
Zu2vRjA/RTi3ZMzS/2Z9YE156hpipJ/Cu6ca8V3y5Kt6DX4fcCS09xESr6soT5Oz
eKRExN7wu8dvYMUuu1YgCVVR47BBDQi3wdZHqlq1PLaycnNOwBPLOAzA19Hefh/0
2HflB1HYKxojQCcZU7qUgQ==
`pragma protect key_keyowner = "Siemens" , key_keyname = "SIEMENS-VERIF-SIM-RSA-2"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 256 )
`pragma protect key_block
fMvC6d2jTMqMqGFzPCPWt6pV9wRUCG4/taH3Nfn7RcekdiLyXQEQgm1SN+X+hkbx
Pu7552vaw2ez4j3zrTk2vRPnDAsxY8GidEnkJcULi8kiia9Xy/ePFLxOJHHigkiB
rU7uwrFblcYYBRwQjhMhJDowyR9HVAonxhOWVIlYagtABxLYlNdDEn+N4yPLVCsr
XUWy1E2L5GUFFNQffENN0iyUaKdWAKGIqgIZK1sB3tVOPVsULetSoyzRErWPNZQD
e5jbBBNZGyQQWgOJkOfy280ekoUUEZajqtB1jDvE3k8kbo4rzvr7yTkhSzLqjGod
B2Zpo2FQ//YDRSAaEa9ksQ==
`pragma protect key_keyowner = "Mentor Graphics Corporation" , key_keyname = "MGC-VERIF-SIM-RSA-2"
`pragma protect key_method = "rsa"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 256 )
`pragma protect key_block
TcmE9lQROafuvxGWP3fMVxDoeaiMX6ALoT3detg/qWZ36+yPTc/t8N7/DtSx17Ze
vr6iBb+ge3aAzWAq2QHyVfgVV15dvW/HsOXXTh7UqExiO7Dxa6nHXuAhYMON6NP2
ihfIRSvdnrL2ufvg7A2rCHGAqnr6cVnRLfhNJxtA1lloQbJEtlf/CWNblDxEfyw2
06l3l8pp1rS0E4tMqagmOr+yhNSpcS9vQswFltqroh6kNIE64zKri96HKkRFLNlP
fpsN7plEpLS54SxIMmh8Op+w0a/jXVOxxD+FLepsZWfGiNksENgu2Xo6TvZIQUUN
ZoPzFCMjGk5ZmMyIlytNCw==
`pragma protect data_method = "aes256-cbc"
`pragma protect encoding = ( enctype = "base64" , line_length = 64 , bytes = 4288 )
`pragma protect data_block
[encoded data, 5785 characters]
Ei7EaFpheCmlTJyxUg8TdA==
`pragma protect end_protected


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2021 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   simple_dual_port_ram_fifo.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      EFX FIFO
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
//
// *******************************

module `IP_MODULE_NAME(efx_fifo_ctl) # (
    parameter SYNC_CLK           = 1,
    parameter SYNC_STAGE         = 2,
    parameter MODE               = "STANDARD",
    parameter WR_DEPTH           = 512,
    parameter WADDR_WIDTH        = 9,
    parameter RADDR_WIDTH        = 9,
    parameter ASYM_WIDTH_RATIO   = 4,
    parameter RAM_MUX_RATIO      = 1,
    parameter PIPELINE_REG       = 1,
    parameter ALMOST_FLAG        = 1,
    parameter PROGRAMMABLE_FULL  = "NONE",
    parameter PROG_FULL_ASSERT   = 0,
    parameter PROG_FULL_NEGATE   = 0,
    parameter PROGRAMMABLE_EMPTY = "NONE",
    parameter PROG_EMPTY_ASSERT  = 0,
    parameter PROG_EMPTY_NEGATE  = 0,
    parameter OUTPUT_REG         = 0,
    parameter HANDSHAKE_FLAG     = 1, 
    parameter OVERFLOW_PROTECT   = 0,
    parameter UNDERFLOW_PROTECT  = 0
)(
    input   wire                   wr_rst,
    input   wire                   rd_rst,
    input   wire                   wclk,
    input   wire                   rclk,
    input   wire                   we,
    input   wire                   re,
    output  wire                   wr_full,
    output  reg                    wr_ack,
    output  wire                   wr_almost_full,
    output  wire                   rd_empty,
    output  wire                   rd_almost_empty,
    output  wire                   wr_prog_full,
    output  wire                   rd_prog_empty,
    output  wire                   wr_en_int,
    output  wire                   rd_en_int,
    output  wire [WADDR_WIDTH-1:0] waddr,
    output  wire [RADDR_WIDTH-1:0] raddr,
    output  wire [WADDR_WIDTH:0]   wr_datacount,
    output  wire [RADDR_WIDTH:0]   rd_datacount,
    output  wire                   rd_vld,
    output  reg                    wr_overflow,
    output  reg                    rd_underflow
);

reg  [WADDR_WIDTH:0] waddr_cntr;
reg  [WADDR_WIDTH:0] waddr_cntr_r;
reg  [RADDR_WIDTH:0] raddr_cntr;
reg                  rd_valid;

wire [WADDR_WIDTH:0] waddr_int;
wire [RADDR_WIDTH:0] raddr_int;
wire                 rd_empty_int;
wire [WADDR_WIDTH:0] wr_datacount_int;
wire [RADDR_WIDTH:0] rd_datacount_int;

assign waddr     = waddr_cntr[WADDR_WIDTH-1:0];
// NIC
wire [RADDR_WIDTH:0] ram_raddr;
assign raddr     = (MODE == "FWFT") ? ram_raddr[RADDR_WIDTH-1:0] : raddr_cntr[RADDR_WIDTH-1:0];
//assign raddr     = raddr_cntr[RADDR_WIDTH-1:0];
//assign wr_en_int = we & ~wr_full;
assign wr_en_int = OVERFLOW_PROTECT ? we & ~wr_full : we;

assign wr_datacount  = wr_datacount_int;
assign rd_datacount  = ASYM_WIDTH_RATIO == 4 && SYNC_CLK ? wr_datacount_int : rd_datacount_int;


generate
    if (MODE == "FWFT") begin    
        // NIC
        //assign rd_en_int     = (~rd_empty_int & rd_empty) | (re & ~rd_empty_int);
        //assign rd_empty      = rd_empty_fwft;

        assign rd_en_int     = 1'b1;
        //assign rd_empty      = rd_empty_int;
        
        //always @ (posedge rclk or posedge rd_rst) begin
        //    if (rd_rst) begin
        //        init_set <= 1'b1;
        //    end
        //    else if (~init_set & rd_empty) begin
        //        init_set <= 1'b1;            
        //    end
        //    else if (~rd_empty_int) begin
        //        init_set <= 1'b0;            
        //    end
        //    else if (rd_empty) begin
        //        init_set <= 1'b1;            
        //    end
        //end
        // NIC 
        //always @ (posedge rclk or posedge rd_rst) begin
        //    if (rd_rst) begin
        //        rd_empty_fwft <= 1'b1;
        //    end
        //    else if (rd_en_int) begin
        //        rd_empty_fwft <= 1'b0;            
        //    end
        //    else if (re) begin
        //        rd_empty_fwft <= 1'b1;            
        //    end
        //end          
        
        //if (FAMILY == "TRION") begin
        if (OUTPUT_REG) begin
            always @ (posedge rclk or posedge rd_rst) begin
                if (rd_rst) begin
                    rd_valid <= 1'b0;
                end
                else begin
                    rd_valid <= ~rd_empty;
                end
            end
            assign rd_vld = rd_valid;                
        end    
        else begin
            assign rd_vld = ~rd_empty;                
        end
        
        assign rd_empty = rd_empty_int;
    end
    else begin
        assign rd_en_int     = UNDERFLOW_PROTECT ? re & ~rd_empty_int : re;
        assign rd_empty      = rd_empty_int;
        
        if (OUTPUT_REG) begin
            reg rd_valid_r;
            always @ (posedge rclk or posedge rd_rst) begin
                if (rd_rst) begin
                    rd_valid_r <= 'h0;
                    rd_valid   <= 'h0;
                end
                else begin
                    {rd_valid,rd_valid_r} <= {rd_valid_r,rd_en_int};
                end
            end
            assign rd_vld = rd_valid;            
        end
        else begin
            always @ (posedge rclk or posedge rd_rst) begin
                if (rd_rst) begin
                    rd_valid  <= 'h0;
                end
                else begin
                    rd_valid <= rd_en_int;
                end
            end
            assign rd_vld = rd_valid;
        end
    end
    
    if (ALMOST_FLAG) begin
        assign wr_almost_full   = wr_datacount >= WR_DEPTH-1;
        assign rd_almost_empty  = rd_datacount <= 'd1;
    end
    else begin
        assign wr_almost_full   = 1'b0;
        assign rd_almost_empty  = 1'b0;        
    end
    
    if (PROGRAMMABLE_FULL == "STATIC_SINGLE") begin
        reg    wr_prog_full_int;
        assign wr_prog_full  = wr_datacount >= PROG_FULL_ASSERT;
        
        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                wr_prog_full_int  <= 1'b0;
            end
            else begin
                wr_prog_full_int  <= wr_prog_full;
            end
        end  
    end
    else if (PROGRAMMABLE_FULL == "STATIC_DUAL") begin
        reg    wr_prog_full_int;
        assign wr_prog_full  = wr_prog_full_int ? wr_datacount >= PROG_FULL_NEGATE : wr_datacount >= PROG_FULL_ASSERT;   

        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                wr_prog_full_int  <= 1'b0;
            end
            else begin
                wr_prog_full_int  <= wr_prog_full;
            end
        end              
    end
    else begin
        assign wr_prog_full  = 1'b0; 
    end
        
    if (PROGRAMMABLE_EMPTY == "STATIC_SINGLE") begin
        reg    rd_prog_empty_int;
        assign rd_prog_empty  = rd_datacount <= PROG_EMPTY_ASSERT;
            
        always @ (posedge rclk or posedge rd_rst) begin
            if (rd_rst) begin
                rd_prog_empty_int <= 1'b1;
            end
            else begin
                rd_prog_empty_int <= rd_prog_empty;
            end
        end
    end
    else if (PROGRAMMABLE_EMPTY == "STATIC_DUAL") begin
        reg    rd_prog_empty_int;
        assign rd_prog_empty = rd_prog_empty_int ? (rd_datacount <= PROG_EMPTY_NEGATE) : (rd_datacount <= PROG_EMPTY_ASSERT);
            
        always @ (posedge rclk or posedge rd_rst) begin
            if (rd_rst) begin
                rd_prog_empty_int <= 1'b1;
            end
            else begin
                rd_prog_empty_int <= rd_prog_empty;
            end
        end  
    end
    else begin
        assign rd_prog_empty  = 1'b0; 
    end
    
    if (HANDSHAKE_FLAG) begin
        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                wr_ack <= 1'b0;
            end
            else begin
                // NIC
                //wr_ack <= wr_en_int & ~wr_overflow;
                wr_ack <= OVERFLOW_PROTECT ? wr_en_int & ~wr_overflow : wr_en_int;
            end
        end
    end

    if (OVERFLOW_PROTECT) begin
        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                wr_overflow <= 1'b0;
            end
            else if (we && wr_full) begin
                wr_overflow <= 1'b1;
            end
            else begin
                wr_overflow <= 1'b0;            
            end
        end
    end
    else if (HANDSHAKE_FLAG) begin
        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                wr_overflow <= 1'b0;
            end
            else begin
                wr_overflow <= we && wr_full ? 1'b1 : wr_overflow;
            end
        end
    end

    if (UNDERFLOW_PROTECT) begin     
        always @ (posedge rclk or posedge rd_rst) begin
            if (rd_rst) begin
                rd_underflow <= 1'b0;
            end
            else if (re && rd_empty) begin
                rd_underflow <= 1'b1;
            end
            else begin
                rd_underflow <= 1'b0;            
            end
        end
    end
    else if (HANDSHAKE_FLAG) begin
        always @ (posedge rclk or posedge rd_rst) begin
            if (rd_rst) begin
                rd_underflow <= 1'b0;
            end
            else begin
                rd_underflow <= re && rd_empty ? 1'b1 : rd_underflow;
            end
        end
    end
    
    localparam RATIO_WIDTH = (RADDR_WIDTH >= WADDR_WIDTH)? RADDR_WIDTH - WADDR_WIDTH : WADDR_WIDTH - RADDR_WIDTH;
    
    if (ASYM_WIDTH_RATIO < 4) begin
        assign wr_full          = (waddr_cntr[WADDR_WIDTH]^raddr_int[RADDR_WIDTH]) & (waddr_cntr[WADDR_WIDTH-1:0] == raddr_int[RADDR_WIDTH-1:RATIO_WIDTH]);
        assign rd_empty_int     = waddr_int[WADDR_WIDTH:0] == raddr_cntr[RADDR_WIDTH:RATIO_WIDTH];
        assign wr_datacount_int = waddr_cntr - (raddr_int/RAM_MUX_RATIO);
        assign rd_datacount_int = (waddr_int*RAM_MUX_RATIO)-raddr_cntr;
    end
    // NIC
    else if (ASYM_WIDTH_RATIO == 4) begin
        assign wr_full          = (waddr_cntr[WADDR_WIDTH]^raddr_int[RADDR_WIDTH]) & (waddr_cntr[WADDR_WIDTH-1:0] == raddr_int[RADDR_WIDTH-1:0]);
        assign rd_empty_int     = waddr_int[WADDR_WIDTH:0] == raddr_cntr[RADDR_WIDTH:0];
        assign wr_datacount_int = waddr_cntr - raddr_int;
        assign rd_datacount_int = waddr_int - raddr_cntr;
    end
    else begin
        assign wr_full          = (waddr_cntr[WADDR_WIDTH]^raddr_int[RADDR_WIDTH]) & (waddr_cntr[WADDR_WIDTH-1:RATIO_WIDTH] == raddr_int[RADDR_WIDTH-1:0]);
        // NIC
        //assign rd_empty_int     = (waddr_int- raddr_cntr*RAM_MUX_RATIO) < RAM_MUX_RATIO;
        assign rd_empty_int     = waddr_int[WADDR_WIDTH:RATIO_WIDTH] == raddr_cntr[RADDR_WIDTH:0];
        assign wr_datacount_int = waddr_cntr - (raddr_int*RAM_MUX_RATIO);
        assign rd_datacount_int = (waddr_int/RAM_MUX_RATIO)-raddr_cntr;
    end
endgenerate

always @ (posedge wclk or posedge wr_rst) begin
    if (wr_rst) begin
        waddr_cntr   <= 'h0;
    end
    else if (wr_en_int) begin
        waddr_cntr   <= waddr_cntr + 1'b1;
    end
end

always @ (posedge wclk or posedge wr_rst) begin
    if (wr_rst) begin
        waddr_cntr_r  <= 'h0;
    end
    else begin
        waddr_cntr_r  <= waddr_cntr;
    end
end

always @ (posedge rclk or posedge rd_rst) begin
    if (rd_rst) begin
        raddr_cntr   <= 'h0;
    end
    // NIC
    //else if (rd_en_int) begin
    else begin
        //raddr_cntr   <= raddr_cntr + 1'b1;
        //raddr_cntr   <= raddr_cntr + (re & ~rd_empty_int);
        raddr_cntr   <= ram_raddr;
    end
end
// NIC
assign ram_raddr = raddr_cntr + (UNDERFLOW_PROTECT ? re & ~rd_empty_int : re);


generate
    if (SYNC_CLK) begin : sync_clk
       if (MODE == "FWFT") begin
          assign waddr_int = waddr_cntr_r;
          assign raddr_int        = raddr_cntr;
       end
       else begin
          assign waddr_int        = waddr_cntr;
          assign raddr_int        = raddr_cntr;
       end
    end
    else begin : async_clk
        reg  [RADDR_WIDTH:0] raddr_cntr_gry_r;
        reg  [WADDR_WIDTH:0] waddr_cntr_gry_r;
        
        wire [RADDR_WIDTH:0] raddr_cntr_gry;
        wire [RADDR_WIDTH:0] raddr_cntr_gry_sync;
        wire [RADDR_WIDTH:0] raddr_cntr_sync_g2b;
        wire [WADDR_WIDTH:0] waddr_cntr_gry;
        wire [WADDR_WIDTH:0] waddr_cntr_gry_sync;
        wire [WADDR_WIDTH:0] waddr_cntr_sync_g2b;

        if (PIPELINE_REG) begin
            reg  [RADDR_WIDTH:0] raddr_cntr_sync_g2b_r;    
            reg  [WADDR_WIDTH:0] waddr_cntr_sync_g2b_r;        
        
            assign waddr_int        = waddr_cntr_sync_g2b_r;
            assign raddr_int        = raddr_cntr_sync_g2b_r;
            
            always @ (posedge wclk or posedge wr_rst) begin
                if (wr_rst) begin
                    raddr_cntr_sync_g2b_r <= 'h0;
                end
                else begin
                    raddr_cntr_sync_g2b_r <= raddr_cntr_sync_g2b;
                end
            end
            
            always @ (posedge rclk or posedge rd_rst) begin
                if (rd_rst) begin
                    waddr_cntr_sync_g2b_r <= 'h0;
                end
                else begin
                    waddr_cntr_sync_g2b_r <= waddr_cntr_sync_g2b;
                end
            end
        end
        else begin
            assign waddr_int        = waddr_cntr_sync_g2b;
            assign raddr_int        = raddr_cntr_sync_g2b;        
        end
      
        always @ (posedge rclk or posedge rd_rst) begin
            if (rd_rst) begin
                raddr_cntr_gry_r <= 'h0;
            end
            else begin
                raddr_cntr_gry_r <= raddr_cntr_gry;
            end
        end
        `IP_MODULE_NAME(efx_fifo_bin2gray) # (.WIDTH(RADDR_WIDTH+1)                                                               ) xrd2wr_bin2gray    (.bin_i(raddr_cntr), .gray_o(raddr_cntr_gry));
        `IP_MODULE_NAME(efx_asyncreg)      # (.ASYNC_STAGE(SYNC_STAGE), .WIDTH (RADDR_WIDTH+1), .ACTIVE_LOW(0), .OFF_ASSERTION (1)) xrd2wr_addr_sync   (.clk(wclk), .reset_n(wr_rst), .d_i(raddr_cntr_gry_r), .d_o(raddr_cntr_gry_sync));
        `IP_MODULE_NAME(efx_fifo_gray2bin) # (.WIDTH(RADDR_WIDTH+1)                                                               ) xrd2wr_gray2bin    (.gray_i(raddr_cntr_gry_sync), .bin_o(raddr_cntr_sync_g2b));
        
        always @ (posedge wclk or posedge wr_rst) begin
            if (wr_rst) begin
                waddr_cntr_gry_r <= 'h0;
            end
            else begin
                waddr_cntr_gry_r <= waddr_cntr_gry;
            end
        end        
        `IP_MODULE_NAME(efx_fifo_bin2gray) # (.WIDTH(WADDR_WIDTH+1)                                                               ) wr2rd_bin2gray  (.bin_i(waddr_cntr), .gray_o(waddr_cntr_gry));
        `IP_MODULE_NAME(efx_asyncreg)      # (.ASYNC_STAGE(SYNC_STAGE), .WIDTH (WADDR_WIDTH+1), .ACTIVE_LOW(0), .OFF_ASSERTION (1)) wr2rd_addr_sync (.clk(rclk), .reset_n(rd_rst), .d_i(waddr_cntr_gry_r), .d_o(waddr_cntr_gry_sync));
        `IP_MODULE_NAME(efx_fifo_gray2bin) # (.WIDTH(WADDR_WIDTH+1)                                                               ) wr2rd_gray2bin  (.gray_i(waddr_cntr_gry_sync), .bin_o(waddr_cntr_sync_g2b));        

    end
endgenerate
endmodule


////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   bin2gray.v
//       / / .'     /    
//    __/ /.'      /     Description:
//   __   \       /      Binary to Gray Encoding Convertor
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************

`resetall
`timescale 1ns/1ps

module `IP_MODULE_NAME(efx_fifo_bin2gray)
#(parameter WIDTH=5)
(// outputs
 output wire [WIDTH-1:0] gray_o,
 // input
 input [WIDTH-1:0] bin_i
 );

//---------------------------------------------------------------------
// Function :   bit_xor
// Description: reduction xor
function bit_xor (
  input [31:0] nex_bit,
  input [31:0] curr_bit,
  input [WIDTH-1:0] xor_in);
  begin : fn_bit_xor
    bit_xor = xor_in[nex_bit] ^ xor_in[curr_bit];
  end
endfunction

// Convert Binary to Gray, bit by bit
generate 
begin
  genvar bit_idx;
  for(bit_idx=0; bit_idx<WIDTH-1; bit_idx=bit_idx+1) begin : gBinBits
    assign gray_o[bit_idx] = bit_xor(bit_idx+1, bit_idx, bin_i);
  end
  assign   gray_o[WIDTH-1] = bin_i[WIDTH-1];
end
endgenerate

endmodule 

////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013-2020 Efinix Inc. All rights reserved.              
//
// This   document  contains  proprietary information  which   is        
// protected by  copyright. All rights  are reserved.  This notice       
// refers to original work by Efinix, Inc. which may be derivitive       
// of other work distributed under license of the authors.  In the       
// case of derivative work, nothing in this notice overrides the         
// original author's license agreement.  Where applicable, the           
// original license agreement is included in it's original               
// unmodified form immediately below this header.                        
//
// WARRANTY DISCLAIMER.                                                  
//     THE  DESIGN, CODE, OR INFORMATION ARE PROVIDED “AS IS” AND        
//     EFINIX MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH               
//     RESPECT THERETO, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES,  
//     INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF          
//     MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR    
//     PURPOSE.  SOME STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED       
//     WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE.           
//
// LIMITATION OF LIABILITY.                                              
//     NOTWITHSTANDING ANYTHING TO THE CONTRARY, EXCEPT FOR BODILY       
//     INJURY, EFINIX SHALL NOT BE LIABLE WITH RESPECT TO ANY SUBJECT    
//     MATTER OF THIS AGREEMENT UNDER TORT, CONTRACT, STRICT LIABILITY   
//     OR ANY OTHER LEGAL OR EQUITABLE THEORY (I) FOR ANY INDIRECT,      
//     SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES OF ANY    
//     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF      
//     GOODWILL, DATA OR PROFIT, WORK STOPPAGE, OR COMPUTER FAILURE OR   
//     MALFUNCTION, OR IN ANY EVENT (II) FOR ANY AMOUNT IN EXCESS, IN    
//     THE AGGREGATE, OF THE FEE PAID BY LICENSEE TO EFINIX HEREUNDER    
//     (OR, IF THE FEE HAS BEEN WAIVED, $100), EVEN IF EFINIX SHALL HAVE 
//     BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO 
//     NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR            
//     CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT   
//     APPLY TO LICENSEE.
//
////////////////////////////////////////////////////////////////////////////////


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AccExdwXlzGguk8A5/EQLRHz5rryY1WQDwV6tuVPs5/Qxrh9gVqa2q4cF4IFnUFp
Dbbd3yNYKmh6qrpl0qXTbn9RPH/P+iNeLpi6t9M0Gq/qSduDwjoyJbsX1qGnatWW
CjK1gfimwERYxGKRPHDSOy7R+9JSnx4A6HuOple3G1mRVkD49PwNhxU2zpo5IY/v
xyvY349g1810u0d4ifYrne+cKPsjalFLLV6aMrNyqvh0uY4z3b5AXUuYlMPuEjvp
CHO1vsCf+9AOqbJ4a8jRjcKiAI16hNFxITHF1RzAxamdmQRamfVSp7pAL/iY6jYV
h3CT1FUJIyV6vX3pLvMMDQ==
//pragma protect end_key_block
//pragma protect digest_block
DEMb2F1lj6rEM07ieIbuGv0NXlk=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 30225 characters]
aKwwwwdorBlouOyfdbFG/h6cU7XSeVN9UTODlUEZquM=
//pragma protect end_data_block
//pragma protect digest_block
ttN5oYHd8WkRTKPQ4gjy7ImfYSw=
//pragma protect end_digest_block
//pragma protect end_protected


module `IP_MODULE_NAME(mii_if) #(
   parameter NO_PREAMBLE = 0
) (
//Globle Signals
input                           tx_mac_aclk,
output  reg                     tx_mac_aclk_en,
input                           tx_reset,
output  wire                    rx_mac_aclk,
output  reg                     rx_mac_aclk_en,
input                           rx_reset,
//Configuration Signals
input           [2:0]           eth_speed,
//GMII Interface
output  reg     [7:0]           gm_rx_d,
output  reg                     gm_rx_dv,
output  reg                     gm_rx_err,
input           [7:0]           gm_tx_d,
input                           gm_tx_en,
input                           gm_tx_err,
//MII Interface
input                           mii_txc,
output  reg     [3:0]           mii_txd,
output  reg                     mii_tx_dv,
output  reg                     mii_tx_err,

input                           mii_rxc,
input           [3:0]           mii_rxd,
input                           mii_rx_dv,
input                           mii_rx_err

//Status and  Error Signals
);
// Parameter Define 
//localparam                      SPEED_100M_DIV = (TX_REFCLK == 125) ? 10 : 2;
//localparam                      SPEED_10M_DIV  = SPEED_100M_DIV*10;
//localparam                      SPEED_CLK_DIV = (TX_REFCLK == 125) ? SPEED_100M_DIV/2 + 1 : 0 ;
// Register Define 
reg     [6:0]                   aclk_en_cnt;
reg     [3:0]                   txd;
reg                             tx_en;
reg                             tx_er;
reg                             rx_dv_pre;
reg                             rx_dv_dl1;
reg     [3:0]                   rxd_pre;
reg     [3:0]                   rxd_dl1;
reg                             rx_odd_data_ptr;
reg     [3:0]                   rxd;
reg                             rx_dv;
reg                             rx_er;
reg     [3:0]                   gm_tx_d_h;
reg     [7:0]                   gm_tx_d_r;
reg                             gm_tx_en_r;
reg                             gm_tx_err_r;
reg                             preamble_flg;
reg     [1:0]                   cur_st;
reg     [1:0]                   nxt_st;
reg                             add_preamble;


// Wire Define
wire                            add_preamble_w;

assign add_preamble_w = mii_rxd == 4'hd && mii_rx_dv && !mii_rx_err && cur_st == 2'b01 && preamble_flg;

/*----------------------------------------------------------------------------------*\
                                 The main code
\*----------------------------------------------------------------------------------*/

/*----------------------- Tx Region ----------------------------*/

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_mac_aclk_en <= 1'b0;
   else
      tx_mac_aclk_en <= ~tx_mac_aclk_en;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      gm_tx_d_r <= 8'h0;
   else if ((gm_tx_en == 1'b1) && (tx_mac_aclk_en == 1'b1))
      gm_tx_d_r <= gm_tx_d;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      gm_tx_en_r <= 1'b0;
   else if (tx_mac_aclk_en == 1'b1)
      gm_tx_en_r <= gm_tx_en;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      gm_tx_err_r <= 1'b0;
   else if (tx_mac_aclk_en == 1'b1)
      gm_tx_err_r <= gm_tx_err;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      txd <= 4'h0;
   else if (gm_tx_en_r == 1'b1) begin
      if (tx_mac_aclk_en == 1'b0)
          txd <= gm_tx_d_r[3:0];
      else
          txd <= gm_tx_d_r[7:4];
   end
   else;    
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       tx_en <= 1'b0;
   else 
       tx_en <= gm_tx_en_r;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       tx_er <= 1'b0;
   else 
       tx_er <= gm_tx_err_r;
end

always @ (posedge mii_txc or posedge tx_reset) begin 
   if (tx_reset == 1'b1) begin
      mii_tx_dv  <= 1'b0;
      mii_txd    <= 4'h0;
      mii_tx_err <= 1'b0;
   end
   else begin
      mii_tx_dv  <= tx_en;
      mii_txd    <= txd[3:0];
      mii_tx_err <= tx_er;
   end
end
/*----------------------- Rx Region ----------------------------*/
always @ (posedge mii_rxc or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      rxd   <= 4'h0;
      rx_dv <= 1'b0;
      rx_er <= 1'b0;
   end
   else if (add_preamble_w && NO_PREAMBLE != 1) begin
      rxd   <= 4'h5;
      rx_dv <= 1'b1;
      rx_er <= rx_er;
   end
   else if (add_preamble && NO_PREAMBLE != 1) begin
      rxd   <= rxd_pre;
      rx_dv <= rx_dv_pre;
      rx_er <= rx_er;
   end
   else begin
      rxd   <= mii_rxd;
      rx_dv <= mii_rx_dv;
      rx_er <= mii_rx_err;
   end
end

assign rx_mac_aclk = mii_rxc;

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      rxd_pre <= 4'h0;
      rx_dv_pre <= 1'b0;
   end
   else if (add_preamble_w || add_preamble) begin
      rxd_pre <= mii_rxd;
      rx_dv_pre <= mii_rx_dv;
   end
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
    if (rx_reset == 1'b1)
       add_preamble <= 1'b0;
    else if (add_preamble_w)
       add_preamble <= 1'b1;
    else if (!mii_rx_dv)
       add_preamble <= 1'b0;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_mac_aclk_en <= 1'b0;
   else
      rx_mac_aclk_en <= ~rx_mac_aclk_en;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      cur_st <= 2'b00;
   end
   else begin
      cur_st <= nxt_st;
   end
end

always @ (*) begin
   case (cur_st)
      2'b00: begin
         if (mii_rxd == 4'h5 && mii_rx_dv && !mii_rx_err)
            nxt_st = 2'b01;
         else
            nxt_st = 2'b00;
      end
      2'b01: begin
         if (mii_rxd == 4'hd && mii_rx_dv && !mii_rx_err)
            nxt_st = 2'b10;
         else if (mii_rxd == 4'h5 && mii_rx_dv && !mii_rx_err)
            nxt_st = 2'b01;
         else 
            nxt_st = 2'b00;
      end
      2'b10: begin
         if (mii_rx_dv) 
            nxt_st = 2'b10;
         else
            nxt_st = 2'b00;
         end
      default: nxt_st = 2'b00;
   endcase
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      preamble_flg <= 1'b0;
   end
   else if (mii_rxd == 4'h5 && mii_rx_dv && !mii_rx_err && cur_st == 2'b01) begin
      preamble_flg <= ~preamble_flg;
   end
   else begin
      preamble_flg <= 1'b0;
   end
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      rx_dv_dl1 <= 1'b0;
      rxd_dl1   <= 4'h0;
   end
   else begin
      rx_dv_dl1 <= rx_dv;
      rxd_dl1   <= rxd;
   end
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      gm_rx_dv <= 1'b0;
   else
      gm_rx_dv <= rx_dv_dl1;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_odd_data_ptr <= 1'b0;
   else if (rx_dv == 1'b0)
      rx_odd_data_ptr <= 1'b0;
   else
      rx_odd_data_ptr <= ~rx_odd_data_ptr;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      gm_rx_d <= 8'h0;
   else if ((rx_dv == 1'b1) && (rx_odd_data_ptr == 1'b1))
      gm_rx_d <= {rxd[3:0], rxd_dl1[3:0]};
   else;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
       gm_rx_err <= 1'b0;
   else begin
      if (rx_er == 1'b1)               gm_rx_err <= 1'b1;
      else if (rx_mac_aclk_en == 1'b1) gm_rx_err <= 1'b0;
   end
end


endmodule



/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   
//       / / .'     /    
//    __/ /.'      /     
//   __   \       /      
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************

module `IP_MODULE_NAME(rgmii_if)#(
    parameter                       RGMII_SYNC_EN = 1
) (
   //Globle Signals
   input                           tx_mac_aclk,
   output  reg                     tx_mac_aclk_en,
   input                           tx_reset,
   output  wire                    rx_mac_aclk,
   output  reg                     rx_mac_aclk_en,
   input                           rx_reset,
   //Configuration Signals
   input           [2:0]           eth_speed,
   input                           rgmii_rxc_edge,//0:DDIO Rising Edge; 1:DDIO Falling Edge; 
   input                           rgmii_txc_dly,//0:rgmii tx clock delay disable; 1:rgmii tx clock delay enable;
   //GMII Interface
   output  reg     [7:0]           gm_rx_d,
   output  reg                     gm_rx_dv,
   output  reg                     gm_rx_err,
   input           [7:0]           gm_tx_d,
   input                           gm_tx_en,
   input                           gm_tx_err,
   //RGMII Interface
   output  wire    [3:0]           rgmii_txd_HI,
   output  wire    [3:0]           rgmii_txd_LO,
   output  wire                    rgmii_tx_ctl_HI,
   output  wire                    rgmii_tx_ctl_LO,
   output  wire                    rgmii_txc_HI,//if rgmii_txc_dly set 0, used clk_125m clock. if rgmii_txc_dly set 1, used clk_125m_90deg clock.
   output  wire                    rgmii_txc_LO,
   input           [3:0]           rgmii_rxd_HI,
   input           [3:0]           rgmii_rxd_LO,
   input                           rgmii_rx_ctl_HI,
   input                           rgmii_rx_ctl_LO,
   input                           rgmii_rxc
   //Status and  Error Signals
);

// Parameter Define 

// Register Define 
reg     [6:0]                   aclk_en_cnt;
reg     [7:0]                   txd;
reg                             tx_en;
reg                             tx_er;
reg     [1:0]                   txc;
reg                             rx_dv_dl1;
reg     [7:0]                   rxd_dl1;
reg                             rx_odd_data_ptr;

// Wire Define
wire                            rx_dv;
wire    [7:0]                   rxd;
wire                            rx_er;

/*----------------------------------------------------------------------------------*\
                                 The main code
\*----------------------------------------------------------------------------------*/
/*----------------------- Tx Region ----------------------------*/
always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      aclk_en_cnt <= 7'd0;
   else if ((eth_speed == 3'h4) ||
           ((eth_speed == 3'h2) && (aclk_en_cnt == 7'd9)) ||
           ((eth_speed == 3'h1) && (aclk_en_cnt == 7'd99)))
      aclk_en_cnt <= 7'd0;
   else
      aclk_en_cnt <= aclk_en_cnt + 1'b1;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_mac_aclk_en <= 1'b0;
   else if (aclk_en_cnt == 7'd0)
      tx_mac_aclk_en <= 1'b1;
   else
      tx_mac_aclk_en <= 1'b0;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      txd[7:4] <= 4'h0;
   else if((gm_tx_en == 1'b1) && (tx_mac_aclk_en == 1'b1))
      txd[7:4] <= gm_tx_d[7:4];
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      txd[3:0] <= 4'h0;
   else if ((gm_tx_en == 1'b1) && (tx_mac_aclk_en == 1'b1))
      txd[3:0] <= gm_tx_d[3:0];
   else if (((eth_speed == 3'h2) && (aclk_en_cnt == 7'd6)) ||
            ((eth_speed == 3'h1) && (aclk_en_cnt == 7'd51)))
      txd[3:0] <= txd[7:4];
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_en <= 1'b0;
   else if (tx_mac_aclk_en == 1'b1)
      tx_en <= gm_tx_en;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_er <= 1'b0;
   else if (tx_mac_aclk_en == 1'b1)
      tx_er <= gm_tx_err;
end
/*
always @(posedge tx_mac_aclk or posedge tx_reset)
begin
    if(tx_reset == 1'b1)
        txc <= 2'b0;
    else
        case(eth_speed)
        3'h4 :
            txc <= 2'b01;
        3'h2 :
            case(rgmii_txc_dly)
            1'b0 ://rgmii tx clock delay disable.
                if((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd5))
                    txc <= 2'b11;
                else if((aclk_en_cnt == 7'd3) || (aclk_en_cnt == 7'd8))
                    txc <= 2'b00;
            1'b1 ://rgmii tx clock delay enable.
                if((aclk_en_cnt == 7'd2) || (aclk_en_cnt == 7'd7))
                    txc <= 2'b11;
                else if((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd5))
                    txc <= 2'b00;
            endcase
        3'h1 :
            case(rgmii_txc_dly)
            1'b0 ://rgmii tx clock delay disable.
                if((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd50))
                    txc <= 2'b11;
                else if((aclk_en_cnt == 7'd25) || (aclk_en_cnt == 7'd75))
                    txc <= 2'b00;
            1'b1 ://rgmii tx clock delay enable.
                if((aclk_en_cnt == 7'd13) || (aclk_en_cnt == 7'd63))
                    txc <= 2'b11;
                else if((aclk_en_cnt == 7'd38) || (aclk_en_cnt == 7'd88))
                    txc <= 2'b00;
            endcase
        default :
            txc <= 2'b0;
        endcase
end

*/
reg [1:0]    txc_100m_r;
reg [1:0]    txc_10m_r;

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       txc_100m_r <= 2'b0;
   else begin
       case(rgmii_txc_dly)
          1'b0 : //rgmii tx clock delay disable.
             if ((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd5))
                txc_100m_r <= 2'b11;
             else if ((aclk_en_cnt == 7'd3) || (aclk_en_cnt == 7'd8))
                txc_100m_r <= 2'b00;
          1'b1 ://rgmii tx clock delay enable.
             if ((aclk_en_cnt == 7'd2) || (aclk_en_cnt == 7'd7))
                txc_100m_r <= 2'b11;
             else if ((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd5))
                txc_100m_r <= 2'b00;
       endcase
   end
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       txc_10m_r <= 2'b0;
   else begin
       case(rgmii_txc_dly)
       1'b0 ://rgmii tx clock delay disable.
           if((aclk_en_cnt == 7'd0) || (aclk_en_cnt == 7'd50))
               txc_10m_r <= 2'b11;
           else if((aclk_en_cnt == 7'd25) || (aclk_en_cnt == 7'd75))
               txc_10m_r <= 2'b00;
       1'b1 ://rgmii tx clock delay enable.
           if((aclk_en_cnt == 7'd13) || (aclk_en_cnt == 7'd63))
               txc_10m_r <= 2'b11;
           else if((aclk_en_cnt == 7'd38) || (aclk_en_cnt == 7'd88))
               txc_10m_r <= 2'b00;
       endcase
   end
end

always @(posedge tx_mac_aclk or posedge tx_reset)
begin
    if(tx_reset == 1'b1)
        txc <= 2'b0;
    else
        case(eth_speed)
            3'h4 :
                txc <= 2'b01;
            3'h2 :
                txc <= txc_100m_r;
            3'h1 :
                txc <= txc_10m_r;
            default :
                txc <= 2'b0;
        endcase
end

/*----------------------- Rx Region ----------------------------*/
assign rx_mac_aclk = rgmii_rxc;

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        rx_mac_aclk_en <= 1'b0;
    else if(eth_speed[2] == 1'b1)
        rx_mac_aclk_en <= 1'b1;
    else
        rx_mac_aclk_en <= ~rx_mac_aclk_en;
end

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        begin
            rx_dv_dl1 <= 1'b0;
            rxd_dl1 <= 8'h0;
        end
    else
        begin
            rx_dv_dl1 <= rx_dv;
            rxd_dl1 <= rxd;
        end
end

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        gm_rx_dv <= 1'b0;
    else
        gm_rx_dv <= rx_dv_dl1;
end

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        rx_odd_data_ptr <= 1'b0;
    else if(rx_dv == 1'b0)
        rx_odd_data_ptr <= 1'b0;
    else
        rx_odd_data_ptr <= ~rx_odd_data_ptr;
end

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        gm_rx_d <= 8'h0;
    else
        begin
            if((eth_speed[2] == 1'b1) && (rx_dv_dl1 == 1'b1))
                gm_rx_d <= rxd_dl1;
            else if((rx_dv == 1'b1) && (rx_odd_data_ptr == 1'b1))
                gm_rx_d <= {rxd[3:0],rxd_dl1[3:0]};
        end
end

always @(posedge rx_mac_aclk or posedge rx_reset)
begin
    if(rx_reset == 1'b1)
        gm_rx_err <= 1'b0;
    else
        begin
            if(rx_er == 1'b1)
                gm_rx_err <= 1'b1;
            else if(rx_mac_aclk_en == 1'b1)
                gm_rx_err <= 1'b0;
        end
end

/*----------------------- PHY Interface ----------------------------*/
`IP_MODULE_NAME(rgmii) #(
    .RGMII_SYNC_EN                      (RGMII_SYNC_EN                      )
)
u_rgmii
(
//Globle Signals
    .tx_mac_aclk                        (tx_mac_aclk                        ),
    .tx_reset                           (tx_reset                           ),
    .rx_reset                           (rx_reset                           ),
//Configuration Signals
    .eth_speed                          (eth_speed                          ),
    .rgmii_rxc_edge                     (rgmii_rxc_edge                     ),
//Phy Interface
    .txd                                (txd                                ),
    .tx_en                              (tx_en                              ),
    .tx_er                              (tx_er                              ),
    .txc                                (txc                                ),
    .rxd                                (rxd                                ),
    .rx_dv                              (rx_dv                              ),
    .rx_er                              (rx_er                              ),
//RGMII Interface
    .rgmii_txd_HI                       (rgmii_txd_HI                       ),
    .rgmii_txd_LO                       (rgmii_txd_LO                       ),
    .rgmii_tx_ctl_HI                    (rgmii_tx_ctl_HI                    ),
    .rgmii_tx_ctl_LO                    (rgmii_tx_ctl_LO                    ),
    .rgmii_txc_HI                       (rgmii_txc_HI                       ),
    .rgmii_txc_LO                       (rgmii_txc_LO                       ),
    .rgmii_rxd_HI                       (rgmii_rxd_HI                       ),
    .rgmii_rxd_LO                       (rgmii_rxd_LO                       ),
    .rgmii_rx_ctl_HI                    (rgmii_rx_ctl_HI                    ),
    .rgmii_rx_ctl_LO                    (rgmii_rx_ctl_LO                    ),
    .rgmii_rxc                          (rgmii_rxc                          )
);

endmodule


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   
//       / / .'     /    
//    __/ /.'      /     
//   __   \       /      
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************
module `IP_MODULE_NAME(rgmii_sync)
(
//Globle Signals
input                           rgmii_rxc,
input                           rx_reset,
input           [2:0]           eth_speed,
//RGMII Rx Interface Input
input           [3:0]           rgmii_rxd_HI_i,
input           [3:0]           rgmii_rxd_LO_i,
input                           rgmii_rx_ctl_HI_i,
input                           rgmii_rx_ctl_LO_i,
//RGMII Rx Interface Output
output  reg     [3:0]           rgmii_rxd_HI_o,
output  reg     [3:0]           rgmii_rxd_LO_o,
output  reg                     rgmii_rx_ctl_HI_o,
output  reg                     rgmii_rx_ctl_LO_o
);


// Parameter Define 
parameter State_idle     = 2'd0;
parameter State_preamble = 2'd1;
parameter State_data_dl1 = 2'd2;
parameter State_data_dl2 = 2'd3;


// Register Define 
reg     [1:0]                   cur_state;
reg     [1:0]                   next_state;
reg                             preamble_odd;
reg     [3:0]                   rx_d_dl1;
reg                             rx_dv_dl1;
reg     [3:0]                   rx_d_dl2;
reg                             rx_dv_dl2;

// Wire Define

/*----------------------------------------------------------------------------------*\
                                 The main code
\*----------------------------------------------------------------------------------*/

always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset) begin
      rx_d_dl1      <= 4'h0;
      rx_dv_dl1     <= 1'b0;
      rx_d_dl2      <= 4'h0;
      rx_dv_dl2     <= 1'b0;
   end
   else begin
      rx_d_dl1      <= rgmii_rxd_LO_i;
      rx_dv_dl1     <= rgmii_rx_ctl_HI_i;
      rx_d_dl2      <= rx_d_dl1;
      rx_dv_dl2     <= rx_dv_dl1;
   end
end

/*----------------------- FSM Region ----------------------------*/
always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset) cur_state <= State_idle;
	else          cur_state <= next_state;
end

always @ (*) begin
	case (cur_state)
      State_idle :
         if ((rx_dv_dl1 == 1'b1) && (rx_d_dl1 == 4'h5))
             next_state = State_preamble;
         else
             next_state = State_idle;

      State_preamble : 
         if (rx_dv_dl1 == 1'b0)
            next_state = State_idle;
         else if ((rx_d_dl1 == 4'hd) && (preamble_odd == 1'b0))
            next_state = State_data_dl1;
         else if ((rx_d_dl1 == 4'hd) && (preamble_odd == 1'b1))
            next_state = State_data_dl2;
         else if (rx_d_dl1 != 4'h5)
            next_state = State_idle;
         else
            next_state = State_preamble;
          
      State_data_dl1 :
         if (rx_dv_dl1 == 1'b0)
            next_state = State_idle;
         else
            next_state = State_data_dl1;

      State_data_dl2 :
         if (rx_dv_dl2 == 1'b0)
            next_state = State_idle;
         else
            next_state = State_data_dl2;

      default :
         next_state = State_idle;
    endcase
end

always @ (posedge rgmii_rxc or posedge rx_reset) begin
    if (rx_reset) 
       preamble_odd <= 1'b0;
    else if (cur_state == State_preamble)
       preamble_odd <= ~preamble_odd;
    else
       preamble_odd <= 1'b0;
end

/*----------------------- Sync Output Region ----------------------------*/

always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset)
      rgmii_rxd_LO_o <= 4'h0;
   else if (eth_speed[2] == 1'b1)
      rgmii_rxd_LO_o <= rgmii_rxd_LO_i;
   else if ((cur_state == State_preamble) && (rx_d_dl1 == 4'hd) && (preamble_odd == 1'b1))
      rgmii_rxd_LO_o <= 4'h5;
   else if (cur_state == State_data_dl2)
      rgmii_rxd_LO_o <= rx_d_dl2;
   else
      rgmii_rxd_LO_o <= rx_d_dl1;
end

always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset) 
      rgmii_rxd_HI_o <= 4'h0;
   else if (eth_speed[2] == 1'b1)
      rgmii_rxd_HI_o <= rgmii_rxd_HI_i;
   else
      rgmii_rxd_HI_o <= 4'h0;
end

always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset)
      rgmii_rx_ctl_HI_o <= 1'b0;
   else if (eth_speed[2] == 1'b1)
      rgmii_rx_ctl_HI_o <= rgmii_rx_ctl_HI_i;
   else if ((cur_state == State_preamble) && (rx_d_dl1 == 4'hd) && (preamble_odd == 1'b1))
      rgmii_rx_ctl_HI_o <= 1'b1;
   else if (cur_state == State_data_dl2)
      rgmii_rx_ctl_HI_o <= rx_dv_dl2;
   else
      rgmii_rx_ctl_HI_o <= rx_dv_dl1;
end

always @(posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset)
      rgmii_rx_ctl_LO_o <= 1'b0;
   else if (eth_speed[2] == 1'b1)
      rgmii_rx_ctl_LO_o <= rgmii_rx_ctl_LO_i;
   else if ((cur_state == State_preamble) && (rx_d_dl1 == 4'hd) && (preamble_odd == 1'b1))
      rgmii_rx_ctl_LO_o <= 1'b1;
   else if (cur_state == State_data_dl2)
      rgmii_rx_ctl_LO_o <= rx_dv_dl2;
   else
      rgmii_rx_ctl_LO_o <= rx_dv_dl1;
end

endmodule


/////////////////////////////////////////////////////////////////////////////
//           _____       
//          / _______    Copyright (C) 2013-2020 Efinix Inc. All rights reserved.
//         / /       \   
//        / /  ..    /   
//       / / .'     /    
//    __/ /.'      /     
//   __   \       /      
//  /_/ /\ \_____/ /     
// ____/  \_______/      
//
// *******************************
// Revisions:
// 1.0 Initial rev
//
// *******************************

module `IP_MODULE_NAME(rgmii) #(
    parameter                   RGMII_SYNC_EN = 1
) (
   //Globle Signals
   input                        tx_mac_aclk,
   input                        tx_reset,
   input                        rx_reset,
   //Configuration Signals
   input           [2:0]        eth_speed,
   input                        rgmii_rxc_edge, //0:DDIO Rising Edge; 1:DDIO Falling Edge; 
   //Phy Interface
   input           [7:0]        txd,
   input                        tx_en,
   input                        tx_er,
   input           [1:0]        txc, //if rgmii_txc_dly set 0, used clk_125m clock. if rgmii_txc_dly set 1, used clk_125m_90deg clock.
   output  reg     [7:0]        rxd,
   output  reg                  rx_dv,
   output  reg                  rx_er,
   //RGMII Interface
   output  reg     [3:0]        rgmii_txd_HI,
   output  reg     [3:0]        rgmii_txd_LO,
   output  reg                  rgmii_tx_ctl_HI,
   output  reg                  rgmii_tx_ctl_LO,
   output  reg                  rgmii_txc_HI,
   output  reg                  rgmii_txc_LO,
   input           [3:0]        rgmii_rxd_HI,
   input           [3:0]        rgmii_rxd_LO,
   input                        rgmii_rx_ctl_HI,
   input                        rgmii_rx_ctl_LO,
   input                        rgmii_rxc
   //Status and  Error Signals
);
// Parameter Define 

// Register Define 
reg     [3:0]                   rgmii_rxd_HI_d1;
reg                             rgmii_rx_ctl_HI_d1;
reg     [3:0]                   rgmii_txd_HI_r;
reg     [3:0]                   rgmii_txd_LO_r;
reg                             rgmii_tx_ctl_HI_r;
reg                             rgmii_tx_ctl_LO_r;
reg                             rgmii_txc_HI_r;
reg                             rgmii_txc_LO_r;
// Wire Define
wire                            tx_en_to_ddr;
wire                            rgmii_tx_ctl_int;
wire    [3:0]                   txd_falling;
/*----------------------------------------------------------------------------------*\
                                 The main code
\*----------------------------------------------------------------------------------*/

/*----------------------- RGMII Tx Region ----------------------------*/
assign tx_en_to_ddr = (eth_speed[2] == 1'b1) ? tx_en : tx_en && (!tx_er);
assign rgmii_tx_ctl_int = tx_en ^ tx_er;

assign txd_falling = (eth_speed[2] == 1'b1) ? txd[7:4] : txd[3:0];

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset) begin
      rgmii_txc_HI_r    <= 1'b0;
      rgmii_txc_LO_r    <= 1'b0;
      rgmii_tx_ctl_HI_r <= 1'b0;
      rgmii_tx_ctl_LO_r <= 1'b0;
      rgmii_txd_HI_r    <= 4'b0;
      rgmii_txd_LO_r    <= 4'b0;
   end 
   else begin
      rgmii_txc_HI_r    <= txc[0];
      rgmii_txc_LO_r    <= txc[1];     
      rgmii_tx_ctl_HI_r <= tx_en_to_ddr;
      rgmii_tx_ctl_LO_r <= rgmii_tx_ctl_int;
      rgmii_txd_HI_r    <= txd[3:0];
      rgmii_txd_LO_r    <= txd_falling;
   end
end


always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset) begin
      rgmii_txc_HI    <= 1'b0;
      rgmii_txc_LO    <= 1'b0;
      rgmii_tx_ctl_HI <= 1'b0;
      rgmii_tx_ctl_LO <= 1'b0;
      rgmii_txd_HI    <= 4'b0;
      rgmii_txd_LO    <= 4'b0;
   end
   else begin
      rgmii_txc_HI    <= rgmii_txc_HI_r;
      rgmii_txc_LO    <= rgmii_txc_LO_r;
      rgmii_tx_ctl_HI <= rgmii_tx_ctl_HI_r;
      rgmii_tx_ctl_LO <= rgmii_tx_ctl_LO_r;
      rgmii_txd_HI    <= rgmii_txd_HI_r;
      rgmii_txd_LO    <= rgmii_txd_LO_r;
   end
end

/*----------------------- RGMII Rx Region ----------------------------*/
//rgmii_rxd & rgmii_rx_ctl
always @ (posedge rgmii_rxc or posedge rx_reset) begin
   if (rx_reset) begin
      rgmii_rxd_HI_d1    <= 4'h0;
      rgmii_rx_ctl_HI_d1 <= 1'b0;
   end 
   else begin
      rgmii_rxd_HI_d1    <= rgmii_rxd_HI;
      rgmii_rx_ctl_HI_d1 <= rgmii_rx_ctl_HI;
   end
end

generate
   if (RGMII_SYNC_EN == 0) begin
      always @ (posedge rgmii_rxc or posedge rx_reset) begin
         if (rx_reset) begin
            rxd[7:4] <= 4'h0;
            rxd[3:0] <= 4'h0;
            rx_dv    <= 1'b0;
            rx_er    <= 1'b0;
         end
         else if (eth_speed[2] == 1'b1) begin //1000M
            if (rgmii_rxc_edge == 1'b0) begin //0:DDIO Rising Edge
               rxd[7:4] <= rgmii_rxd_LO;
               rxd[3:0] <= rgmii_rxd_HI_d1;
               rx_dv    <= rgmii_rx_ctl_HI_d1;
               rx_er    <= rgmii_rx_ctl_HI_d1^rgmii_rx_ctl_LO;
            end
            else begin//1:DDIO Falling Edge
               rxd[7:4] <= rgmii_rxd_HI;
               rxd[3:0] <= rgmii_rxd_LO;
               rx_dv    <= rgmii_rx_ctl_LO;
               rx_er    <= rgmii_rx_ctl_LO^rgmii_rx_ctl_HI;
            end
        end
        else begin //100M or 10M
           rxd[7:4] <= 4'b0;
           rxd[3:0] <= rgmii_rxd_LO;
           rx_dv    <= rgmii_rx_ctl_LO;
           rx_er    <= rgmii_rx_ctl_LO^rgmii_rx_ctl_HI_d1;
        end
     end
   end
   else begin
      reg  [3:0]  rgmii_rxd_HI_i;
      reg  [3:0]  rgmii_rxd_LO_i;
      reg         rgmii_rx_ctl_HI_i;
      reg         rgmii_rx_ctl_LO_i;
      wire [3:0]  rgmii_rxd_HI_sync;
      wire [3:0]  rgmii_rxd_LO_sync;
      wire        rgmii_rx_ctl_HI_sync;
      wire        rgmii_rx_ctl_LO_sync;

      always @ (posedge rgmii_rxc or posedge rx_reset) begin
         if (rx_reset) begin
            rgmii_rxd_HI_i    <= 4'h0;
            rgmii_rxd_LO_i    <= 4'h0;
            rgmii_rx_ctl_HI_i <= 1'b0;
            rgmii_rx_ctl_LO_i <= 1'b0;
         end
         else if (eth_speed[2] == 1'b1) begin //1000M
            if (rgmii_rxc_edge == 1'b0) begin //0:DDIO Rising Edge
               rgmii_rxd_HI_i    <= rgmii_rxd_LO;
               rgmii_rxd_LO_i    <= rgmii_rxd_HI_d1;
               rgmii_rx_ctl_HI_i <= rgmii_rx_ctl_HI_d1;
               rgmii_rx_ctl_LO_i <= rgmii_rx_ctl_LO;
            end
            else begin //1:DDIO Falling Edge
               rgmii_rxd_HI_i    <= rgmii_rxd_HI;
               rgmii_rxd_LO_i    <= rgmii_rxd_LO;
               rgmii_rx_ctl_HI_i <= rgmii_rx_ctl_HI;
               rgmii_rx_ctl_LO_i <= rgmii_rx_ctl_LO;
            end
         end        
         else begin//100M or 10M
            rgmii_rxd_HI_i    <= rgmii_rxd_HI_d1;
            rgmii_rxd_LO_i    <= rgmii_rxd_LO;
            rgmii_rx_ctl_HI_i <= rgmii_rx_ctl_LO;
            rgmii_rx_ctl_LO_i <= rgmii_rx_ctl_HI_d1;
         end
      end

      always @ (posedge rgmii_rxc or posedge rx_reset) begin
         if (rx_reset) begin
            rxd[7:4] <= 4'h0;
            rxd[3:0] <= 4'h0;
            rx_dv    <= 1'b0;
            rx_er    <= 1'b0;
         end
         else begin
            rxd[7:4] <= rgmii_rxd_HI_sync;
            rxd[3:0] <= rgmii_rxd_LO_sync;
            rx_dv    <= rgmii_rx_ctl_HI_sync;
            rx_er    <= rgmii_rx_ctl_HI_sync^rgmii_rx_ctl_LO_sync;
         end
      end
      
      /*----------------------- RGMII Rx Sync Module -----------------------*/
      `IP_MODULE_NAME(rgmii_sync) u_rgmii_sync
      (
      //Globle Signals
          .rgmii_rxc                  (rgmii_rxc                  ),
          .rx_reset                   (rx_reset                   ),
          .eth_speed                  (eth_speed                  ),
      //RGMII Rx Interface Input
          .rgmii_rxd_HI_i             (rgmii_rxd_HI_i             ),
          .rgmii_rxd_LO_i             (rgmii_rxd_LO_i             ),
          .rgmii_rx_ctl_HI_i          (rgmii_rx_ctl_HI_i          ),
          .rgmii_rx_ctl_LO_i          (rgmii_rx_ctl_LO_i          ),
      //RGMII Rx Interface Output
          .rgmii_rxd_HI_o             (rgmii_rxd_HI_sync          ),
          .rgmii_rxd_LO_o             (rgmii_rxd_LO_sync          ),
          .rgmii_rx_ctl_HI_o          (rgmii_rx_ctl_HI_sync       ),
          .rgmii_rx_ctl_LO_o          (rgmii_rx_ctl_LO_sync       )
      );
   end
endgenerate


endmodule


module `IP_MODULE_NAME(rmii_if)
(
//Globle Signals
input                           tx_mac_aclk,
output  reg                     tx_mac_aclk_en,
input                           tx_reset,
output  wire                    rx_mac_aclk,
output  reg                     rx_mac_aclk_en,
input                           rx_reset,
//Configuration Signals
input           [2:0]           eth_speed,
//GMII Interface
output  reg     [7:0]           gm_rx_d,
output  reg                     gm_rx_dv,
output  reg                     gm_rx_err,
input           [7:0]           gm_tx_d,
input                           gm_tx_en,
input                           gm_tx_err,
//RGMII Interface
input                           rmii_clk_ref,
output  reg     [1:0]           rmii_txd,
output  reg                     rmii_tx_en,

input           [1:0]           rmii_rxd,
input                           rmii_crs_dv,
input                           rmii_rx_err

//Status and  Error Signals
);
// Parameter Define 

// Register Define 
reg     [6:0]                   aclk_en_cnt;
reg     [6:0]                   rx_aclk_en_cnt;
reg     [1:0]                   txd;
reg                             tx_en;
reg                             tx_er;
reg                             rx_err_dl1;
reg                             rx_dv_dl1;
reg     [7:0]                   rxd_dl1;
reg     [6:0]                   rx_odd_data_ptr;
reg     [1:0]                   rxd;
reg                             rx_dv;
reg                             rx_er;
reg     [7:0]                   gm_tx_d_temp;
reg                             tx_en_temp;
reg     [6:0]                   txbit_cnt;
reg                             rx_dv_compensate;
reg                             rx_err_compensate;
reg                             rx_err_latch;
reg     [7:0]                   rx_d_compensate;
reg     [6:0]                   rx_compensate_cnt;
// Wire Define

/*----------------------------------------------------------------------------------*\
                                 The main code
\*----------------------------------------------------------------------------------*/

/*----------------------- Tx Region ----------------------------*/
always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      aclk_en_cnt <= 7'd0;
   else if (((eth_speed == 3'h2) && (aclk_en_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (aclk_en_cnt == 7'd39)))
      aclk_en_cnt <= 7'd0;
   else
      aclk_en_cnt <= aclk_en_cnt + 1'b1;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_mac_aclk_en <= 1'b0;
   else if (aclk_en_cnt == 7'd0)
      tx_mac_aclk_en <= 1'b1;
   else
      tx_mac_aclk_en <= 1'b0;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      gm_tx_d_temp <= 8'h0;
   else if ((gm_tx_en == 1'b1) && (tx_mac_aclk_en == 1'b1))
      gm_tx_d_temp <= gm_tx_d;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_en_temp <= 1'b0;
   else if(tx_mac_aclk_en == 1'b1)
      tx_en_temp <= gm_tx_en;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      txbit_cnt <= 7'd0;
   else if (((eth_speed == 3'h2) && (txbit_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (txbit_cnt == 7'd39)))
      txbit_cnt <= 7'd0;
   else if (tx_en_temp == 1'b1)
      txbit_cnt <= txbit_cnt + 1'b1;
   else
      txbit_cnt <= 7'd0; 
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       txd <= 2'h0;
   else if (eth_speed == 3'h2) begin
      case(txbit_cnt[1:0])
         2'b00: txd <= gm_tx_d_temp[1:0];
         2'b01: txd <= gm_tx_d_temp[3:2];
         2'b10: txd <= gm_tx_d_temp[5:4];
         2'b11: txd <= gm_tx_d_temp[7:6];
         default; 
      endcase 
   end 
   else if (eth_speed == 3'h1) begin
      case(txbit_cnt[5:0])
         6'd00: txd <= gm_tx_d_temp[1:0];
         6'd10: txd <= gm_tx_d_temp[3:2];
         6'd20: txd <= gm_tx_d_temp[5:4];
         6'd30: txd <= gm_tx_d_temp[7:6];
         default; 
      endcase 
   end
   else;    
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
      tx_en <= 1'b0;
   else 
      tx_en <= tx_en_temp;
end

always @ (posedge tx_mac_aclk or posedge tx_reset) begin
   if (tx_reset == 1'b1)
       tx_er <= 1'b0;
   else if (tx_mac_aclk_en == 1'b1)
       tx_er <= gm_tx_err;
end

always @ (posedge rmii_clk_ref or posedge tx_reset) begin 
   if (tx_reset == 1'b1) begin
      rmii_tx_en <= 1'b0;
      rmii_txd   <= 2'b0;
   end
   else begin
      rmii_tx_en  <= tx_en;
      rmii_txd    <= txd[1:0];
   end
end

/*----------------------- Rx Region ----------------------------*/
always @(posedge rmii_clk_ref or posedge rx_reset) begin
   if (rx_reset == 1'b1) begin
      rxd   <= 2'b00;
      rx_dv <= 1'b0;
      rx_er <= 1'b0;
   end
   else begin
      rxd   <= rmii_rxd;
      rx_dv <= rmii_crs_dv;
      rx_er <= rmii_rx_err;
   end
end

assign rx_mac_aclk = rmii_clk_ref;

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_aclk_en_cnt <= 7'd0;
   else if (((eth_speed == 3'h2) && (rx_aclk_en_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (rx_aclk_en_cnt == 7'd39)))
      rx_aclk_en_cnt <= 7'd0;
   else
      rx_aclk_en_cnt <= rx_aclk_en_cnt + 1'b1;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_mac_aclk_en <= 1'b0;
   else if (rx_aclk_en_cnt == 7'd0)
      rx_mac_aclk_en <= 1'b1;
   else
      rx_mac_aclk_en <= 1'b0;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_odd_data_ptr <= 7'd0;
   else if (((eth_speed == 3'h2) && (rx_odd_data_ptr == 7'd3)) ||
           ((eth_speed == 3'h1) && (rx_odd_data_ptr == 7'd39)) || (rx_dv == 1'b0))
      rx_odd_data_ptr <= 7'd0;
   else 
      rx_odd_data_ptr <= rx_odd_data_ptr + 1'b1;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_dv_dl1 <= 1'b0;
   else 
      rx_dv_dl1 <= rx_dv; 
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
       rx_err_dl1 <= 1'b0;
   else 
       rx_err_dl1 <= rx_er; 
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rxd_dl1 <= 8'h0;
   else if (eth_speed == 3'h2) begin
      case (rx_odd_data_ptr[1:0])
         2'b00: rxd_dl1[1:0] <= rxd;
         2'b01: rxd_dl1[3:2] <= rxd;
         2'b10: rxd_dl1[5:4] <= rxd;
         2'b11: rxd_dl1[7:6] <= rxd;
         default; 
      endcase 
   end 
   else if (eth_speed == 3'h1) begin
      case (rx_odd_data_ptr[5:0])
         6'd00: rxd_dl1[1:0] <= rxd;
         6'd10: rxd_dl1[3:2] <= rxd;
         6'd20: rxd_dl1[5:4] <= rxd;
         6'd30: rxd_dl1[7:6] <= rxd;
         default; 
      endcase 
   end
   else;    
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_compensate_cnt <= 7'b0;
   else if (rx_dv_dl1 == 1'b1)
      rx_compensate_cnt <= 7'b0;
   else if (((eth_speed == 3'h2) && (rx_compensate_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (rx_compensate_cnt == 7'd39)))
      rx_compensate_cnt <= rx_compensate_cnt;
   else
      rx_compensate_cnt <= rx_compensate_cnt + 1;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_dv_compensate <= 1'b0;
   else if (((eth_speed == 3'h2) && (rx_compensate_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (rx_compensate_cnt == 7'd39)))
      rx_dv_compensate <= 1'b0;
   else if ((rx_dv_dl1 == 1'b1) && rx_odd_data_ptr == 7'd0)
      rx_dv_compensate <= 1'b1;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
       rx_err_latch <= 1'b0;
   else begin
      if (rx_dv & rx_er)                rx_err_latch <= 1'b1;
      else if (rx_odd_data_ptr == 7'd0) rx_err_latch <= 1'b0; 
      else                              rx_err_latch <= rx_err_latch;
   end
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_err_compensate <= 1'b0;
   else if (((eth_speed == 3'h2) && (rx_compensate_cnt == 7'd3)) ||
           ((eth_speed == 3'h1) && (rx_compensate_cnt == 7'd39)))
      rx_err_compensate <= 1'b0;
   else if (rx_odd_data_ptr == 7'd0)
      rx_err_compensate <= rx_err_latch;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      rx_d_compensate <= 8'h0;
   else if ((rx_dv_dl1 == 1'b1) && rx_odd_data_ptr == 7'd0)
      rx_d_compensate <= rxd_dl1;
   else;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      gm_rx_dv <= 1'b0;
   else if (rx_mac_aclk_en == 1'b1)
      gm_rx_dv <= rx_dv_compensate;
end


always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      gm_rx_d <= 8'h0;
   else if (rx_mac_aclk_en == 1'b1)
      gm_rx_d <= rx_d_compensate;
   else;
end

always @ (posedge rx_mac_aclk or posedge rx_reset) begin
   if (rx_reset == 1'b1)
      gm_rx_err <= 1'b0;
   else if (rx_mac_aclk_en == 1'b1)
      gm_rx_err <= rx_err_compensate;
end

endmodule



//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AdUnj7Bs+hmJ5SGqEqyFUEEMiDRgSp0S2f/VGAUk5v91ubVm2vgtcT4UvOY8OQGq
A+wc8em2skYny3gLEXZmGWWY5M3IOrXXN3garTjgT/5aryDdctZKanGzUfDwK74W
DPdg+zD4MmzgiuU8eKz1ef52GhS+oY1Cc96fkAEweAh/3tvGasLmKHSIQ7ZCsxHI
uSU8DESy32ZzWcXDfpldgfIys4YE/sMJnzZ7g6U0deho5UWElUrJD9K61IXoClnb
PnZtzkA2AnB6RQkVnqyZ/M9paBgFFjA2jqUqJ26dmPzviIlJsf0wlEL8iXwtLh4z
t69l8BOBmXaHLSfmBmAxJw==
//pragma protect end_key_block
//pragma protect digest_block
ePVsN48yGEZh+oJ/8GPEgNrTsQ4=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 6825 characters]
JFlrPWMNU1mbpeNa6fDHvei4fFx8Bo8dFPTWUJCVEdU=
//pragma protect end_data_block
//pragma protect digest_block
4fgubcVSsGbsihJUaEnAoP/WOus=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ArtFgEcTFuExxn3GR8FXMf8nwl3zKw461a9BondW1J0YUuXertNKCWOunZwIrdrk
kw2YzU9ydjX7blOfOkioZGvDDlgewjLov5Mm5pDGPknUvpOwcW4MZWQrEGy2pLBs
Qohfcymv50b6J4D/31pvxZTePhhccJCdoYSiWn+42UBae/oWJFGidjQmzNFBRaQy
YWiNMTyxxSK6A/fDoVY76cti8cxvT7LsA7n9t7wikAJZ4AjX9A0pT3o0a7/tfAKv
Y5rtMNAzAxGpKz3kT1HsEbG0900ME4mG3SE3k1voeJSSuBlO8Ien/845CEmfKiFt
0QXWlFyuoeA/Oh3YqqX89A==
//pragma protect end_key_block
//pragma protect digest_block
Y7TScLLhiz6ikFqRuivjMbSX+G0=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 4420 characters]
//pragma protect end_data_block
//pragma protect digest_block
xciDfX1Ldbg0C13jX2WprHhS4gs=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AAYwB7coa78/Yuf59VHBW69gLAzRgVmYBXzd6y0lnt3wufZEqvvibKUEmexmwZhs
WPN2aFehFn4jrA23RfpbbUayQa4o1NImVXWBuQPUg1pxveC9IjVzjfODknUQo/7x
wGLGnttzN1H4YcBsgEVHV9C2+FrlVjMt/AXKBX7tyWt/uj/BHegmN05w3eF68ezW
KSSi0+4o8poOVevk+3u6jl/LU5pljIB3wfgTFuQRlyza1iKh3Oi2+amQ4FcEy20S
7rcZo4VsZPsvfejsl2CjAS7ULz8zAWmQ2pHcnujD/AZPRg/QyIlVgfJLnazN4yZq
FVUrqm7EADxShs4MTf6x4Q==
//pragma protect end_key_block
//pragma protect digest_block
ptYnyNqudo4cULGlJXYZ099X40A=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 6630 characters]
L7KSnGASAUgTPLwhD/HvLg==
//pragma protect end_data_block
//pragma protect digest_block
8VZnDhHtC+Uqr3bipiiwbVqxO1U=
//pragma protect end_digest_block
//pragma protect end_protected


//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
ArZ7vcjjhCv7sCCIwq7Ak8HMUBXa14nxVhK7jXnk/2XpoXqO2IiXlWkfEelaa7VP
515V+5Xso72FipIBiEzqDg/rUT3GGR8W50dw9gd4++WdSDldeLL+7MJTKyoOxSh+
/LP/zH6/9NXeiTZkzqu0zYmFLPdu7FBJoWGWMG8nWby7KOIGMmrawCjWk2/eRtua
kaxTPPfenziW/83T0yjS/AUBh32iSi11xKZrwkTJ5VaDP9ibyW7I0BGQGSLfgjuI
0N1K7Ux2+jHd180YXAO+aQhx1kQiRuBeSasWhNatvSgPxivWJ+BP3Zk/JkifaIoR
Kg+XWdo3A3YzSGCCDBSbag==
//pragma protect end_key_block
//pragma protect digest_block
7HkkPzjj4KfGbdQvpN+onYkUc3Y=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 5655 characters]
zskBxSIRx4Pgqkw4FJvmS+1CNp3um09EipNb3W18p4s=
//pragma protect end_data_block
//pragma protect digest_block
ufjESfjEyhxiHPCliZDKmztoS0g=
//pragma protect end_digest_block
//pragma protect end_protected


module `IP_MODULE_NAME(efx_mac1gbe) #(
   parameter FAMILY = "TRION",
   parameter VERSION = 32'h20,
   parameter RXFIFO_EN = 1,
   parameter RXFIFO_DTH = 2048,
   parameter TXFIFO_EN = 1,
   parameter TXFIFO_DTH = 2048,
   parameter PHY_INTF_MODE = 0,  
   parameter LOOPBACK_EN = 1'b0,
   parameter GMII_DW = PHY_INTF_MODE == 4 ? 16 : 8,
   parameter AXIS_DW = 8,  
   parameter APBIF = 0,
   parameter NO_PREAMBLE = 0,
   parameter INTER_PACKET_GAP = 6'd12,
   parameter MTU_FRAME_LENGTH = 16'd1518,
   parameter MAC_SOURCE_ADDRESS = 48'h0,
   parameter ENABLE_BROADCAST_FILTERING = 1'b1,
   parameter RGMII_RXC_EDGE = 1'b1,
   parameter RGMII_TXC_DLY = 1'b1,
   parameter PKT_CNT_MAX = 256, 
   parameter SIP600 = 0 
) (
   input                  tx_mac_aclk,
   output                 rx_mac_aclk,
   input                  mac_reset,   
   input                  proto_reset, 
   input                  tx_axis_clk,
   input [AXIS_DW-1:0]    tx_axis_mac_tdata,
   input                  tx_axis_mac_tvalid,
   input                  tx_axis_mac_tlast,
   input [AXIS_DW/8-1:0]  tx_axis_mac_tstrb,
   input                  tx_axis_mac_tuser,
   output                 tx_axis_mac_tready,
   input                  rx_axis_clk,
   output [AXIS_DW-1:0]   rx_axis_mac_tdata,
   output                 rx_axis_mac_tvalid,
   output                 rx_axis_mac_tlast,
   output [AXIS_DW/8-1:0] rx_axis_mac_tstrb,
   output                 rx_axis_mac_tuser,
   input                  rx_axis_mac_tready,
   input                  gm_rx_c,
   input  [GMII_DW-1:0]   gm_rx_d,
   input  [GMII_DW/8-1:0] gm_rx_dv,
   input  [GMII_DW/8-1:0] gm_rx_err,
   output                 gm_tx_c,
   output [GMII_DW-1:0]   gm_tx_d,
   output [GMII_DW/8-1:0] gm_tx_en,
   output [GMII_DW/8-1:0] gm_tx_err,
   output [3:0]           rgmii_txd_HI,
   output [3:0]           rgmii_txd_LO,
   output                 rgmii_tx_ctl_HI,
   output                 rgmii_tx_ctl_LO,
   output                 rgmii_txc_HI,
   output                 rgmii_txc_LO,
   input  [3:0]           rgmii_rxd_HI,
   input  [3:0]           rgmii_rxd_LO,
   input                  rgmii_rx_ctl_HI,
   input                  rgmii_rx_ctl_LO,
   input                  rgmii_rxc,
   input                  mii_txc,
   output [3:0]           mii_txd,
   output                 mii_tx_dv,
   output                 mii_tx_err,
   input                  mii_rxc,
   input  [3:0]           mii_rxd,
   input                  mii_rx_dv,
   input                  mii_rx_err,
   input                  rmii_clk_ref,
   output [1:0]           rmii_txd,
   output                 rmii_tx_en,
   input  [1:0]           rmii_rxd,
   input                  rmii_crs_dv,
   input                  rmii_rx_err,
   input  [9:0]           s_paddr,
   input  [31:0]          s_pwdata,
   input                  s_pwrite,
   input                  s_penable,
   input                  s_psel,
   output [31:0]          s_prdata,
   output                 s_pready,
   output                 s_perr,
   input                  s_axi_aclk,    
   input  [9:0]           s_axi_awaddr,  
   input                  s_axi_awvalid, 
   output                 s_axi_awready, 
   input  [31:0]          s_axi_wdata,   
   input                  s_axi_wvalid,  
   output                 s_axi_wready,  
   output [1:0]           s_axi_bresp,   
   output                 s_axi_bvalid,  
   input                  s_axi_bready,  
   input  [9:0]           s_axi_araddr,  
   input                  s_axi_arvalid, 
   output                 s_axi_arready, 
   output [1:0]           s_axi_rresp,   
   output [31:0]          s_axi_rdata,   
   output                 s_axi_rvalid,  
   input                  s_axi_rready,  
`ifdef ONCHIP_PHY
   input  logic           init_clk,
   input  logic           init_rst_n,
   input  logic           PMA_CMN_READY,
   input  logic           PMA_XCVR_PLLCLK_EN_ACK,
   input  logic [3:0]     PMA_XCVR_POWER_STATE_ACK,
   input  logic           PMA_RX_SIGNAL_DETECT,
   output logic           PMA_XCVR_PLLCLK_EN,
   output logic [3:0]     PMA_XCVR_POWER_STATE_REQ,
   output logic           phy_init_done,
`else
   output                 Mdo,   
   output                 MdoEn, 
   input                  Mdi,   
   output                 Mdc,   
`endif
   output [2:0]           eth_speed
);
`ifdef ONCHIP_PHY
//pragma protect begin_protected
//pragma protect encrypt_agent="NCPROTECT"
//pragma protect encrypt_agent_info="Encrypted using API"
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=prv(CDS_RSA_KEY_VER_2)
//pragma protect key_method=RSA
//pragma protect key_block
AMyoRL5/w7aGJMUAFjWdggMiBKf1mhnyB4tTNrQUAOHCO5ZmDsFpb964w4qkWZVN
XTiRjcc3GwM/Fmz7oO2RrXaSAbzLZGKR7DnzUuMenl8JrAwGEamBMGjpSL3aMEyl
mCUirfX0tqLb1/uPom1p3lHA+w9re3Qyn6vY/PUBq0IAP0rEKqYSnRPr21y2lJVr
GlwFuPkDG3BEkA5XQ32m2c6FOY1oVdGXaZA0+O0dQ9EHL0US5NFI3VmHggusoT7Z
/TQxNlOAsBkna47aYA7voZoUel9oAm+GvOo4Vs/5V6t6TNw9SkHr16nMswnNfzzb
xGTO/3F/v5LdwzL2hgvz5A==
//pragma protect end_key_block
//pragma protect digest_block
GPFPDOqRYTtfroZsY3lH14yzT1E=
//pragma protect end_digest_block
//pragma protect data_block
[encoded data, 6825 characters]
juOf4JlCNaUnoknLV2NmgcNIbS+PkTJ7HkVjCB5Ng4U=
//pragma protect end_data_block
//pragma protect digest_block
gfSy+yjCs0cH8hBJH8nmuez3sig=
//pragma protect end_digest_block
//pragma protect end_protected


// Module: efx_pulse_sync
// Description:
//   Safely transfers a single-cycle pulse from a source clock domain to a
//   destination clock domain using a toggle-based synchronization scheme.
//
// ==========================================================================

module `IP_MODULE_NAME(efx_pulse_sync) #(
   parameter ACTIVE_LOW = 1, // 0 - Active high reset, 1 - Active low reset
   parameter OFF_ASSERTION = 0
) (
   input  src_clk,      // Source clock (e.g., tx_axis_clk)
   input  src_reset,    // Reset for source domain
   input  pulse_in,     // Single-cycle pulse in src_clk domain

   input  dst_clk,      // Destination clock (e.g., tx_clk)
   input  dst_reset,    // Reset for destination domain
   output pulse_out     // Single-cycle pulse in dst_clk domain
);

// Toggle generation in source clock domain
reg toggle_src;

// Synchronizer flops in destination clock domain
wire toggle_sync;
reg  toggle_sync_r;

generate
   if (ACTIVE_LOW == 1) begin
      always @ (posedge src_clk or negedge src_reset) begin
         if (!src_reset)
            toggle_src <= 1'b0;
         else if (pulse_in)
            toggle_src <= ~toggle_src;
         else
            toggle_src <= toggle_src;
      end

     `IP_MODULE_NAME(efx_asyncreg) #(
        .WIDTH         (1),
        .OFF_ASSERTION (OFF_ASSERTION)
     ) efx_asyncreg_toggle_src (
        .clk     (dst_clk),
        .reset_n (dst_reset),
        .d_i     (toggle_src),
        .d_o     (toggle_sync)
     );
      
      always @ (posedge dst_clk or negedge dst_reset) begin
         if (!dst_reset) begin
            toggle_sync_r <= 1'b0;
         end 
         else begin
            toggle_sync_r <= toggle_sync;  // Delay for edge detect
         end
      end
   end
   else begin
      always @ (posedge src_clk or posedge src_reset) begin
         if (src_reset)
            toggle_src <= 1'b0;
         else if (pulse_in)
            toggle_src <= ~toggle_src;
         else
            toggle_src <= toggle_src;
      end

      `IP_MODULE_NAME(efx_asyncreg) #(
         .WIDTH         (1),
         .ACTIVE_HIGH   (0),
         .OFF_ASSERTION (OFF_ASSERTION)
      ) efx_asyncreg_toggle_src (
         .clk     (dst_clk),
         .reset_n (dst_reset),
         .d_i     (toggle_src),
         .d_o     (toggle_sync)
      );
      
      always @ (posedge dst_clk or posedge dst_reset) begin
         if (!dst_reset) begin
            toggle_sync_r <= 1'b0;
         end 
         else begin
            toggle_sync_r <= toggle_sync;  // Delay for edge detect
         end
      end
   end
endgenerate

// Generate one-cycle pulse in destination domain
assign pulse_out = toggle_sync ^ toggle_sync_r;

endmodule



module `IP_MODULE_NAME(efx_data_pipeline)  #(
    parameter HBP = 1,
    parameter DATA_WIDTH = 256,
    parameter MUX_IN = 1
)(
  input               upstream_valid_i,
  output              upstream_ready_o,
  input      [DATA_WIDTH-1:0]   upstream_data_i,
  output              downstream_valid_o,
  input               downstream_ready_i,
  output     [DATA_WIDTH-1:0]   downstream_data_o,
  input               clk,
  input               resetn
);
//pragma protect begin_protected
//pragma protect key_keyowner=Cadence Design Systems.
//pragma protect key_keyname=CDS_KEY
//pragma protect key_method=RC5
//pragma protect key_block
KjlM4WkOO2w2bQEZgp8zfO7oizuHRj0nKnd2HyaTF0mbfmP85E9tcE8RSpnLFQQY
Fx/LQ03PTxfV8SEFCk0j5a/YIXbL+yC7EvSHJ8LQ/Hh5tLpaDgWah36rsTcE2fet
whq92/ag/nAdDF1Vy4sbDr5FINmqPPikptUUvL1vDUmBcBOK5GHbSA==
//pragma protect end_key_block
//pragma protect digest_block
MnZuDl/T4JMKytmOinMcApLLkiI=
//pragma protect end_digest_block
//pragma protect data_block
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
K4vhL/IlI8Mj/z0kKlnD9A==
//pragma protect end_data_block
//pragma protect digest_block
/ZU5wr/v9FLKg6OANYaVJInQw6o=
//pragma protect end_digest_block
//pragma protect end_protected

`undef IP_UUID
`undef IP_NAME_CONCAT
`undef IP_MODULE_NAME
