Skip to content

Commit b3c491f

Browse files
committed
DExx_Cramps: add dbspi (Buffered SPI with cs decoder) support
Signed-off-by: Michael Brown <producer@holotronic.dk>
1 parent cf03506 commit b3c491f

File tree

4 files changed

+217
-201
lines changed

4 files changed

+217
-201
lines changed

HW/hm2/config/DExx_Nano_xxx_Cramps/PIN_3x24_cap_enc_dbspi.vhd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ package Pintypes is
8181
(LEDTag, x"00", ClockLowTag, x"01", LEDAddr&PadT, LEDNumRegs, x"00", LEDMPBitMask),
8282
(NANOADCTag, x"00", ClockLowTag, x"08", NANOADCAddr&PadT, NANOADCNumRegs, x"00", NANOADCBitMask),
8383
(CAPSENSETag, x"00", ClockLowTag, x"04", CAPSENSEAddr&PadT, CAPSENSENumRegs, x"00", CAPSENSEBitMask),
84-
(DBSPITag, x"00", ClockLowTag, x"02", DBSPIDataAddr&PadT, DBSPINumRegs, x"11", DBSPIMPBitMask),
84+
(DBSPITag, x"00", ClockLowTag, x"01", DBSPIDataAddr&PadT, DBSPINumRegs, x"11", DBSPIMPBitMask),
8585
(FWIDTag, x"00", ClockLowTag, x"01", FWIDAddr&PadT, FWIDNumRegs, x"00", FWIDMPBitMask),
8686
(NullTag, x"00", NullTag, x"00", NullAddr&PadT, x"00", x"00", x"00000000"),
8787
(NullTag, x"00", NullTag, x"00", NullAddr&PadT, x"00", x"00", x"00000000"),
@@ -168,9 +168,9 @@ package Pintypes is
168168
IOPortTag & x"00" & DBSPITag & DBSPICS2Pin, -- I/O 52 GPIO_1 17 19 SPI Cs
169169
IOPortTag & x"00" & DBSPITag & DBSPICS3Pin, -- I/O 53 GPIO_1 18 20 SPI Cs
170170
IOPortTag & x"00" & DBSPITag & DBSPICS4Pin, -- I/O 54 GPIO_1 19 21 SPI Cs
171-
IOPortTag & x"01" & DBSPITag & DBSPICS5Pin, -- I/O 55 GPIO_1 20 22 SPI Cs
172-
IOPortTag & x"01" & DBSPITag & DBSPICS6Pin, -- I/O 56 GPIO_1 21 23 SPI Cs
173-
IOPortTag & x"01" & DBSPITag & DBSPICS7Pin, -- I/O 57 GPIO_1 22 24 SPI Cs
171+
IOPortTag & x"00" & DBSPITag & DBSPICS5Pin, -- I/O 55 GPIO_1 20 22 SPI Cs
172+
IOPortTag & x"00" & DBSPITag & DBSPICS6Pin, -- I/O 56 GPIO_1 21 23 SPI Cs
173+
IOPortTag & x"00" & DBSPITag & DBSPICS7Pin, -- I/O 57 GPIO_1 22 24 SPI Cs
174174
IOPortTag & x"01" & NullTag & NullPin, -- I/O 58 GPIO_1 23 25 just GPIO
175175
IOPortTag & x"01" & NullTag & NullPin, -- I/O 59 GPIO_1 24 26 just GPIO
176176
IOPortTag & x"01" & NullTag & NullPin, -- I/O 60 GPIO_1 25 27 just GPIO

HW/hm2/hm3_socfpga.qip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set_global_assignment -name VHDL_FILE ../../hm2/wrappers/MakePwmgens.vhd
3131
set_global_assignment -name VHDL_FILE ../../hm2/wrappers/MakeTPPWMGens.vhd
3232
set_global_assignment -name VHDL_FILE ../../hm2/wrappers/MakeSPIs.vhd
3333
set_global_assignment -name VHDL_FILE ../../hm2/wrappers/MakeBSPIs.vhd
34+
set_global_assignment -name VHDL_FILE ../../hm2/wrappers/MakeDBSPIs.vhd
3435

3536
# HM2 cores:
3637
set_global_assignment -name VHDL_FILE ../../hm2/kubstepgenzi.vhd

HW/hm2/hostmot3.vhd

Lines changed: 53 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ constant UsePWMEnas: boolean := PinExists(ThePinDesc,PWMTag,PWMCEnaPin);
161161
constant TPPWMGens : integer := NumberOfModules(TheModuleID,TPPWMTag);
162162
constant SPIs: integer := NumberOfModules(TheModuleID,SPITag);
163163
constant BSPIs: integer := NumberOfModules(TheModuleID,BSPITag);
164-
-- constant DBSPIs: integer := NumberOfModules(TheModuleID,DBSPITag);
164+
constant DBSPIs: integer := NumberOfModules(TheModuleID,DBSPITag);
165165
--constant SSSIs: integer := NumberOfModules(TheModuleID,SSSITag);
166166
--constant FAbss: integer := NumberOfModules(TheModuleID,FAbsTag);
167167
--constant BISSs: integer := NumberOfModules(TheModuleID,BISSTag);
@@ -196,7 +196,7 @@ constant StepGenTableWidth: integer := MaxPinsPerModule(ThePinDesc,StepGenTag);
196196
-- extract how many BSPI CS pins are needed
197197
constant BSPICSWidth: integer := CountPinsInRange(ThePinDesc,BSPITag,BSPICS0Pin,BSPICS7Pin);
198198
-- extract how many DBSPI CS pins are needed
199-
--constant DBSPICSWidth: integer := CountPinsInRange(ThePinDesc,DBSPITag,DBSPICS0Pin,DBSPICS7Pin);
199+
constant DBSPICSWidth: integer := CountPinsInRange(ThePinDesc,DBSPITag,DBSPICS0Pin,DBSPICS7Pin);
200200

201201
constant UseProbe: boolean := PinExists(ThePinDesc,QCountTag,QCountProbePin);
202202
constant UseMuxedProbe: boolean := PinExists(ThePinDesc,MuxedQCountTag,MuxedQCountProbePin);
@@ -675,201 +675,57 @@ GenMakeBSPIs: if BSPIs >0 generate
675675
);
676676
end generate;
677677

678-
--
679-
-- makebspimod: if BSPIs >0 generate
680-
-- signal LoadBSPIData: std_logic_vector(BSPIs -1 downto 0);
681-
-- signal ReadBSPIData: std_logic_vector(BSPIs -1 downto 0);
682-
-- signal LoadBSPIDescriptor: std_logic_vector(BSPIs -1 downto 0);
683-
-- signal ReadBSPIFIFOCOunt: std_logic_vector(BSPIs -1 downto 0);
684-
-- signal ClearBSPIFIFO: std_logic_vector(BSPIs -1 downto 0);
685-
-- signal BSPIClk: std_logic_vector(BSPIs -1 downto 0);
686-
-- signal BSPIIn: std_logic_vector(BSPIs -1 downto 0);
687-
-- signal BSPIOut: std_logic_vector(BSPIs -1 downto 0);
688-
-- signal BSPIFrame: std_logic_vector(BSPIs -1 downto 0);
689-
-- signal BSPIDataSel : std_logic;
690-
-- signal BSPIFIFOCountSel : std_logic;
691-
-- signal BSPIDescriptorSel : std_logic;
692-
-- type BSPICSType is array(BSPIs-1 downto 0) of std_logic_vector(BSPICSWidth-1 downto 0);
693-
-- signal BSPICS : BSPICSType;
694-
-- begin
695-
-- makebspis: for i in 0 to BSPIs -1 generate
696-
-- bspi: entity work.BufferedSPI
697-
-- generic map (
698-
-- cswidth => BSPICSWidth,
699-
-- gatedcs => false)
700-
-- port map (
701-
-- clk => clklow,
702-
-- ibus => ibusint,
703-
-- obus => obusint,
704-
-- addr => Aint(5 downto 2),
705-
-- hostpush => LoadBSPIData(i),
706-
-- hostpop => ReadBSPIData(i),
707-
-- loaddesc => LoadBSPIDescriptor(i),
708-
-- loadasend => '0',
709-
-- clear => ClearBSPIFIFO(i),
710-
-- readcount => ReadBSPIFIFOCount(i),
711-
-- spiclk => BSPIClk(i),
712-
-- spiin => BSPIIn(i),
713-
-- spiout => BSPIOut(i),
714-
-- spiframe => BSPIFrame(i),
715-
-- spicsout => BSPICS(i)
716-
-- );
717-
-- end generate;
718-
--
719-
-- BSPIDecodeProcess : process (Aint,Readstb,writestb,BSPIDataSel,BSPIFIFOCountSel,BSPIDescriptorSel)
720-
-- begin
721-
-- if Aint(AddrWidth-1 downto 8) = BSPIDataAddr then -- BSPI data register select
722-
-- BSPIDataSel <= '1';
723-
-- else
724-
-- BSPIDataSel <= '0';
725-
-- end if;
726-
-- if Aint(AddrWidth-1 downto 8) = BSPIFIFOCountAddr then -- BSPI FIFO count register select
727-
-- BSPIFIFOCountSel <= '1';
728-
-- else
729-
-- BSPIFIFOCountSel <= '0';
730-
-- end if;
731-
-- if Aint(AddrWidth-1 downto 8) = BSPIDescriptorAddr then -- BSPI channel descriptor register select
732-
-- BSPIDescriptorSel <= '1';
733-
-- else
734-
-- BSPIDescriptorSel <= '0';
735-
-- end if;
736-
-- LoadBSPIData <= OneOfNDecode(BSPIs,BSPIDataSel,writestb,Aint(7 downto 6)); -- 4 max
737-
-- ReadBSPIData <= OneOfNDecode(BSPIs,BSPIDataSel,Readstb,Aint(7 downto 6));
738-
-- LoadBSPIDescriptor<= OneOfNDecode(BSPIs,BSPIDescriptorSel,writestb,Aint(5 downto 2));
739-
-- ReadBSPIFIFOCOunt <= OneOfNDecode(BSPIs,BSPIFIFOCountSel,Readstb,Aint(5 downto 2));
740-
-- ClearBSPIFIFO <= OneOfNDecode(BSPIs,BSPIFIFOCountSel,writestb,Aint(5 downto 2));
741-
-- end process BSPIDecodeProcess;
742-
--
743-
-- DoBSPIPins: process(BSPIFrame, BSPIOut, BSPIClk, BSPICS, IOBitsCorein)
744-
-- begin
745-
-- for i in 0 to IOWidth -1 loop -- loop through all the external I/O pins
746-
-- if ThePinDesc(i)(15 downto 8) = BSPITag then
747-
-- case (ThePinDesc(i)(7 downto 0)) is --secondary pin function, drop MSB
748-
-- when BSPIFramePin =>
749-
-- IOBitsCorein(i) <= BSPIFrame(conv_integer(ThePinDesc(i)(23 downto 16)));
750-
-- when BSPIOutPin =>
751-
-- IOBitsCorein(i) <= BSPIOut(conv_integer(ThePinDesc(i)(23 downto 16)));
752-
-- when BSPIClkPin =>
753-
-- IOBitsCorein(i) <= BSPIClk(conv_integer(ThePinDesc(i)(23 downto 16)));
754-
-- when BSPIInPin =>
755-
-- BSPIIn(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBitsCorein(i);
756-
-- when others =>
757-
-- IOBitsCorein(i) <= BSPICS(conv_integer(ThePinDesc(i)(23 downto 16)))(conv_integer(ThePinDesc(i)(6 downto 0))-5);
758-
-- magic foo, magic foo, what on earth does it do?
759-
-- (this needs to written more clearly!)
760-
-- end case;
761-
-- end if;
762-
-- end loop;
763-
-- end process;
764-
-- end generate;
765-
--
766-
-- makedbspimod: if DBSPIs >0 generate
767-
-- signal LoadDBSPIData: std_logic_vector(DBSPIs -1 downto 0);
768-
-- signal ReadDBSPIData: std_logic_vector(DBSPIs -1 downto 0);
769-
-- signal LoadDBSPIDescriptor: std_logic_vector(DBSPIs -1 downto 0);
770-
-- signal ReadDBSPIFIFOCOunt: std_logic_vector(DBSPIs -1 downto 0);
771-
-- signal ClearDBSPIFIFO: std_logic_vector(DBSPIs -1 downto 0);
772-
-- signal DBSPIClk: std_logic_vector(DBSPIs -1 downto 0);
773-
-- signal DBSPIIn: std_logic_vector(DBSPIs -1 downto 0);
774-
-- signal DBSPIOut: std_logic_vector(DBSPIs -1 downto 0);
775-
-- type DBSPICSType is array(DBSPIs-1 downto 0) of std_logic_vector(DBSPICSWidth-1 downto 0);
776-
-- signal DBSPICS : DBSPICSType;
777-
-- signal DBSPIDataSel : std_logic;
778-
-- signal DBSPIFIFOCountSel : std_logic;
779-
-- signal DBSPIDescriptorSel : std_logic;
780-
-- begin
781-
-- makedbspis: for i in 0 to DBSPIs -1 generate
782-
-- bspi: entity work.BufferedSPI
783-
-- generic map (
784-
-- cswidth => DBSPICSWidth,
785-
-- gatedcs => true
786-
-- )
787-
-- port map (
788-
-- clk => clklow,
789-
-- ibus => ibusint,
790-
-- obus => obusint,
791-
-- addr => Aint(5 downto 2),
792-
-- hostpush => LoadDBSPIData(i),
793-
-- hostpop => ReadDBSPIData(i),
794-
-- loaddesc => LoadDBSPIDescriptor(i),
795-
-- loadasend => '0',
796-
-- clear => ClearDBSPIFIFO(i),
797-
-- readcount => ReadDBSPIFIFOCount(i),
798-
-- spiclk => DBSPIClk(i),
799-
-- spiin => DBSPIIn(i),
800-
-- spiout => DBSPIOut(i),
801-
-- spicsout => DBSPICS(i)
802-
-- );
803-
-- end generate;
804-
--
805-
-- DBSPIDecodeProcess : process (Aint,Readstb,writestb,DBSPIDataSel,DBSPIFIFOCountSel,DBSPIDescriptorSel)
806-
-- begin
807-
-- if Aint(AddrWidth-1 downto 8) = DBSPIDataAddr then -- DBSPI data register select
808-
-- DBSPIDataSel <= '1';
809-
-- else
810-
-- DBSPIDataSel <= '0';
811-
-- end if;
812-
-- if Aint(AddrWidth-1 downto 8) = DBSPIFIFOCountAddr then -- DBSPI FIFO count register select
813-
-- DBSPIFIFOCountSel <= '1';
814-
-- else
815-
-- DBSPIFIFOCountSel <= '0';
816-
-- end if;
817-
-- if Aint(AddrWidth-1 downto 8) = DBSPIDescriptorAddr then -- DBSPI channel descriptor register select
818-
-- DBSPIDescriptorSel <= '1';
819-
-- else
820-
-- DBSPIDescriptorSel <= '0';
821-
-- end if;
822-
-- LoadDBSPIData <= OneOfNDecode(DBSPIs,DBSPIDataSel,writestb,Aint(7 downto 6)); -- 4 max
823-
-- ReadDBSPIData <= OneOfNDecode(DBSPIs,DBSPIDataSel,Readstb,Aint(7 downto 6));
824-
-- LoadDBSPIDescriptor<= OneOfNDecode(DBSPIs,DBSPIDescriptorSel,writestb,Aint(5 downto 2));
825-
-- ReadDBSPIFIFOCOunt <= OneOfNDecode(DBSPIs,DBSPIFIFOCountSel,Readstb,Aint(5 downto 2));
826-
-- ClearDBSPIFIFO <= OneOfNDecode(DBSPIs,DBSPIFIFOCountSel,writestb,Aint(5 downto 2));
827-
-- end process DBSPIDecodeProcess;
828-
--
829-
-- DoDBSPIPins: process(DBSPIOut, DBSPIClk, DBSPICS, IOBitsCorein)
830-
-- begin
831-
-- for i in 0 to IOWidth -1 loop -- loop through all the external I/O pins
832-
-- if ThePinDesc(i)(15 downto 8) = DBSPITag then
833-
-- case (ThePinDesc(i)(7 downto 0)) is --secondary pin function, drop MSB
834-
-- when DBSPIOutPin =>
835-
-- IOBitsCorein(i) <= DBSPIOut(conv_integer(ThePinDesc(i)(23 downto 16)));
836-
-- when DBSPIClkPin =>
837-
-- IOBitsCorein(i) <= DBSPIClk(conv_integer(ThePinDesc(i)(23 downto 16))); when DBSPIInPin =>
838-
-- DBSPIIn(conv_integer(ThePinDesc(i)(23 downto 16))) <= IOBitsCorein(i);
839-
-- when others =>
840-
-- IOBitsCorein(i) <= DBSPICS(conv_integer(ThePinDesc(i)(23 downto 16)))(conv_integer(ThePinDesc(i)(6 downto 0))-5);
841-
-- magic foo, magic foo, what on earth does it do?
842-
-- (this needs to written more clearly!)
843-
-- end case;
844-
-- end if;
845-
-- end loop;
846-
-- end process;
847-
--
848-
-- DoLocalDDBSPIPins: process(LIOBits,DBSPICS,DBSPIClk,DBSPIOut) -- only for 4I69 LIO currently
849-
-- begin
850-
-- for i in 0 to LIOWidth -1 loop -- loop through all the local I/O pins
851-
-- report("Doing DBSPI LIOLoop: "& integer'image(i));
852-
-- if ThePinDesc(i+IOWidth)(15 downto 8) = DBSPITag then -- GTag (Local I/O starts at end of external I/O)
853-
-- case (ThePinDesc(i+IOWidth)(7 downto 0)) is --secondary pin function, drop MSB
854-
-- when DBSPIOutPin =>
855-
-- LIOBits(i) <= DBSPIOut(conv_integer(ThePinDesc(i+IOWidth)(23 downto 16)));
856-
-- report("Local DBSPIOutPin found at LIOBit " & integer'image(i));
857-
-- when DBSPIClkPin =>
858-
-- LIOBits(i) <= DBSPIClk(conv_integer(ThePinDesc(i+IOWidth)(23 downto 16)));
859-
-- report("Local DBSPClkPin found at LIOBit " & integer'image(i));
860-
-- when DBSPIInPin =>
861-
-- DBSPIIn(conv_integer(ThePinDesc(i+IOWidth)(23 downto 16))) <= LIOBits(i);
862-
-- report("Local DBSPIInPin found at LIOBit " & integer'image(i));
863-
-- when others =>
864-
-- LIOBits(i) <= DBSPICS(conv_integer(ThePinDesc(i+IOWidth)(23 downto 16)))(conv_integer(ThePinDesc(i+IOWidth)(6 downto 0))-5);
865-
-- report("Local DBSPICSPin found at LIOBit " & integer'image(i));
866-
-- magic foo, magic foo, what on earth does it do?
867-
-- (this needs to written more clearly!)
868-
-- end case;
869-
-- end if;
870-
-- end loop;
871-
-- end process;
872-
-- end generate;
678+
GenMakeDBSPIs: if DBSPIs >0 generate
679+
MakeDBSPIs : entity work.MakeDBSPIs
680+
generic map (
681+
ThePinDesc => ThePinDesc,
682+
ClockHigh => ClockHigh,
683+
ClockMed => ClockMed,
684+
ClockLow => ClockLow,
685+
BusWidth => BusWidth,
686+
AddrWidth => AddrWidth,
687+
IOWidth => IOWidth,
688+
STEPGENs => STEPGENs,
689+
StepGenTableWidth => StepGenTableWidth,
690+
UseStepGenPreScaler => UseStepGenPreScaler,
691+
UseStepgenIndex => UseStepgenIndex,
692+
UseStepgenProbe => UseStepgenProbe,
693+
timersize => 14,
694+
asize => 48,
695+
rsize => 32,
696+
HM2DPLLs => HM2DPLLs,
697+
MuxedQCounters => MuxedQCounters,
698+
MuxedQCountersMIM => MuxedQCountersMIM,
699+
PWMGens => PWMGens,
700+
PWMRefWidth => PWMRefWidth,
701+
UsePWMEnas => UsePWMEnas,
702+
TPPWMGens => TPPWMGens,
703+
QCounters => QCounters,
704+
UseMuxedProbe => UseMuxedProbe,
705+
UseProbe => UseProbe,
706+
SPIs => SPIs,
707+
BSPIs => BSPIs,
708+
BSPICSWidth => BSPICSWidth,
709+
DBSPIs => DBSPIs,
710+
DBSPICSWidth => DBSPICSWidth
711+
)
712+
port map (
713+
ibus => ibusint,
714+
obusint => obusint,
715+
Aint => Aint,
716+
readstb => readstb,
717+
writestb => writestb,
718+
CoreDataOut => CoreDataOut,
719+
IOBitsCorein => IOBitsCorein,
720+
clklow => clklow,
721+
clkmed => clkmed,
722+
clkhigh => clkhigh,
723+
PRobe => PRobe,
724+
RateSources => RateSources,
725+
rates => rates
726+
);
727+
end generate;
728+
873729
--
874730
-- makesssimod: if SSSIs >0 generate
875731
-- signal LoadSSSIData0: std_logic_vector(SSSIs -1 downto 0);

0 commit comments

Comments
 (0)