Archived
1
0

Initial commit

This commit is contained in:
github-classroom[bot]
2024-02-23 13:01:05 +00:00
committed by GitHub
commit d212040c30
1914 changed files with 1290006 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
LIBRARY std;
USE std.textio.all;
LIBRARY Common_test;
USE Common_test.testUtils.all;
ARCHITECTURE test OF charToMorseController_tester IS
-- clock and reset
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
signal sClock: std_uLogic := '1';
signal sReset: std_uLogic := '1';
-- character input
constant textToSend : string := "tea time";
constant charInputDelay : time := 200 us;
signal writePointer, readPointer : integer := 0;
signal fifoDataAvailable: std_uLogic := '0';
BEGIN
-- clock and reset
sClock <= not sClock after clockPeriod/2;
clock <= transport sClock after clockPeriod*9/10;
sReset <= '1', '0' after 2*clockPeriod;
reset <= sReset;
------------------------------------------------------------------------------
-- test sequence
testSequence: process
begin
-- send characters
for index in 1 to textToSend'length loop
wait for charInputDelay;
writePointer <= writePointer + 1;
end loop;
-- end of fifo input
print(cr & cr);
assert false
report "End of text"
severity note;
wait;
end process testSequence;
------------------------------------------------------------------------------
-- fifo simulation
fifo: process
begin
-- wait for action
wait until rising_edge(sClock);
-- add char in fifo
if readChar = '1' then
readPointer <= readPointer + 1;
end if;
-- end of simulation
if readPointer = textToSend'length then
wait for charInputDelay;
print(cr & cr);
assert false
report "End of simulation"
severity failure;
end if;
end process fifo;
char <= std_ulogic_vector(to_unsigned(
character'pos(textToSend(readPointer+1)), char'length
)) when (readPointer < textToSend'length) and (fifoDataAvailable = '1')
else (others => '-');
fifoDataAvailable <= '1' when readPointer < writePointer
else '0';
charNotReady <= not fifoDataAvailable;
END ARCHITECTURE test;

View File

@@ -0,0 +1,108 @@
LIBRARY Common_test;
USE Common_test.testUtils.all;
ARCHITECTURE test OF morseDecoder_tester IS
-- clock and reset
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
signal sClock: std_uLogic := '1';
signal sReset: std_uLogic := '1';
-- UART
constant uartPeriod: time := (1.0/uartBaudRate) * 1 sec;
constant uartWriteInterval: time := 2 ms;
signal uartInString : string(1 to 32);
signal uartSendInString: std_uLogic;
signal uartSendInDone: std_uLogic;
signal uartInByte: character;
signal uartSendInByte: std_uLogic;
BEGIN
-- clock and reset
sClock <= not sClock after clockPeriod/2;
clock <= transport sClock after clockPeriod*9/10;
sReset <= '1', '0' after 2*clockPeriod;
reset <= sReset;
------------------------------------------------------------------------------
-- test sequence
process
begin
uartSendInString <= '0';
wait for 4*uartPeriod;
-- characters with max. 2 Morse symbols
print("Sending characters with max. 2 symbols");
uartInString <= pad("tea time", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- characters starting with a dot
print("Sending characters starting with a dot");
uartInString <= pad("eish54v3uf2arlwpj1", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- characters starting with a dash
print("Sending characters starting with a dash");
uartInString <= pad("tndb6xkcymgz7qo890", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- end of simulation
print(cr & cr);
assert false
report "End of simulation"
severity failure;
wait;
end process;
--============================================================================
-- uart send
rsSendSerialString: process
constant uartBytePeriod : time := 15*uartPeriod;
variable commandRight: natural;
begin
uartSendInByte <= '0';
uartSendInDone <= '0';
wait until rising_edge(uartSendInString);
commandRight := uartInString'right;
while uartInString(commandRight) = ' ' loop
commandRight := commandRight-1;
end loop;
for index in uartInString'left to commandRight loop
uartInByte <= uartInString(index);
uartSendInByte <= '1', '0' after 1 ns;
wait for uartBytePeriod;
end loop;
uartInByte <= cr;
uartSendInByte <= '1', '0' after 1 ns;
wait for uartBytePeriod;
uartSendInDone <= '1';
wait for 1 ns;
end process rsSendSerialString;
rsSendSerialByte: process
variable rxData: unsigned(uartDataBitNb-1 downto 0);
begin
RxD <= '1';
wait until rising_edge(uartSendInByte);
rxData := to_unsigned(character'pos(uartInByte), rxData'length);
RxD <= '0';
wait for uartPeriod;
for index in rxData'reverse_range loop
RxD <= rxData(index);
wait for uartPeriod;
end loop;
end process rsSendSerialByte;
END ARCHITECTURE test;

View File

@@ -0,0 +1,106 @@
LIBRARY Common_test;
USE Common_test.testUtils.all;
ARCHITECTURE test OF morseEncoder_tester IS
-- clock and reset
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
signal sClock: std_uLogic := '1';
signal sReset: std_uLogic := '1';
-- UART
constant uartPeriod: time := (1.0/uartBaudRate) * 1 sec;
constant uartWriteInterval: time := 8 ms;
signal uartInString : string(1 to 32);
signal uartSendInString: std_uLogic;
signal uartSendInDone: std_uLogic;
signal uartInByte: character;
signal uartSendInByte: std_uLogic;
BEGIN
-- clock and reset
sClock <= not sClock after clockPeriod/2;
clock <= transport sClock after clockPeriod*9/10;
sReset <= '1', '0' after 2*clockPeriod;
reset <= sReset;
------------------------------------------------------------------------------
-- test sequence
process
begin
uartSendInString <= '0';
wait for 4*uartPeriod;
-- characters with max. 2 Morse symbols
print("Sending characters with max. 2 symbols");
uartInString <= pad("tea time", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- characters starting with a dot
print("Sending characters starting with a dot");
uartInString <= pad("eish54v3uf2arlwpj1", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- characters starting with a dash
print("Sending characters starting with a dash");
uartInString <= pad("tndb6xkcymgz7qo890", uartInString'length);
uartSendInString <= '1', '0' after 1 ns;
wait until uartSendInDone = '1';
wait for uartWriteInterval;
-- end of simulation
print(cr & cr);
assert false
report "End of simulation"
severity failure;
wait;
end process;
--============================================================================
-- uart send
rsSendSerialString: process
constant uartBytePeriod : time := 15*uartPeriod;
variable commandRight: natural;
begin
uartSendInByte <= '0';
uartSendInDone <= '0';
wait until rising_edge(uartSendInString);
commandRight := uartInString'right;
while uartInString(commandRight) = ' ' loop
commandRight := commandRight-1;
end loop;
for index in uartInString'left to commandRight loop
uartInByte <= uartInString(index);
uartSendInByte <= '1', '0' after 1 ns;
wait for uartBytePeriod;
end loop;
uartInByte <= cr;
uartSendInByte <= '1', '0' after 1 ns;
wait for uartBytePeriod;
uartSendInDone <= '1';
wait for 1 ns;
end process rsSendSerialString;
rsSendSerialByte: process
variable rxData: unsigned(uartDataBitNb-1 downto 0);
begin
RxD <= '1';
wait until rising_edge(uartSendInByte);
rxData := to_unsigned(character'pos(uartInByte), rxData'length);
RxD <= '0';
wait for uartPeriod;
for index in rxData'reverse_range loop
RxD <= rxData(index);
wait for uartPeriod;
end loop;
end process rsSendSerialByte;
END ARCHITECTURE test;