Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added data mask support #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions sdram.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ entity sdram is
-- input data bus
data : in std_logic_vector(DATA_WIDTH-1 downto 0);

-- input data mask
mask : in std_logic_vector(3 downto 0);

-- When the write enable signal is asserted, a write operation will be performed.
we : in std_logic;

Expand Down Expand Up @@ -216,6 +219,7 @@ architecture arch of sdram is
signal addr_reg : unsigned(SDRAM_COL_WIDTH+SDRAM_ROW_WIDTH+SDRAM_BANK_WIDTH-1 downto 0);
signal data_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
signal we_reg : std_logic;
signal mask_reg : std_logic_vector(3 downto 0);
signal q_reg : std_logic_vector(DATA_WIDTH-1 downto 0);

-- aliases to decode the address register
Expand Down Expand Up @@ -367,6 +371,7 @@ begin
addr_reg <= shift_left(resize(addr, addr_reg'length), 1);
data_reg <= data;
we_reg <= we;
mask_reg <= not mask;
end if;
end if;
end process;
Expand Down Expand Up @@ -440,6 +445,24 @@ begin
sdram_dq <= data_reg((BURST_LENGTH-wait_counter)*SDRAM_DATA_WIDTH-1 downto (BURST_LENGTH-wait_counter-1)*SDRAM_DATA_WIDTH) when state = WRITE else (others => 'Z');

-- set SDRAM data mask
sdram_dqmh <= '0';
sdram_dqml <= '0';
--sdram_dqmh <= mask_reg(3) when (wait_counter = 0) else mask_reg(1);
--sdram_dqml <= mask_reg(2) when (wait_counter = 0) else mask_reg(0);


process (state, wait_counter, mask_reg)
begin
if (state = WRITE) then
if (wait_counter = 0) then
sdram_dqmh <= mask_reg(3);
sdram_dqml <= mask_reg(2);
else
sdram_dqmh <= mask_reg(1);
sdram_dqml <= mask_reg(0);
end if;
else
sdram_dqmh <= '0';
sdram_dqml <= '0';
end if;
end process;

end architecture arch;