Refactor KittCarPWM logic for improved LED direction handling and clean up Vivado project settings

This commit is contained in:
2025-03-21 17:47:28 +01:00
parent 038ea73291
commit f6c568b416
2 changed files with 16 additions and 18 deletions

View File

@@ -86,12 +86,13 @@ BEGIN
leds_sr <= (OTHERS => 0); leds_sr <= (OTHERS => 0);
led_sig <= (OTHERS => '0'); led_sig <= (OTHERS => '0');
counter := (OTHERS => '0'); counter := (OTHERS => '0');
up <= '1';
ELSIF rising_edge(clk) THEN ELSIF rising_edge(clk) THEN
-- Kitt logic -- Kitt logic: Update direction
IF leds_sr(TAIL_LENGTH - 1) = 15 THEN IF leds_sr(TAIL_LENGTH - 1) = led'high THEN
up <= '0'; up <= '0';
ELSIF leds_sr(TAIL_LENGTH - 1) = 0 THEN ELSIF leds_sr(TAIL_LENGTH - 1) = led'low THEN
up <= '1'; up <= '1';
END IF; END IF;
@@ -101,17 +102,17 @@ BEGIN
-- Calculate the number of periods -- Calculate the number of periods
IF counter >= (MIN_KITT_CAR_STEP_NS * n_period) THEN IF counter >= (MIN_KITT_CAR_STEP_NS * n_period) THEN
-- Shift the leds -- Reset led_sig
IF up = '1' THEN
leds_sr <= (leds_sr(TAIL_LENGTH - 1) + 1) & leds_sr(TAIL_LENGTH - 2 DOWNTO 0);
ELSIF up = '0' THEN
leds_sr <= (leds_sr(TAIL_LENGTH - 1) - 1) & leds_sr(TAIL_LENGTH - 2 DOWNTO 0);
END IF;
-- Reset leg_sig
led_sig <= (OTHERS => '0'); led_sig <= (OTHERS => '0');
-- Assign the leds -- Shift the leds
IF up = '1' THEN
leds_sr <= (leds_sr(TAIL_LENGTH - 1) + 1) & leds_sr(TAIL_LENGTH - 1 DOWNTO 1);
ELSE
leds_sr <= (leds_sr(TAIL_LENGTH - 1) - 1) & leds_sr(TAIL_LENGTH - 1 DOWNTO 1);
END IF;
-- Assign the LEDs
FOR i IN 0 TO TAIL_LENGTH - 1 LOOP FOR i IN 0 TO TAIL_LENGTH - 1 LOOP
led_sig(leds_sr(i)) <= leds_pwm(i); led_sig(leds_sr(i)) <= leds_pwm(i);
END LOOP; END LOOP;

View File

@@ -106,6 +106,7 @@
</Config> </Config>
</FileSet> </FileSet>
<FileSet Name="sim_1" Type="SimulationSrcs" RelSrcDir="$PSRCDIR/sim_1" RelGenDir="$PGENDIR/sim_1"> <FileSet Name="sim_1" Type="SimulationSrcs" RelSrcDir="$PSRCDIR/sim_1" RelGenDir="$PGENDIR/sim_1">
<Filter Type="Srcs"/>
<Config> <Config>
<Option Name="DesignMode" Val="RTL"/> <Option Name="DesignMode" Val="RTL"/>
<Option Name="TopModule" Val="KittCarPWM"/> <Option Name="TopModule" Val="KittCarPWM"/>
@@ -149,9 +150,7 @@
<Runs Version="1" Minor="15"> <Runs Version="1" Minor="15">
<Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" AutoIncrementalCheckpoint="false" WriteIncrSynthDcp="false" State="current" Dir="$PRUNDIR/synth_1" IncludeInArchive="true" AutoIncrementalDir="$PSRCDIR/utils_1/imports/synth_1"> <Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" AutoIncrementalCheckpoint="false" WriteIncrSynthDcp="false" State="current" Dir="$PRUNDIR/synth_1" IncludeInArchive="true" AutoIncrementalDir="$PSRCDIR/utils_1/imports/synth_1">
<Strategy Version="1" Minor="2"> <Strategy Version="1" Minor="2">
<StratHandle Name="Vivado Synthesis Defaults" Flow="Vivado Synthesis 2020"> <StratHandle Name="Vivado Synthesis Defaults" Flow="Vivado Synthesis 2020"/>
<Desc>Vivado Synthesis Defaults</Desc>
</StratHandle>
<Step Id="synth_design"/> <Step Id="synth_design"/>
</Strategy> </Strategy>
<GeneratedRun Dir="$PRUNDIR" File="gen_run.xml"/> <GeneratedRun Dir="$PRUNDIR" File="gen_run.xml"/>
@@ -161,9 +160,7 @@
</Run> </Run>
<Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." AutoIncrementalCheckpoint="false" WriteIncrSynthDcp="false" State="current" Dir="$PRUNDIR/impl_1" SynthRun="synth_1" IncludeInArchive="true" GenFullBitstream="true" AutoIncrementalDir="$PSRCDIR/utils_1/imports/impl_1"> <Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." AutoIncrementalCheckpoint="false" WriteIncrSynthDcp="false" State="current" Dir="$PRUNDIR/impl_1" SynthRun="synth_1" IncludeInArchive="true" GenFullBitstream="true" AutoIncrementalDir="$PSRCDIR/utils_1/imports/impl_1">
<Strategy Version="1" Minor="2"> <Strategy Version="1" Minor="2">
<StratHandle Name="Vivado Implementation Defaults" Flow="Vivado Implementation 2020"> <StratHandle Name="Vivado Implementation Defaults" Flow="Vivado Implementation 2020"/>
<Desc>Default settings for Implementation.</Desc>
</StratHandle>
<Step Id="init_design"/> <Step Id="init_design"/>
<Step Id="opt_design"/> <Step Id="opt_design"/>
<Step Id="power_opt_design"/> <Step Id="power_opt_design"/>