-- altera vhdl_input_version vhdl_2008
-- XXX: QSYS Fix (https://www.intel.com/content/www/us/en/support/programmable/articles/000079458.html)

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

LIBRARY altera_mf;
USE altera_mf.altera_mf_components.all;

architecture altera of true_dual_port_ram is
    
begin

    altsyncram_component : altsyncram
        generic map (
            address_reg_b                       => "CLOCK0",
            clock_enable_input_a                => "BYPASS",
            clock_enable_input_b                => "BYPASS",
            clock_enable_output_a               => "BYPASS",
            clock_enable_output_b               => "BYPASS",
            indata_reg_b                        => "CLOCK0",
            intended_device_family              => "Cyclone V",
            lpm_type                            => "altsyncram",
            numwords_a                          => MEMORY_DEPTH,
            numwords_b                          => MEMORY_DEPTH,
            operation_mode                      => "BIDIR_DUAL_PORT",
            outdata_aclr_a                      => "NONE",
            outdata_aclr_b                      => "NONE",
            outdata_reg_a                       => "UNREGISTERED",
            outdata_reg_b                       => "UNREGISTERED",
            power_up_uninitialized              => "FALSE",
            read_during_write_mode_mixed_ports  => "DONT_CARE",
            read_during_write_mode_port_a       => "NEW_DATA_NO_NBE_READ",
            read_during_write_mode_port_b       => "NEW_DATA_NO_NBE_READ",
            widthad_a                           => ADDR_WIDTH,
            widthad_b                           => ADDR_WIDTH,
            width_a                             => DATA_WIDTH,
            width_b                             => DATA_WIDTH,
            width_byteena_a                     => 1,
            width_byteena_b                     => 1,
            wrcontrol_wraddress_reg_b           => "CLOCK0"
        )
        port map (
            address_a   => addr_a,
            address_b   => addr_b,
            clock0      => clk,
            data_a      => wr_data_a,
            data_b      => wr_data_b,
            rden_a      => ren_a,
            rden_b      => ren_b,
            wren_a      => wen_a,
            wren_b      => wen_b,
            q_a         => rd_data_a,
            q_b         => rd_data_b
        );

end architecture;
