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

synth: memory inference does not recognize byte-enables in some cases #2102

Open
Xiretza opened this issue Jun 20, 2022 · 1 comment
Open
Labels
Feature: Synthesis VHDL to netlist transformation.

Comments

@Xiretza
Copy link
Contributor

Xiretza commented Jun 20, 2022

Description
When given a memory with a write port that writes to only a subslice of a data word at a time, ghdl does not infer appropriate byte-enables unless the sub-slices are iterated over explicitly, and falls back to register-based storage instead.

Expected behaviour
Memory inference recognizes this pattern as a byte-enable and successfully infers the memory.

How to reproduce?

library ieee;
use ieee.std_logic_1164.all;

entity ent is
	generic (
		DEPTH : positive := 256
	);
	port (
		clk: in std_logic;

		write_enable: in std_logic;
		write_address: in natural range 0 to DEPTH-1;
		write_byte: in natural range 0 to 3;
		input: in std_logic_vector(7 downto 0);

		read_address: in natural range 0 to DEPTH-1;
		output: out std_logic_vector(31 downto 0)
	);
end entity;

architecture a of ent is
begin
	process(clk)
		type memory_t is array(0 to DEPTH-1) of std_logic_vector(31 downto 0);

		variable memory : memory_t;
	begin
		if rising_edge(clk) then
			output <= memory(read_address);

			if write_enable then
				memory(write_address)((write_byte+1) * 8 - 1 downto write_byte * 8) := input;

				-- the following works:
				/*
				for i in 0 to 3 loop
					if i = write_byte then
						memory(write_address)((i+1) * 8 - 1 downto i * 8) := input;
					end if;
				end loop;
				*/
			end if;
		end if;
	end process;
end architecture;
ghdl synth --std=08 ent.vhdl -e ent |& grep 'found RAM'

Context
Please, provide the following information:

  • OS: Arch Linux
  • Origin:
@umarcor
Copy link
Member

umarcor commented Jun 20, 2022

Ref: #1782.

@umarcor umarcor added the Feature: Synthesis VHDL to netlist transformation. label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Synthesis VHDL to netlist transformation.
Projects
None yet
Development

No branches or pull requests

2 participants