Forum Discussion
Altera_Forum
Honored Contributor
14 years ago --- Quote Start --- now, can you tell me , how to use the byte enable signal in the master port, any example code in vhdl. --- Quote End --- Refer to Table 3-1. Avalon-MM Signals in the Avalon specification for the exact definition. Basically though byte enable gets set by the master at the same point that it sets the address. So wherever it is that you have your logic that generates 'read' (or 'write') and 'address' you would need to also set 'byteenable'. Below is an example template that shows how to properly generate all of master output signals. Not every master needs to both 'read' and 'write'; if not needed you simply can leave them off of the entity. You would need to fill in the ... with whatever your logic is for generating an address, when exactly a read or write should be initiated what data is to be written for a write and which bytes are to be selected. If you only want to write to the lower 16 bits, byteenable would be set to "0011"; the upper 32 bits would be "1100"; writing only to the least significant byte would be "0001". In many cases though, you are always writing to all of the bytes so byteenable can simply be set to "1111" outside of the process since it is never changing. The value for byte enable is only needed during the time when a command is being issued, it is otherwise ignored. This is also true for address and writedata. That's why none of these signals needs to be reset by 'reset'. Some like to reset everything, I prefer not to burden a design with unnecessary logic since potentially it can become a performance or routing issue.
process(Clock)
begin
if rising_edge(Clock) then
if (Reset = '1') then
read <= '0'; -- If this master reads
write <= '0'; -- If this master writes
elsif (waitrequest = '0') then -- The signals can't change while waitrequest is active
address <= .... -- However it is that the master is supposed to generate an address
byteenable <= "1111"; -- Write to all 32 bits
write <= ... -- However it is that the master is supposed to initiate a write
writedata <= ...-- Whatever it is that is supposed to be written
end if;
end if;
end process; Kevin Jennings