mirror of
https://github.com/Klagarge/Cursor.git
synced 2025-06-26 04:12:31 +00:00
Initial commit
This commit is contained in:
47
Libs/Lcd_test/hdl/lcdController_tester_test.vhd
Normal file
47
Libs/Lcd_test/hdl/lcdController_tester_test.vhd
Normal file
@ -0,0 +1,47 @@
|
||||
ARCHITECTURE test OF lcdController_tester IS
|
||||
|
||||
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
|
||||
signal clock_int: std_ulogic := '1';
|
||||
|
||||
constant testInterval: time := 5 us;
|
||||
|
||||
BEGIN
|
||||
------------------------------------------------------------------------------
|
||||
-- reset and clock
|
||||
reset <= '1', '0' after 2*clockPeriod;
|
||||
|
||||
clock_int <= not clock_int after clockPeriod/2;
|
||||
clock <= transport clock_int after clockPeriod*9/10;
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- send sequence
|
||||
process
|
||||
begin
|
||||
ascii <= (others => '0');
|
||||
send <= '0';
|
||||
wait until falling_edge(busy);
|
||||
wait for testInterval;
|
||||
-- send single character
|
||||
wait until rising_edge(clock_int);
|
||||
ascii <= std_ulogic_vector(to_unsigned(character'pos('a'), ascii'length));
|
||||
send <= '1', '0' after clockPeriod;
|
||||
wait until rising_edge(busy);
|
||||
wait until falling_edge(busy);
|
||||
wait for testInterval;
|
||||
-- send character stream
|
||||
for index in character'pos('b') to character'pos('d') loop
|
||||
ascii <= std_ulogic_vector(to_unsigned(index, ascii'length));
|
||||
send <= '1', '0' after clockPeriod;
|
||||
wait until rising_edge(busy);
|
||||
wait until falling_edge(busy);
|
||||
wait for 1 ns;
|
||||
end loop;
|
||||
wait for testInterval;
|
||||
-- end of simulation
|
||||
assert false
|
||||
report "End of simulation"
|
||||
severity failure;
|
||||
wait;
|
||||
end process;
|
||||
|
||||
END ARCHITECTURE test;
|
111
Libs/Lcd_test/hdl/lcdDemo_tester_test.vhd
Normal file
111
Libs/Lcd_test/hdl/lcdDemo_tester_test.vhd
Normal file
@ -0,0 +1,111 @@
|
||||
ARCHITECTURE test OF lcdDemo_tester IS
|
||||
|
||||
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
|
||||
signal clock_int: std_ulogic := '1';
|
||||
|
||||
constant testInterval:time := 0.1 ms;
|
||||
constant initSequenceLength:time := 20 us;
|
||||
constant helloSequenceLength:time := 1 ms;
|
||||
|
||||
constant rs232Frequency: real := real(baudRate);
|
||||
constant rs232Period: time := (1.0/rs232Frequency) * 1 sec;
|
||||
constant rs232WriteInterval: time := 10*rs232Period;
|
||||
|
||||
signal rs232OutString : string(1 to 32);
|
||||
signal rs232SendOutString: std_uLogic;
|
||||
signal rs232SendOutDone: std_uLogic;
|
||||
signal rs232OutByte: character;
|
||||
signal rs232SendOutByte: std_uLogic;
|
||||
|
||||
BEGIN
|
||||
------------------------------------------------------------------------------
|
||||
-- reset and clock
|
||||
reset <= '1', '0' after 2*clockPeriod;
|
||||
|
||||
clock_int <= not clock_int after clockPeriod/2;
|
||||
clock <= transport clock_int after clockPeriod*9/10;
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- test sequence
|
||||
process
|
||||
begin
|
||||
rs232SendOutString <= '0';
|
||||
buttons <= (others => '0');
|
||||
wait for initSequenceLength + helloSequenceLength;
|
||||
-- send bytes from serial port
|
||||
rs232OutString <= "a ";
|
||||
rs232SendOutString <= '1', '0' after 1 ns;
|
||||
wait until rs232SendOutDone = '1';
|
||||
wait for rs232WriteInterval;
|
||||
|
||||
rs232OutString <= "hello world ";
|
||||
rs232SendOutString <= '1', '0' after 1 ns;
|
||||
wait until rs232SendOutDone = '1';
|
||||
wait for rs232WriteInterval;
|
||||
wait for testInterval;
|
||||
-- send hello message
|
||||
wait until rising_edge(clock_int);
|
||||
for index in buttons'range loop
|
||||
buttons(index) <= '1';
|
||||
wait until rising_edge(clock_int);
|
||||
buttons(index) <= '0';
|
||||
wait until rising_edge(clock_int);
|
||||
end loop;
|
||||
wait for helloSequenceLength;
|
||||
wait for testInterval;
|
||||
-- end of simulation
|
||||
assert false
|
||||
report "End of simulation"
|
||||
severity failure;
|
||||
wait;
|
||||
end process;
|
||||
|
||||
--============================================================================
|
||||
-- RS232 send
|
||||
rsSendSerialString: process
|
||||
constant rs232BytePeriod : time := 15*rs232Period;
|
||||
variable commandRight: natural;
|
||||
begin
|
||||
rs232SendOutByte <= '0';
|
||||
rs232SendOutDone <= '0';
|
||||
|
||||
wait until rising_edge(rs232SendOutString);
|
||||
|
||||
commandRight := rs232OutString'right;
|
||||
while rs232OutString(commandRight) = ' ' loop
|
||||
commandRight := commandRight-1;
|
||||
end loop;
|
||||
|
||||
for index in rs232OutString'left to commandRight loop
|
||||
rs232OutByte <= rs232OutString(index);
|
||||
rs232SendOutByte <= '1', '0' after 1 ns;
|
||||
wait for rs232BytePeriod;
|
||||
end loop;
|
||||
|
||||
rs232OutByte <= cr;
|
||||
rs232SendOutByte <= '1', '0' after 1 ns;
|
||||
wait for rs232BytePeriod;
|
||||
|
||||
rs232SendOutDone <= '1';
|
||||
wait for 1 ns;
|
||||
end process rsSendSerialString;
|
||||
-- send byte
|
||||
rsSendSerialByte: process
|
||||
variable txData: unsigned(7 downto 0);
|
||||
begin
|
||||
RxD <= '1';
|
||||
|
||||
wait until rising_edge(rs232SendOutByte);
|
||||
txData := to_unsigned(character'pos(rs232OutByte), txData'length);
|
||||
|
||||
RxD <= '0';
|
||||
wait for rs232Period;
|
||||
|
||||
for index in txData'reverse_range loop
|
||||
RxD <= txData(index);
|
||||
wait for rs232Period;
|
||||
end loop;
|
||||
|
||||
end process rsSendSerialByte;
|
||||
|
||||
END ARCHITECTURE test;
|
69
Libs/Lcd_test/hdl/lcdSerializer_tester_test.vhd
Normal file
69
Libs/Lcd_test/hdl/lcdSerializer_tester_test.vhd
Normal file
@ -0,0 +1,69 @@
|
||||
ARCHITECTURE test OF lcdSerializer_tester IS
|
||||
|
||||
constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
|
||||
signal clock_int: std_ulogic := '1';
|
||||
|
||||
constant initializationSequenceLength: positive := 14;
|
||||
type initializtionDataType is array (1 to initializationSequenceLength)
|
||||
of std_ulogic_vector(data'range);
|
||||
constant initializtionData: initializtionDataType :=(
|
||||
'0' & X"40", -- Display start line 0
|
||||
'0' & X"A1", --
|
||||
'0' & X"C0", --
|
||||
'0' & X"A6", --
|
||||
'0' & X"A2", --
|
||||
'0' & X"2F", --
|
||||
'0' & X"F8", --
|
||||
'0' & X"00", --
|
||||
'0' & X"23", --
|
||||
'0' & X"81", --
|
||||
'0' & X"1F", --
|
||||
'0' & X"AC", --
|
||||
'0' & X"00", --
|
||||
'0' & X"AF" --
|
||||
);
|
||||
|
||||
BEGIN
|
||||
------------------------------------------------------------------------------
|
||||
-- reset and clock
|
||||
reset <= '1', '0' after 2*clockPeriod;
|
||||
|
||||
clock_int <= not clock_int after clockPeriod/2;
|
||||
clock <= transport clock_int after clockPeriod*9/10;
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- send sequence
|
||||
process
|
||||
begin
|
||||
data <= (others => '0');
|
||||
send <= '0';
|
||||
wait until falling_edge(busy);
|
||||
-- send initialization codes
|
||||
wait until rising_edge(clock_int);
|
||||
for index in initializtionData'range loop
|
||||
data <= initializtionData(index);
|
||||
send <= '1', '0' after clockPeriod;
|
||||
wait until rising_edge(busy);
|
||||
wait until falling_edge(busy);
|
||||
wait for 1 ns;
|
||||
end loop;
|
||||
wait for 100*clockPeriod;
|
||||
-- send pixel codes
|
||||
wait until rising_edge(clock_int);
|
||||
for index in 1 to 8 loop
|
||||
data <= std_ulogic_vector(to_unsigned(index, data'length));
|
||||
data(data'high) <= '1';
|
||||
send <= '1', '0' after clockPeriod;
|
||||
wait until rising_edge(busy);
|
||||
wait until falling_edge(busy);
|
||||
wait for 1 ns;
|
||||
end loop;
|
||||
wait for 100*clockPeriod;
|
||||
-- end of simulation
|
||||
assert false
|
||||
report "End of simulation"
|
||||
severity failure;
|
||||
wait;
|
||||
end process;
|
||||
|
||||
END ARCHITECTURE test;
|
Reference in New Issue
Block a user