2

I want to return values of A,B, and Y at time values 7.5 ns, 15 ns, 22.5 ns, etc during my simulation. Below is the code I've implemented thus far (for the for loop). Mathemitically it makes sense, but it's returning values at times 7.5 ns, 30 ns, 67.5 ns, 120 ns,.... I can't figure out where my code is wrong. Do you know of a better way to implement this?

constant InputPeriod : time := 15 ns;

----------------------------------
TEST:process

variable n : integer range 1 to 9;

begin   

        for I in 0 to 4 loop
            wait for (n * (InputPeriod / 2)); 
            report "A: " & std_logic'image(A);
            report "B: " & std_logic'image(B);
            report "Y: " & std_logic'image(Y);  

            n := n + 2;
        end loop;

    report "Test Completed";
   wait;
end process TEST;
  • 1
    It's doing exactly what you ask. It first waits for 1 * 7.5 ns. Then you add 2 to n so it waits 3 * 7.5 ns (22.5 ns) and outputs at 30ns. Then it waits 5 * 7.5 ns and so on. If you want to output at 7.5, 15, 22.5 ns, then simply arrange for it to wait 7.5 ns each time. –  Jul 29 '15 at 18:04
  • "Then you add 2 to n so it waits 3 * 7.5 ns (22.5 ns) and outputs at 30ns." Why does it suddenly add 7.5 ns and then output at 30 ns? – user5153260 Jul 29 '15 at 18:09
  • 1
    It doesn't "suddenly add 7.5 ns". It's already waited 7.5ns first time round the loop. –  Jul 29 '15 at 18:16
  • I guess I just don't know how to adjust the code to remove that and still allow for a variable InputPeriod – user5153260 Jul 29 '15 at 18:23
  • As the statement `wait for` says, it's a relative time span not an absolute value since simulation start. Solution: a) remove `n` b) `wait for (InputPeriod / 2);` – Paebbels Jul 29 '15 at 18:28
  • Unrelated to your question but I'd suggest to use `& LF &` to insert a line feed instead of using `report` 3 times. This will make the report shorter and easier to read. – privera Jul 30 '15 at 16:02

0 Answers0