2024-02-23 13:01:05 +00:00
|
|
|
ARCHITECTURE studentVersion OF triangleToPolygon IS
|
2024-03-01 13:24:40 +00:00
|
|
|
|
|
|
|
signal mySignal : unsigned(bitNb downto 0);
|
|
|
|
constant aFullTriangle : unsigned(bitNb downto 0) := (others => '1');
|
2024-03-01 13:53:57 +00:00
|
|
|
signal bigTriangle: unsigned(bitNb downto 0);
|
|
|
|
signal oneOfHeight: unsigned(bitNb downto 0);
|
|
|
|
signal fiveOfHeight: unsigned(bitNb downto 0);
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-02-23 13:01:05 +00:00
|
|
|
BEGIN
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
resizeTriangle: process(triangle)
|
|
|
|
begin
|
|
|
|
bigTriangle <= ('0' & triangle) + ('0' & shift_right(triangle, 1));
|
|
|
|
oneOfHeight <= shift_right(aFullTriangle, 3);
|
|
|
|
fiveOfHeight <= shift_right(aFullTriangle, 1) + shift_right(aFullTriangle, 3);
|
|
|
|
end process resizeTriangle;
|
|
|
|
|
|
|
|
convert: process(bigTriangle)
|
2024-03-01 13:24:40 +00:00
|
|
|
begin
|
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
if bigTriangle < oneOfHeight then
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
mySignal <= oneOfHeight;
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
elsif bigTriangle > fiveOfHeight then
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
mySignal <= fiveOfHeight;
|
2024-03-01 13:24:40 +00:00
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
else
|
|
|
|
mySignal <= bigTriangle;
|
2024-03-01 13:24:40 +00:00
|
|
|
|
|
|
|
end if ;
|
|
|
|
|
|
|
|
end process convert;
|
|
|
|
|
2024-03-01 13:53:57 +00:00
|
|
|
polygon <= resize(mySignal-oneOfHeight, bitNb);
|
2024-02-23 13:01:05 +00:00
|
|
|
END ARCHITECTURE studentVersion;
|