Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:37:44+00:00 2026-05-23T10:37:44+00:00

Is there a TAP (Test Anything Protocol) implementation for VHDL? It would be nice

  • 0

Is there a TAP (Test Anything Protocol) implementation for VHDL? It would be nice because then I could use prove to check my results automatically. There are also nice formatting swuites such as smolder that can process it output. You might ask why not use assertions. Partly TAP gives me some good reporting such as number of files and number of tests. I’m looking for a minimal implentation with number of tests at the beginning and end and the ok, diag and fail functions. is() would really nice, but not necessary. I could write this, but why reinvent the wheel.

This is the question as in this question but for VHDL instead of Verilog.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:37:44+00:00Added an answer on May 23, 2026 at 10:37 am

    I wrote one that I’ve used a lot, but I’ve never distributed it. Here it is (the not-included base_pkg mostly has to_string() implementations for everything).

    -- Copyright © 2010 Wesley J. Landaker <wjl@icecavern.net>
    -- 
    -- This program is free software: you can redistribute it and/or modify
    -- it under the terms of the GNU General Public License as published by
    -- the Free Software Foundation, either version 3 of the License, or
    -- (at your option) any later version.
    
    -- 
    -- This program is distributed in the hope that it will be useful,
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    -- GNU General Public License for more details.
    -- 
    -- You should have received a copy of the GNU General Public License
    -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    -- Output is standard TAP (Test Anything Protocol) version 13
    
    package test_pkg is
    
      procedure test_redirect(filename : string);
      procedure test_plan(tests : natural; directive : string := "");
      procedure test_abort(reason : string);
      procedure test_finished(directive : string := "");
      procedure test_comment (message : string);
      procedure test_pass (description : string := ""; directive : string := "");
      procedure test_fail (description : string := ""; directive : string := "");
      procedure test_ok   (result : boolean; description : string := ""; directive : string := "");
      procedure test_equal(actual, expected : integer; description : string := ""; directive : string := "");
      procedure test_equal(actual, expected : real; description : string := ""; directive : string := "");
      procedure test_equal(actual, expected : time; description : string := ""; directive : string := "");
      procedure test_equal(actual, expected : string; description : string := ""; directive : string := "");
      procedure test_equal(actual, expected : bit_vector; description : string := ""; directive : string := "");
      procedure test_approx_absolute(actual, expected, absolute_error : real; description : string := ""; directive : string := "");
      procedure test_approx_relative(actual, expected, relative_error : real; description : string := ""; directive : string := "");
    
    end package;
    
    use std.textio.all;
    use work.base_pkg.all;
    
    package body test_pkg is
    
      file test_output : text;
      shared variable initialized : boolean := false;
      shared variable have_plan : boolean := false;
      shared variable last_test_number : natural := 0;
    
      function remove_eol(s : string) return string is
        variable s_no_eol : string(s'range);
      begin
        for i in s'range loop
          case s(i) is
            when LF | CR => s_no_eol(i) := '_';
            when others  => s_no_eol(i) := s(i);
          end case;
        end loop;
        return s_no_eol;
      end function;
    
      function make_safe (s : string) return string is
        variable s_no_hash : string(s'range);
      begin
        for i in s'range loop
          case s(i) is
            when '#'    => s_no_hash(i) := '_';
            when others => s_no_hash(i) := s(i);
          end case;
        end loop;
        return remove_eol(s_no_hash);
      end function;
    
      procedure init is
        variable l : line;
      begin
        if initialized then
          return;
        end if;
        initialized := true;
        file_open(test_output, "STD_OUTPUT", write_mode);
        write(l, string'("TAP version 13"));
        writeline(test_output, l);
      end procedure;
    
      procedure test_redirect(filename : string) is
      begin
        init;
        file_close(test_output);
        file_open(test_output, filename, write_mode);
      end procedure;
    
      procedure test_plan(tests : natural; directive : string := "") is
        variable l : line;
      begin
        init;
        have_plan := true;
        write(l, string'("1.."));
        write(l, tests);
        if directive'length > 0 then
          write(l, " # " & remove_eol(directive));
        end if;
        writeline(test_output, l);
      end procedure;
    
      procedure test_abort(reason : string) is
        variable l : line;
      begin
        init;
        write(l, "Bail out! " & remove_eol(reason));
        writeline(test_output, l);
        assert false
          report "abort called"
          severity failure;
      end procedure;
    
      procedure test_finished (directive : string := "") is
      begin
        if not have_plan then
          test_plan(last_test_number, directive);
        elsif directive'length > 0 then
          test_comment("1.." & integer'image(last_test_number) & " # " & directive);
        else
          test_comment("1.." & integer'image(last_test_number));
        end if;
      end procedure;
    
      procedure test_comment (message : string) is
        variable l : line;
      begin
        init;
        write(l, '#');
        if message'length > 0 then
          write(l, " " & remove_eol(message));
        end if;
        writeline(test_output, l);
      end procedure;
    
      procedure result (status : string; description : string; directive : string) is
        variable l : line;
      begin
        init;
        last_test_number := last_test_number + 1;
        write(l, status & " ");
        write(l, last_test_number);
        if description'length > 0 then
          write(l, " " & make_safe(description));
        end if;
        if directive'length > 0 then
          write(l, " # " & remove_eol(directive));
        end if;
        writeline(test_output, l);
      end procedure;
    
      procedure test_pass (description : string := ""; directive : string := "") is
      begin
        result("ok", description, directive);
      end procedure;
    
      procedure test_fail (description : string := ""; directive : string := "") is
      begin
        result("not ok", description, directive);
      end procedure;
    
      procedure test_ok (result : boolean; description : string := ""; directive : string := "") is
      begin
        if result then
          test_pass(description, directive);
        else
          test_fail(description, directive);
        end if;
      end procedure;
    
      procedure test_equal(actual, expected : integer; description : string := ""; directive : string := "") is
        variable ok : boolean := actual = expected;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & integer'image(actual) & ", expected = " & integer'image(expected));
        end if;
      end procedure;
    
      procedure test_equal(actual, expected : real; description : string := ""; directive : string := "") is
        variable ok : boolean := actual = expected;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & real'image(actual) & ", expected = " & real'image(expected));
        end if;
      end procedure;
    
      procedure test_equal(actual, expected : time; description : string := ""; directive : string := "") is
        variable ok : boolean := actual = expected;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & time'image(actual) & ", expected = " & time'image(expected));
        end if;
      end procedure;
    
      procedure test_equal(actual, expected : string; description : string := ""; directive : string := "") is
        variable ok : boolean := actual = expected;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & actual & ", expected = " & expected);
        end if;
      end procedure;
    
      procedure test_equal(actual, expected : bit_vector; description : string := ""; directive : string := "") is
        variable ok : boolean := actual = expected;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & to_string(actual) & ", expected = " & to_string(expected));
        end if;
      end procedure;
    
      procedure test_approx_absolute(actual, expected, absolute_error : real; description : string := ""; directive : string := "") is
        variable err : real := abs(actual - expected);
        variable ok : boolean := err <= absolute_error;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & to_string(actual) & ", expected = " & to_string(expected) & ", absolute error = " & to_string(err));
        end if;
      end procedure;
    
      procedure test_approx_relative(actual, expected, relative_error : real; description : string := ""; directive : string := "") is
        variable err : real := abs(actual - expected)/abs(expected);
        variable ok : boolean := err <= relative_error;
      begin
        test_ok(ok, description, directive);
        if not ok then
          test_comment("actual = " & to_string(actual) & ", expected = " & to_string(expected) & ", relative error = " & to_string(err));
        end if;
      end procedure;
    
    end package body;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to cascade UIGestureRecognizers to detect a tap and then drag.
I was wondering is there a way that I could have my code tap
Is there an API to tap to Apple's Bonjour service (I'm planning to share
Is there an event that I can tap into in Global.asax to execute some
Is there a complete list of the objects you can tap into with <%$
I added a text field, and when I tap in there, the keyboard slides
Is there a way to stop a UISwitch from toggling state when you tap
There was another question with an answer saying that you can use event.down.x to
There is double tap to zoom / pinch to zoom ImageView (ImageViewTouch) from here
I need to detect the user finger-press, there's already the tap event, but tap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.