|
| 1 | +-- EMACS settings: -*- tab-width: 2; indent-tabs-mode: t -*- |
| 2 | +-- vim: tabstop=2:shiftwidth=2:noexpandtab |
| 3 | +-- kate: tab-width 2; replace-tabs off; indent-width 2; |
| 4 | +-- ============================================================================= |
| 5 | +-- Authors: Thomas B. Preusser |
| 6 | +-- Gustavo Martin |
| 7 | +-- |
| 8 | +-- Entity: arith_addw_Simple |
| 9 | +-- |
| 10 | +-- Description: |
| 11 | +-- ------------------------------------- |
| 12 | +-- Simple OSVVM test for arith_addw |
| 13 | +-- |
| 14 | +-- License: |
| 15 | +-- ============================================================================= |
| 16 | +-- Copyright 2025-2025 The PoC-Library Authors |
| 17 | +-- |
| 18 | +-- Licensed under the Apache License, Version 2.0 (the "License"); |
| 19 | +-- you may not use this file except in compliance with the License. |
| 20 | +-- You may obtain a copy of the License at |
| 21 | +-- |
| 22 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 23 | +-- |
| 24 | +-- Unless required by applicable law or agreed to in writing, software |
| 25 | +-- distributed under the License is distributed on an "AS IS" BASIS, |
| 26 | +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 27 | +-- See the License for the specific language governing permissions and |
| 28 | +-- limitations under the License. |
| 29 | +-- ============================================================================= |
| 30 | + |
| 31 | +library IEEE; |
| 32 | +use IEEE.std_logic_1164.all; |
| 33 | +use IEEE.numeric_std.all; |
| 34 | + |
| 35 | +library osvvm; |
| 36 | +context osvvm.OsvvmContext; |
| 37 | + |
| 38 | +library PoC; |
| 39 | +use PoC.strings.all; |
| 40 | +use PoC.physical.all; |
| 41 | +use PoC.arith.all; |
| 42 | + |
| 43 | +use work.arith_addw_TestController_pkg.all; |
| 44 | + |
| 45 | +architecture Simple of arith_addw_TestController is |
| 46 | + signal TestDone : integer_barrier := 1; |
| 47 | + constant TCID : AlertLogIDType := NewID("AddWTest"); |
| 48 | + constant TPERIOD_CLOCK : time := 10 ns; |
| 49 | + |
| 50 | +begin |
| 51 | + |
| 52 | + ControlProc: process |
| 53 | + constant ProcID : AlertLogIDType := NewID("ControlProc", TCID); |
| 54 | + constant TIMEOUT : time := 10 ms; |
| 55 | + begin |
| 56 | + SetTestName("arith_addw_Simple"); |
| 57 | + |
| 58 | + SetLogEnable(PASSED, FALSE); |
| 59 | + SetLogEnable(INFO, FALSE); |
| 60 | + SetLogEnable(DEBUG, FALSE); |
| 61 | + wait for 0 ns; wait for 0 ns; |
| 62 | + |
| 63 | + TranscriptOpen; |
| 64 | + SetTranscriptMirror(TRUE); |
| 65 | + |
| 66 | + wait until Reset = '0'; |
| 67 | + ClearAlerts; |
| 68 | + |
| 69 | + WaitForBarrier(TestDone, TIMEOUT); |
| 70 | + AlertIf(ProcID, now >= TIMEOUT, "Test finished due to timeout"); |
| 71 | + AlertIf(ProcID, GetAffirmCount < 1, "Test is not Self-Checking"); |
| 72 | + |
| 73 | + EndOfTestReports(ReportAll => TRUE); |
| 74 | + std.env.stop; |
| 75 | + end process; |
| 76 | + |
| 77 | + CheckerProc: process |
| 78 | + constant ProcID : AlertLogIDType := NewID("CheckerProc", TCID); |
| 79 | + variable ai, bi : integer; |
| 80 | + variable expected : natural; |
| 81 | + variable actual_sum : unsigned(9 downto 0); |
| 82 | + begin |
| 83 | + wait until Reset = '0'; |
| 84 | + WaitForClock(Clock); |
| 85 | + |
| 86 | + for i in 0 to 2**9-1 loop |
| 87 | + a <= std_logic_vector(to_unsigned(i, 9)); |
| 88 | + for j in 0 to 2**9-1 loop |
| 89 | + b <= std_logic_vector(to_unsigned(j, 9)); |
| 90 | + cin <= '0'; |
| 91 | + WaitForClock(Clock); |
| 92 | + for arch in tArch loop |
| 93 | + for skip in tSkipping loop |
| 94 | + -- Test with P_INCLUSIVE = false |
| 95 | + expected := (i + j) mod 2**10; |
| 96 | + actual_sum := unsigned(cout(arch, skip, false) & s(arch, skip, false)); |
| 97 | + AffirmIf(ProcID, expected = to_integer(actual_sum), |
| 98 | + "Output Error: " & integer'image(i) & "+" & integer'image(j) & |
| 99 | + " arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=false" |
| 100 | + ); |
| 101 | + |
| 102 | + -- Test with P_INCLUSIVE = true |
| 103 | + actual_sum := unsigned(cout(arch, skip, true) & s(arch, skip, true)); |
| 104 | + AffirmIf(ProcID, expected = to_integer(actual_sum), |
| 105 | + "Output Error: " & integer'image(i) & "+" & integer'image(j) & |
| 106 | + " arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=true" |
| 107 | + ); |
| 108 | + end loop; |
| 109 | + end loop; |
| 110 | + |
| 111 | + cin <= '1'; |
| 112 | + WaitForClock(Clock); |
| 113 | + for arch in tArch loop |
| 114 | + for skip in tSkipping loop |
| 115 | + -- Test with P_INCLUSIVE = false |
| 116 | + expected := (i + j + 1) mod 2**10; |
| 117 | + actual_sum := unsigned(cout(arch, skip, false) & s(arch, skip, false)); |
| 118 | + AffirmIf(ProcID, expected = to_integer(actual_sum), |
| 119 | + "Output Error with carry: " & integer'image(i) & "+" & integer'image(j) & "+1" & |
| 120 | + " arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=false" |
| 121 | + ); |
| 122 | + |
| 123 | + -- Test with P_INCLUSIVE = true |
| 124 | + actual_sum := unsigned(cout(arch, skip, true) & s(arch, skip, true)); |
| 125 | + AffirmIf(ProcID, expected = to_integer(actual_sum), |
| 126 | + "Output Error with carry: " & integer'image(i) & "+" & integer'image(j) & "+1" & |
| 127 | + " arch=" & tArch'image(arch) & " skip=" & tSkipping'image(skip) & " incl=true" |
| 128 | + ); |
| 129 | + end loop; |
| 130 | + end loop; |
| 131 | + |
| 132 | + end loop; |
| 133 | + end loop; |
| 134 | + |
| 135 | + WaitForBarrier(TestDone); |
| 136 | + wait; |
| 137 | + end process; |
| 138 | +end architecture; |
| 139 | + |
| 140 | +configuration arith_addw_Simple of arith_addw_TestHarness is |
| 141 | + for TestHarness |
| 142 | + for TestCtrl: arith_addw_TestController |
| 143 | + use entity work.arith_addw_TestController(Simple); |
| 144 | + end for; |
| 145 | + end for; |
| 146 | +end configuration; |
0 commit comments