1
0
SEm-Labos/01-WaveformGenerator/WaveformGenerator/hdl/triangleToPolygon_studentVersion.vhd
2024-03-01 14:24:40 +01:00

28 lines
837 B
VHDL

ARCHITECTURE studentVersion OF triangleToPolygon IS
signal mySignal : unsigned(bitNb downto 0);
constant aFullTriangle : unsigned(bitNb downto 0) := (others => '1');
BEGIN
convert: process(triangle)
begin
if (('0' & triangle) + ('0' & shift_right(triangle, 1))) < shift_right(aFullTriangle, 3) then
mySignal <= shift_right(aFullTriangle,3);
elsif (('0' & triangle) + ('0' & shift_right(triangle, 1))) > (shift_right(aFullTriangle, 1) + shift_right('0' & aFullTriangle, 3)) then
mySignal <= (shift_right(aFullTriangle,1) + shift_right(aFullTriangle,3));
elsif '1' then
mySignal <= ('0' & triangle) + ('0' & shift_right(triangle, 1) );
end if ;
end process convert;
polygon <= resize(mySignal-shift_right('0' & aFullTriangle,3), bitNb);
END ARCHITECTURE studentVersion;