From 59e8302a48eb3bbfcf579b98a714581880a7786d Mon Sep 17 00:00:00 2001 From: Max P Date: Sat, 13 Apr 2024 15:18:52 +0200 Subject: [PATCH] Fix single-stage pipeline validity update issue Enhanced the PipelineController's validity logic to handle single-stage configurations properly. This update ensures that the validity bit is correctly updated for systems that operate with only one pipeline stage, addressing a potential logic flaw in previous versions. Additionally, clarified documentation for random number generation in pipeline testbench. --- src/PipelineController.vhd | 9 +++++++-- tests/Pipeline_tb.vhd | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/PipelineController.vhd b/src/PipelineController.vhd index 6efc2d7..23c880e 100644 --- a/src/PipelineController.vhd +++ b/src/PipelineController.vhd @@ -1,6 +1,6 @@ ---------------------------------------------------------------------------------- --@ - Name: **Pipeline Controller** ---@ - Version: 0.0.1 +--@ - Version: 0.0.2 --@ - Author: _Maximilian Passarello ([Blog](mpassarello.de))_ --@ - License: [MIT](LICENSE) --@ @@ -46,6 +46,7 @@ --@ --@ ## History --@ - 0.0.1 (2024-03-24) Initial version +--@ - 0.0.2 (2024-04-13) Enhanced the validity update logic to correctly handle configurations with a single pipeline stage ---------------------------------------------------------------------------------- library ieee; @@ -136,7 +137,11 @@ begin R_Valid <= (others => '0'); elsif I_CE = '1' then if C_Ready = '1' then - R_Valid <= R_Valid(R_Valid'high - 1 downto R_Valid'low) & I_Valid; + if G_PipelineStages = 1 then + R_Valid(0) <= I_Valid; + else + R_Valid <= R_Valid(R_Valid'high - 1 downto R_Valid'low) & I_Valid; + end if; end if; end if; end if; diff --git a/tests/Pipeline_tb.vhd b/tests/Pipeline_tb.vhd index 7587962..522b713 100644 --- a/tests/Pipeline_tb.vhd +++ b/tests/Pipeline_tb.vhd @@ -8,8 +8,14 @@ entity Pipeline_tb is end entity Pipeline_tb; architecture behavior of Pipeline_tb is - shared variable seed1 : integer := 483; - shared variable seed2 : integer := 847; + -- Random number generator + --@ Select a random number for `seed1` to generate random numbers + shared variable seed1 : integer := 483; + --@ Select a random number for `seed2` to generate random numbers + shared variable seed2 : integer := 847; + --@ Generate a random number between `min_val` and `max_val` + --@ You must provide the `shared variable seed1` and `shared variable seed2` to generate random numbers. + --@ You need `use ieee.math_real.all;` to use this function. impure function rand_int(min_val, max_val : integer) return integer is variable r : real; begin