10-02-2018, 06:03 PM
(This post was last modified: 10-02-2018, 06:08 PM by ppppenguin.)
Everybody who uses VHDL has a different style. Some constructs are obvious, others are "why the h*** didn't I think of that earlier.
Some examples....
Bitwise AND of the elements in an 8 bit bus: A <= B(0) and B(1) and....... I'm already tired of this.
A <= (B = X"FF")
the result is boolean here but the expression is a lot quicker to write. Make it a 32 bit bus and that's hugely quicker. I only found this contrstuct recently when I had to do a 64 bit and and thought there must be a better way. Google helped
In VHDL2008 there are bitwise AND etc functions but I'm not sure if VHDL2008 is fully imlemented in the Xilinx tools. Same ideas for bitwise OR, NOR and NAND. I don't have a nice answer for bitwise XOR as needed in parity checks.
Multiplexer for the elements of an 8 bit bus (or any width)
MUX <= BUS(SELECTOR); where selector is an integer. Saves a big CASE or WITH statement.
MUX <= BUS(conv_integer(SELECTOR)); if SELECTOR is SLV
if SELECTOR < 11 then MUX <= BUS(SELECTOR); else MUX <= '0'; end if; --- 10 bit bus, making sure that if the selection is more than 10 the result is guaranteed zero.
Some examples....
Bitwise AND of the elements in an 8 bit bus: A <= B(0) and B(1) and....... I'm already tired of this.
A <= (B = X"FF")
the result is boolean here but the expression is a lot quicker to write. Make it a 32 bit bus and that's hugely quicker. I only found this contrstuct recently when I had to do a 64 bit and and thought there must be a better way. Google helped
In VHDL2008 there are bitwise AND etc functions but I'm not sure if VHDL2008 is fully imlemented in the Xilinx tools. Same ideas for bitwise OR, NOR and NAND. I don't have a nice answer for bitwise XOR as needed in parity checks.Multiplexer for the elements of an 8 bit bus (or any width)
MUX <= BUS(SELECTOR); where selector is an integer. Saves a big CASE or WITH statement.
MUX <= BUS(conv_integer(SELECTOR)); if SELECTOR is SLV
if SELECTOR < 11 then MUX <= BUS(SELECTOR); else MUX <= '0'; end if; --- 10 bit bus, making sure that if the selection is more than 10 the result is guaranteed zero.
www.borinsky.co.uk Jeffrey Borinsky www.becg.tv







