mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-11-21 15:46:06 +01:00
FPGA : Trigger
This commit is contained in:
parent
d477c9ec58
commit
63b89e64b2
|
@ -30,10 +30,7 @@ architecture Behavioral of communication is
|
|||
constant F2AI_CAPT : std_logic_vector(7 downto 0) := x"43"; -- 'C'
|
||||
constant F2AT_CAPT : std_logic_vector(7 downto 0) := x"63"; -- 'c'
|
||||
|
||||
type readStates is (readIdle);
|
||||
signal readState : readStates := readIdle; -- TODO Make sure is correctly reset when reworking this
|
||||
signal readOffset : integer := 0;
|
||||
|
||||
type readMessages is (none, F2AT_CAPTs);
|
||||
type sendMessages is (none, A2FD_PINGs, F2AI_CODERs, F2AI_CAPTs, F2AD_ERR_UNKNOWN_CODEs);
|
||||
|
||||
constant SENDQUEUE_SIZE : integer := 16;
|
||||
|
@ -41,6 +38,7 @@ architecture Behavioral of communication is
|
|||
|
||||
signal frontTrigger : integer := 0;
|
||||
signal backTrigger : integer := 0;
|
||||
signal triggerSet : std_logic := '0';
|
||||
|
||||
signal txStbs : std_logic := '0';
|
||||
|
||||
|
@ -50,6 +48,11 @@ begin
|
|||
|
||||
readsendFA : process(clock, reset)
|
||||
|
||||
variable readMessage : readMessages := none;
|
||||
variable readSize : integer := 0;
|
||||
variable readOffset : integer := 0;
|
||||
variable readData : std_logic_vector(63 downto 0); -- Max message size (will be trimmed down by the synthetizer)
|
||||
|
||||
variable sendMessage : sendMessages := none;
|
||||
variable sendOffset : integer := 0;
|
||||
variable sendSize : integer := 0;
|
||||
|
@ -91,24 +94,31 @@ begin
|
|||
|
||||
begin
|
||||
if reset = '1' then
|
||||
readState <= readIdle;
|
||||
readMessage := none;
|
||||
readOffset := 0;
|
||||
readSize := 0;
|
||||
|
||||
sendMessage := none;
|
||||
sendOffset := 0;
|
||||
sendSize := 0;
|
||||
|
||||
sendTail := 0;
|
||||
sendHead := 0;
|
||||
sendLooped := false;
|
||||
|
||||
frontTrigger <= 0;
|
||||
backTrigger <= 0;
|
||||
zerocoder <= '0';
|
||||
txData <= x"00";
|
||||
triggerSet <= '0';
|
||||
else
|
||||
if rising_edge(clock) then
|
||||
zerocoder <= '0';
|
||||
|
||||
-- If read something
|
||||
if rxStb = '1' then
|
||||
if readState = readIdle then
|
||||
if readSize = 0 then
|
||||
readSize := 0;
|
||||
case rxData is
|
||||
when A2FD_PING =>
|
||||
pushSend(A2FD_PINGs);
|
||||
|
@ -116,12 +126,38 @@ begin
|
|||
pushSend(F2AI_CODERs);
|
||||
when F2AI_CAPT =>
|
||||
pushSend(F2AI_CAPTs);
|
||||
when F2AT_CAPT =>
|
||||
readMessage := F2AT_CAPTs;
|
||||
readSize := 4;
|
||||
when others =>
|
||||
pushSend(F2AD_ERR_UNKNOWN_CODEs);
|
||||
end case;
|
||||
else
|
||||
readData((readOffset + 1) * 8 - 1 downto readOffset * 8) := rxData;
|
||||
if readOffset = readSize - 1 then
|
||||
case readMessage is
|
||||
when F2AT_CAPTs =>
|
||||
frontTrigger <= to_integer(unsigned(readData(15 downto 0)));
|
||||
backTrigger <= to_integer(unsigned(readData(31 downto 16)));
|
||||
triggerSet <= '1';
|
||||
when others =>
|
||||
pushSend(F2AD_ERR_UNKNOWN_CODEs);
|
||||
end case;
|
||||
readMessage := none;
|
||||
readOffset := 0;
|
||||
readSize := 0;
|
||||
else
|
||||
readOffset := readOffset + 1;
|
||||
end if;
|
||||
|
||||
end if;
|
||||
end if;
|
||||
|
||||
if (triggerSet = '1' and ((front > frontTrigger) or (back > backTrigger))) then
|
||||
pushSend(F2AI_CAPTs);
|
||||
triggerSet <= '0';
|
||||
end if;
|
||||
|
||||
-- If what was sent is acknowledged or nothing is being sent atm
|
||||
if txStbs = '0' or txAck = '1' then
|
||||
if sendSize = 0 then -- If no data to be sent
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
[*]
|
||||
[*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI
|
||||
[*] Tue Feb 27 08:58:38 2018
|
||||
[*] Tue Feb 27 20:44:59 2018
|
||||
[*]
|
||||
[dumpfile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/build/communication_tb.ghw"
|
||||
[dumpfile_mtime] "Tue Feb 27 08:58:14 2018"
|
||||
[dumpfile_size] 5411
|
||||
[dumpfile_mtime] "Tue Feb 27 20:44:10 2018"
|
||||
[dumpfile_size] 6988
|
||||
[savefile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/communication_tb.gtkw"
|
||||
[timestart] 0
|
||||
[size] 1600 862
|
||||
[pos] -1 -1
|
||||
*-29.549107 930000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
*-29.975166 2184000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
[treeopen] top.
|
||||
[treeopen] top.communication_tb.
|
||||
[treeopen] top.communication_tb.dut.
|
||||
[sst_width] 213
|
||||
[signals_width] 118
|
||||
[signals_width] 126
|
||||
[sst_expanded] 1
|
||||
[sst_vpaned_height] 200
|
||||
@28
|
||||
|
@ -29,11 +29,6 @@ top.communication_tb.reset
|
|||
@28
|
||||
[color] 5
|
||||
top.communication_tb.dut.rxstb
|
||||
@420
|
||||
[color] 6
|
||||
top.communication_tb.dut.readstate
|
||||
[color] 6
|
||||
top.communication_tb.dut.readoffset
|
||||
@22
|
||||
[color] 1
|
||||
#{top.communication_tb.txdata[7:0]} top.communication_tb.txdata[7] top.communication_tb.txdata[6] top.communication_tb.txdata[5] top.communication_tb.txdata[4] top.communication_tb.txdata[3] top.communication_tb.txdata[2] top.communication_tb.txdata[1] top.communication_tb.txdata[0]
|
||||
|
@ -45,8 +40,17 @@ top.communication_tb.dut.readoffset
|
|||
top.communication_tb.dut.txstb
|
||||
[color] 1
|
||||
top.communication_tb.dut.txack
|
||||
@29
|
||||
[color] 2
|
||||
top.communication_tb.dut.zerocoder
|
||||
@420
|
||||
[color] 2
|
||||
top.communication_tb.dut.fronttrigger
|
||||
[color] 2
|
||||
top.communication_tb.dut.backtrigger
|
||||
[color] 2
|
||||
top.communication_tb.dut.front
|
||||
@421
|
||||
[color] 2
|
||||
top.communication_tb.dut.back
|
||||
[pattern_trace] 1
|
||||
[pattern_trace] 0
|
||||
|
|
|
@ -67,7 +67,7 @@ begin
|
|||
clock <= TbClock;
|
||||
|
||||
stimuli : process
|
||||
variable shouldReceive : multipleChar;
|
||||
variable tampon : multipleChar;
|
||||
begin
|
||||
left <= 0;
|
||||
right <= 0;
|
||||
|
@ -169,10 +169,10 @@ begin
|
|||
wait for TbPeriod;
|
||||
rxStb <= '0';
|
||||
|
||||
shouldReceive(0 to 4) := (x"43", x"80", x"04", x"5E", x"2D");
|
||||
tampon(0 to 4) := (x"43", x"80", x"04", x"5E", x"2D");
|
||||
for I in 0 to 4 loop
|
||||
wait for 100 ns;
|
||||
assert txData = shouldReceive(I) report "Not sent correct data, got " & integer'image(to_integer(unsigned(txData))) & ", expected " & integer'image(to_integer(unsigned(shouldReceive(I))))severity error;
|
||||
assert txData = tampon(I) report "Not sent correct data, got " & integer'image(to_integer(unsigned(txData))) & ", expected " & integer'image(to_integer(unsigned(tampon(I))))severity error;
|
||||
assert txStb = '1' report "Not sending" severity error;
|
||||
|
||||
wait for 100 ns;
|
||||
|
@ -199,10 +199,10 @@ begin
|
|||
wait for TbPeriod;
|
||||
assert zerocoder = '0' report "Not stopping reseting coder values" severity error;
|
||||
|
||||
shouldReceive(0 to 4) := (x"44", x"80", x"04", x"5E", x"2D");
|
||||
tampon(0 to 4) := (x"44", x"80", x"04", x"5E", x"2D");
|
||||
for I in 0 to 4 loop
|
||||
wait for 100 ns;
|
||||
assert txData = shouldReceive(I) report "Not sent correct data, got " & integer'image(to_integer(unsigned(txData))) & ", expected " & integer'image(to_integer(unsigned(shouldReceive(I))))severity error;
|
||||
assert txData = tampon(I) report "Not sent correct data, got " & integer'image(to_integer(unsigned(txData))) & ", expected " & integer'image(to_integer(unsigned(tampon(I))))severity error;
|
||||
assert txStb = '1' report "Not sending" severity error;
|
||||
|
||||
wait for 100 ns;
|
||||
|
@ -211,8 +211,41 @@ begin
|
|||
txAck <= '0';
|
||||
end loop;
|
||||
|
||||
wait for 100 ns;
|
||||
assert txStb = '0' report "Not stopping send" severity error;
|
||||
|
||||
|
||||
-- Test capt trigger
|
||||
report "TEST Receiving 'c'" severity note;
|
||||
|
||||
tampon(0 to 4) := (x"63", x"80", x"04", x"5E", x"2D");
|
||||
for I in 0 to 4 loop
|
||||
rxData <= tampon(I);
|
||||
rxStb <= '1';
|
||||
wait for TbPeriod;
|
||||
rxStb <= '0';
|
||||
wait for TbPeriod;
|
||||
end loop;
|
||||
|
||||
wait for 100 ns;
|
||||
|
||||
front <= 11614;
|
||||
back <= 11614;
|
||||
|
||||
tampon(0 to 4) := (x"43", x"5E", x"2D", x"5E", x"2D");
|
||||
for I in 0 to 4 loop
|
||||
wait for 100 ns;
|
||||
assert txData = tampon(I) report "Not sent correct data, got " & integer'image(to_integer(unsigned(txData))) & ", expected " & integer'image(to_integer(unsigned(tampon(I))))severity error;
|
||||
assert txStb = '1' report "Not sending" severity error;
|
||||
|
||||
wait for 100 ns;
|
||||
txAck <= '1';
|
||||
wait for TbPeriod;
|
||||
txAck <= '0';
|
||||
end loop;
|
||||
|
||||
wait for 100 ns;
|
||||
|
||||
wait for 100 ns; -- Margin
|
||||
|
||||
TbSimEnded <= '1';
|
||||
wait;
|
||||
|
|
Loading…
Reference in a new issue