Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 entity RAM_256Bytes is Port ( CLK : in STD_LOGIC; R_W : in STD_LOGIC; -- 1 means READ, 0 means WRITE Address : in STD_LOGIC_VECTOR (7 downto 0); Din : in STD_LOGIC_VECTOR (7 downto 0); Dout : out STD_LOGIC_VECTOR (7 downto 0)); end RAM_256Bytes; architecture Behavioral of RAM_256Bytes is --Defining a 2D signal as a type for RAM type RAM_256x8 is array (0 to 255) of std_logic_vector(7 downto 0); --Creating a 2D signal as RAM signal RAM: RAM_256x8; begin Read_Process: Process (CLK,R_W) begin if rising_edge (CLK) then if R_W= '1' then -- Reading has higher priority Dout <= RAM(conv_integer(Address)); elsif R_W = '0' then RAM (conv_integer(Address)) <= Din; end if; end if; end process; end Behavioral;
Also, numeric_std is a terrible standard. If you manage to time travel 2 decades into the past, use numeric_std. otherwise, use whatever you want. IMO, numeric_std is basically monkeys on a ladder.
So are you suggesting that everyone should use the Synopsys non-IEEE standard std_logic_arith, std_logic_unsigned, and std_logic_signed packages? (and amazingly someone gave it a helpful point)
Please clarify why everyone should not use the numeric_std package, I'd really like to know why you consider that package is basically monkeys on a ladder.
This is exactly why. Numeric_std vs _anything_ is never done based on technical merits. It is always done based on some tribal knowledge passed down through generations of VHDL developers.
I consider numeric_std, as written, terrible because it so heavily favors academic correctness over convenience AND is advocated as the ONLY solution. Specifically, "+" and "-" don't exist for std_logic_vectors despite being the same operation in both cases. There is no single function for converting std_logic_vector to natural for indexing -- another common task. These concepts both exist in Verilog, so I feel like the world wouldn't end if VHDL had them.
Advocating for numeric_std only, with no explanation, is really closer to advocating the user fundamentally change their design style without actually telling them how/why. It is done when the user doesn't understand the issue and when the user is attempting to solve an unrelated issue.
I agree. But the reason for this is more elitism than factual -- my premise is that many developers are told NEVER to use std_logic_unsigned because HORRIBLE (unspecified/misrepresented) things will happen. They don't actually learn the differences. Ideally, they figure out how to use numeric_std in a sane manner. Less ideal, they end up hating VHDL for the perception of type-micromanagement and verbosity. But, they will very strongly advise numeric_std either way.You are more likely to be considered for a job though. More places mandate numeric_std and usage of std_logic_unsigned can make you appear antiquated/set in your ways.
Sure, I don't like either as-written and prefer the practical/sane subset. My preference is to allow "+" (std_logic_unsigned), "-" (std_logic_signed), and conv_integer (std_logic_arith). "-" from signed as it is a useful unary operator for induction. conv_integer because it is convenient to have a vector-to-index function. I would prefer to force inequality comparisons for std_logic_vector to be errors. (Lexical compare is very dangerous -- confusing and not a warning. Some people will misguidedly use it as unsigned compare). I prefer equality comparison for std_logic_vector to be from the standard -- unequal lengths gives a warning.std_logic_unsigned/signed is also missing a several functions present in numeric std - like "/", mod and rem, resize, std_match.
Strong agree. But my point is that many VHDL developers can/do develop Verilog without the design failing instantly. Well, at least not failing for unsigned/signed reasons.I also dont like the idea that "it is more like verilog". VHDL isnt verilog. Why dont you just write verilog?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?