Skip to content

Commit f3162da

Browse files
authored
Merge branch 'master' into sfrinaldi/02-doxygen-ci-fix
2 parents cf4997e + 01044f4 commit f3162da

File tree

4 files changed

+280
-4
lines changed

4 files changed

+280
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,6 @@ FineSteeringMirrorController/Liberopeekfifos/designer/FineSteeringMirror/user_se
167167

168168
doxygen/*
169169
.vscode/*
170-
*.ctags
170+
*.ctags
171+
172+
build/*

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Install headers from `include` directory into PREFIX directory.
2+
# By default, PREFIX is /usr/local/include/summerDevice, but it can be
3+
# overridden by setting the PREFIX variable when invoking make. For example:
4+
# make install PREFIX=/opt/MAgAOX/source/summerDevice
5+
# Note: installing / uninstalling to /usr/local requires root privileges:
6+
# sudo make install / uninstall
7+
8+
PREFIX ?= /usr/local/include/summerDevice
9+
DESTDIR ?=
10+
11+
SRCDIR := include
12+
BUILD_DIR := build
13+
MANIFEST := $(BUILD_DIR)/install_manifest.txt
14+
15+
INSTALL_DIR := install -d
16+
17+
ALL_HEADERS := $(shell find $(SRCDIR) -type f -name '*.h' -o -type f -name '*.hpp')
18+
19+
.PHONY: all build install uninstall clean help
20+
21+
# Default: build list of headers to be installed
22+
all: build
23+
24+
build:
25+
@echo "Building header list in $(BUILD_DIR)"
26+
@mkdir -p $(BUILD_DIR)
27+
@find $(SRCDIR) -type f -name '*.h' -o -type f -name '*.hpp' > $(BUILD_DIR)/headers.list
28+
@echo "Found $$(wc -l < $(BUILD_DIR)/headers.list) header files to install"
29+
30+
install: uninstall build
31+
@echo "Installing headers to $(DESTDIR)$(PREFIX)"
32+
@> $(MANIFEST)
33+
@while IFS= read -r f; do \
34+
rel=$${f#$(SRCDIR)/}; \
35+
dest=$(DESTDIR)$(PREFIX)/$$rel; \
36+
$(INSTALL_DIR) "$$(dirname "$$dest")"; \
37+
cp "$$f" "$$dest"; \
38+
echo "$$dest" >> $(MANIFEST); \
39+
done < $(BUILD_DIR)/headers.list
40+
@echo "Installed $$(wc -l < $(MANIFEST)) headers; manifest written to $(MANIFEST)"
41+
42+
uninstall:
43+
@if [ -f $(MANIFEST) ]; then \
44+
echo "Removing files listed in $(MANIFEST)"; \
45+
xargs rm -f < $(MANIFEST); \
46+
rm -f $(MANIFEST); \
47+
echo "Removing empty directories under $(DESTDIR)$(PREFIX)"; \
48+
find $(DESTDIR)$(PREFIX) -type d -empty -delete 2>/dev/null || true; \
49+
else \
50+
echo "No manifest found at $(MANIFEST); nothing to uninstall"; \
51+
fi
52+
53+
clean:
54+
@echo "Cleaning $(BUILD_DIR)"
55+
@rm -rf $(BUILD_DIR)
56+
57+
help:
58+
@echo "Usage: make [target] [PREFIX=/path] [DESTDIR=/staging]"
59+
@echo "Targets: all, build, install, uninstall, clean, help"

include/fpga/FieldLatcher.vhd

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
--
2+
-- Copyright (c) by Franks Development, LLC
3+
--
4+
-- This software is copyrighted by and is the sole property of Franks
5+
-- Development, LLC. All rights, title, ownership, or other interests
6+
-- in the software remain the property of Franks Development, LLC. This
7+
-- software may only be used in accordance with the corresponding
8+
-- license agreement. Any unauthorized use, duplication, transmission,
9+
-- distribution, or disclosure of this software is expressly forbidden.
10+
--
11+
-- This Copyright notice may not be removed or modified without prior
12+
-- written consent of Franks Development, LLC.
13+
--
14+
-- Franks Development, LLC. reserves the right to modify this software
15+
-- without notice.
16+
--
17+
-- Franks Development, LLC support@franks-development.com
18+
-- 500 N. Bahamas Dr. #101 http:--www.franks-development.com
19+
-- Tucson, AZ 85710
20+
-- USA
21+
--
22+
-- Permission granted for perpetual non-exclusive end-use by the University of Arizona August 1, 2020
23+
--
24+
library IEEE;
25+
use IEEE.STD_LOGIC_1164.ALL;
26+
use IEEE.STD_LOGIC_UNSIGNED.ALL;
27+
use IEEE.NUMERIC_STD.all;
28+
library work;
29+
use work.CGraphTypes.all;
30+
31+
entity FieldLatcher is
32+
port (
33+
clk : in std_logic;
34+
rst : in std_logic;
35+
36+
-- Bus:
37+
ByteIn : in std_logic_vector(7 downto 0);
38+
WriteReq : in std_logic;
39+
FieldLatched : out std_logic_vector(31 downto 0)--;
40+
);
41+
end FieldLatcher;
42+
43+
44+
architecture FieldLatcherImplemenatation of FieldLatcher is
45+
46+
signal LastWriteReq : std_logic;
47+
48+
begin
49+
process (clk, rst)
50+
begin
51+
52+
if (rst = '1') then
53+
54+
LastWriteReq <= '0';
55+
FieldLatched <= x"00000000";
56+
57+
else
58+
59+
if ( (clk'event) and (clk = '1') ) then
60+
61+
LastWriteReq <= WriteReq;
62+
63+
if ( (LastWriteReq = '0') and (WriteReq = '1') ) then
64+
65+
FieldLatched(31 downto 24) <= FieldLatched(23 downto 16);
66+
FieldLatched(23 downto 16) <= FieldLatched(15 downto 8);
67+
FieldLatched(15 downto 8) <= FieldLatched(7 downto 0);
68+
FieldLatched(7 downto 0) <= ByteIn;
69+
70+
end if;
71+
end if;
72+
end if;
73+
end process;
74+
75+
end FieldLatcherImplemenatation;
76+

include/fpga/PeekRingBuffer.vhd

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ entity PeekRingBuffer is
3838
DataEndAddress : out std_logic_vector(PeekRamDepth - 1 downto 0);
3939
PeekAddress : in std_logic_vector(PeekRamDepth - 1 downto 0);
4040
PopAddress : in std_logic_vector(PeekRamDepth - 1 downto 0);
41+
LastHeaderEnd : out std_logic_vector(PeekRamDepth - 1 downto 0);
42+
LastFooterEnd : out std_logic_vector(PeekRamDepth - 1 downto 0);
43+
PopAddress : in std_logic_vector(PeekRamDepth - 1 downto 0);
44+
PayloadLen : out std_logic_vector(31 downto 0);
45+
HeaderFooterPayloadLenMatches : out std_logic;
4146
ByteIn : in std_logic_vector(7 downto 0);
4247
ByteOut : out std_logic_vector(7 downto 0);
4348
WriteReq : in std_logic;
@@ -68,11 +73,49 @@ architecture PeekRingBufferImplemenatation of PeekRingBuffer is
6873
);
6974
end component;
7075

76+
component PatternFinder is
77+
generic (
78+
Byte0 : std_logic_vector(7 downto 0) := x"00";
79+
Byte1 : std_logic_vector(7 downto 0) := x"00";
80+
Byte2 : std_logic_vector(7 downto 0) := x"00";
81+
Byte3 : std_logic_vector(7 downto 0) := x"00"--;
82+
);
83+
port (
84+
clk : in std_logic;
85+
rst : in std_logic;
86+
87+
-- Bus:
88+
ByteIn : in std_logic_vector(7 downto 0);
89+
WriteReq : in std_logic;
90+
Found : out std_logic--;
91+
);
92+
end component;
93+
94+
component FieldLatcher is
95+
port (
96+
clk : in std_logic;
97+
rst : in std_logic;
98+
99+
-- Bus:
100+
ByteIn : in std_logic_vector(7 downto 0);
101+
WriteReq : in std_logic;
102+
FieldLatched : out std_logic_vector(31 downto 0)--;
103+
);
104+
end component;
105+
106+
71107
signal DataStartAddress_i : std_logic_vector(PeekRamDepth - 1 downto 0);
72108
signal WriteAddress : std_logic_vector(PeekRamDepth - 1 downto 0);
73109

74110
signal LastPopReq : std_logic;
75111
signal LastWriteReq : std_logic;
112+
113+
signal HeaderFound : std_logic;
114+
signal FooterFound : std_logic;
115+
signal LastHeaderFound : std_logic;
116+
signal LastFooterFound : std_logic;
117+
118+
signal MaybePayloadLen : std_logic_vector(31 downto 0);
76119

77120
begin
78121

@@ -88,6 +131,50 @@ architecture PeekRingBufferImplemenatation of PeekRingBuffer is
88131
WriteReq => WriteReq
89132
);
90133

134+
HeaderFinder : PatternFinder
135+
generic map
136+
(
137+
Byte0 => x"1B",
138+
Byte1 => x"AD",
139+
Byte2 => x"BA",
140+
Byte3 => x"BE"--,
141+
);
142+
port map
143+
(
144+
clk => clk,
145+
rst => rst,
146+
ByteIn => ByteIn,
147+
WriteReq => WriteReq,
148+
Found => HeaderFound--,
149+
);
150+
151+
FooterFinder : PatternFinder
152+
generic map
153+
(
154+
Byte0 => x"0A",
155+
Byte1 => x"0F",
156+
Byte2 => x"AD",
157+
Byte3 => x"ED"--,
158+
);
159+
port map
160+
(
161+
clk => clk,
162+
rst => rst,
163+
ByteIn => ByteIn,
164+
WriteReq => WriteReq,
165+
Found => FooterFound--,
166+
);
167+
168+
PayloadLenLatcher : FieldLatcher
169+
port map
170+
(
171+
clk => clk,
172+
rst => rst,
173+
ByteIn => ByteIn,
174+
WriteReq => WriteReq,
175+
FieldLatched => MaybePayloadLen--,
176+
);
177+
91178
process (clk, rst)
92179
begin
93180

@@ -114,12 +201,17 @@ architecture PeekRingBufferImplemenatation of PeekRingBuffer is
114201
LastWriteReq <= '0';
115202
DataStartAddress_i <= (others => '0');
116203
WriteAddress <= (others => '0');
204+
LastHeaderEnd <= (others => '0');
205+
LastFooterEnd <= (others => '0');
206+
PayloadLen <= x"00000000";
117207

118208
else
119209
if ( (clk'event) and (clk = '1') ) then
120210

121211
LastPopReq <= PopReq;
122212
LastWriteReq <= WriteReq;
213+
LastHeaderFound <= HeaderFound;
214+
LastFooterFound <= FooterFound;
123215

124216
if ( (LastPopReq = '0') and (PopReq = '1') ) then
125217

@@ -133,21 +225,68 @@ architecture PeekRingBufferImplemenatation of PeekRingBuffer is
133225

134226
if (WriteAddress < ( (2**PeekRamDepth) - 1) ) then
135227

136-
--~ WriteAddress <= WriteAddress + std_logic_vector(to_unsigned(1, PeekRamDepth));
137-
WriteAddress <= WriteAddress + "0000000001";
228+
WriteAddress <= WriteAddress + std_logic_vector(to_unsigned(1, PeekRamDepth));
229+
--~ WriteAddress <= WriteAddress + "0000000001";
138230

139231
else --wrap
140232

141233
WriteAddress <= (others => '0');
142234

143235
end if;
144-
236+
237+
--If we wrap footer or header, clear!
238+
if (LastHeaderEnd = WriteAddress + "0000000001") then LastHeaderEnd <= (others => '0'); end if;
239+
240+
if (LastFooterEnd = WriteAddress + "0000000001") then LastFooterEnd <= (others => '0'); end if;
241+
242+
--Grab the payload len?
243+
244+
if (WriteAddress >= LastHeaderEnd) then
245+
246+
if (WriteAddress = (LastHeaderEnd + 3) then PayloadLen <= MaybePayloadLen; end if;
247+
248+
else
249+
250+
if (WriteAddress = (LastHeaderEnd + 3 - (2**PeekRamDepth)) then PayloadLen <= MaybePayloadLen; end if; --!!!this calc is WRONG!!! Needs to WRAP correctly...
251+
252+
end if;
253+
145254
else
146255

147256
Dbg1 <= '0';
148257

149258
end if;
150259

260+
--Update on the edge of found; can't put this on the writereq edge, because the flag will toggle on the next clock after, not synchrounously!
261+
if ( (LastHeaderFound = '0') and (HeaderFound = '1') ) then LastHeaderEnd = WriteAddress - "0000000001"; end if;
262+
263+
if ( (LastFooterFound = '0') and (FooterFound = '1') ) then
264+
265+
LastFooterEnd = WriteAddress - "0000000001";
266+
267+
--Found a footer! This should initiate more checks; namely, generating & testing the CRC and checking if headerpos +length <+appropriate offsets> = footerpos
268+
--Really need to test & fix CRCer first...
269+
--~ RS422_Rx0_Crcer : CrcFifo
270+
--~ generic map
271+
--~ (
272+
--~ DEPTH_BITS => 10--,
273+
--~ )
274+
--~ port map
275+
--~ (
276+
--~ clk => MasterClk,
277+
--~ rst => Uart0DoCrc,
278+
--~ FifoStartAddr => Uart0CrcStartAddr,
279+
--~ FifoEndAddr => Uart0CrcEndAddr,
280+
--~ FifoPeekData => Uart0RxFifoPeekPeekData,
281+
--~ FifoPeekAddr => Uart0RxFifoPeekPeekAddrCrcer,
282+
--~ Crc => Uart0Crc,
283+
--~ CrcComplete => Uart0CrcDone--,
284+
--~ );
285+
286+
--~ HeaderFooterPayloadLenMatches <=
287+
288+
end if;
289+
151290
end if;
152291
end if;
153292
end process;

0 commit comments

Comments
 (0)