aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-03-15 14:01:42 +0100
committerTristan Gingold <tgingold@free.fr>2019-03-15 14:01:42 +0100
commit429e36bf14976d2bb3f173cbc99c204ac3a5994a (patch)
tree80a01fb59b65edbc13ec10f8f08c1f968db16813
parent6e8e0f9d3ca375a29fafc81314d98e6df834e86d (diff)
downloadghdl-429e36bf14976d2bb3f173cbc99c204ac3a5994a.tar.gz
ghdl-429e36bf14976d2bb3f173cbc99c204ac3a5994a.tar.bz2
ghdl-429e36bf14976d2bb3f173cbc99c204ac3a5994a.zip
Add testcase for #736
-rw-r--r--testsuite/gna/issue736/repro.vhdl31
-rw-r--r--testsuite/gna/issue736/simple_fsm.vhdl46
-rw-r--r--testsuite/gna/issue736/tb_simple_fsm.vhdl92
-rwxr-xr-xtestsuite/gna/issue736/testsuite.sh14
4 files changed, 183 insertions, 0 deletions
diff --git a/testsuite/gna/issue736/repro.vhdl b/testsuite/gna/issue736/repro.vhdl
new file mode 100644
index 000000000..3ac0b65d5
--- /dev/null
+++ b/testsuite/gna/issue736/repro.vhdl
@@ -0,0 +1,31 @@
+entity repro is
+end repro;
+
+architecture behav of repro is
+ signal a, i, r : bit;
+begin
+ process (all)
+ begin
+ r <= a when i = '0' else not a;
+ end process;
+
+ process
+ begin
+ i <= '0';
+ a <= '1';
+ wait for 1 ns;
+ assert r = '1' severity failure;
+
+ i <= '0';
+ a <= '0';
+ wait for 1 ns;
+ assert r = '0' severity failure;
+
+ i <= '1';
+ a <= '1';
+ wait for 1 ns;
+ assert r = '0' severity failure;
+
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/issue736/simple_fsm.vhdl b/testsuite/gna/issue736/simple_fsm.vhdl
new file mode 100644
index 000000000..dfc871ba9
--- /dev/null
+++ b/testsuite/gna/issue736/simple_fsm.vhdl
@@ -0,0 +1,46 @@
+--Standard Library
+library ieee;
+--Standard Packages
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity simple_fsm is
+ port (
+ clk : in std_logic;
+ rst : in std_logic;
+
+ valid : in std_logic;
+ invalid : in std_logic
+ );
+end simple_fsm;
+
+architecture rtl of simple_fsm is
+
+ type t_states is (e_IDLE, e_S1);
+ signal p_state : t_states := e_IDLE;
+ signal n_state : t_states;
+
+begin
+
+ p_sync_fsm : process(clk)
+ begin
+ if rising_edge(clk) then
+ if (rst = '1') then
+ p_state <= e_IDLE;
+ else
+ p_state <= n_state;
+ end if;
+ end if;
+ end process;
+
+ p_comb_fsm : process (all)
+ begin
+ case p_state is
+ when e_IDLE =>
+ n_state <= e_S1 when valid = '1' else e_IDLE;
+ when e_S1 =>
+ n_state <= e_IDLE when (valid = '0' and invalid = '1') else e_S1;
+ end case;
+ end process;
+
+end rtl;
diff --git a/testsuite/gna/issue736/tb_simple_fsm.vhdl b/testsuite/gna/issue736/tb_simple_fsm.vhdl
new file mode 100644
index 000000000..6db54a67e
--- /dev/null
+++ b/testsuite/gna/issue736/tb_simple_fsm.vhdl
@@ -0,0 +1,92 @@
+--Standard Library
+library ieee;
+--Standard Packages
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity tb_simple_fsm is
+end tb_simple_fsm;
+
+architecture tb of tb_simple_fsm is
+
+ signal clk : std_logic := '0';
+ signal rst : std_logic := '0';
+ signal valid : std_logic := '0';
+ signal invalid : std_logic := '0';
+
+
+ -- Simulation support
+ signal clock_ena : boolean := false;
+ constant C_CLK_PERIOD : time := 10 ns;
+
+-------------------------------------------------------------------------------
+-- Clock generator procedure
+-------------------------------------------------------------------------------
+ procedure clock_gen(
+ signal clock_signal : inout std_logic;
+ signal clock_ena : in boolean;
+ constant clock_period : in time
+ ) is
+ variable v_first_half_clk_period : time := clock_period / 2;
+ begin
+ loop
+ if not clock_ena then
+ wait until clock_ena;
+ end if;
+ wait for v_first_half_clk_period;
+ clock_signal <= not clock_signal;
+ wait for (clock_period - v_first_half_clk_period);
+ clock_signal <= not clock_signal;
+ end loop;
+ end;
+
+
+begin
+
+ clock_gen(clk, clock_ena, C_CLK_PERIOD);
+
+ -----------------------------------------------------------------------------
+ -- DUT
+ -----------------------------------------------------------------------------
+ dut : entity work.simple_fsm
+ port map (
+ clk => clk,
+ rst => rst,
+ valid => valid,
+ invalid => invalid);
+
+ p_main : process
+ begin
+ wait for 100 ns;
+ rst <= '1';
+ wait for 100 ns;
+ clock_ena <= true;
+ wait for 100 ns;
+ valid <= '1';
+ wait for 100 ns;
+ valid <= '0';
+ wait for 100 ns;
+ invalid <= '1';
+ wait for 100 ns;
+ invalid <= '0';
+ wait for 100 ns;
+
+
+ rst <= '0';
+
+ wait for 100 ns;
+ valid <= '1';
+ wait for 100 ns;
+ valid <= '0';
+ wait for 100 ns;
+ invalid <= '1';
+ wait for 100 ns;
+ invalid <= '0';
+ wait for 100 ns;
+
+ -- end sim
+ clock_ena <= false;
+ wait;
+
+ end process;
+end tb;
diff --git a/testsuite/gna/issue736/testsuite.sh b/testsuite/gna/issue736/testsuite.sh
new file mode 100755
index 000000000..282eaffd1
--- /dev/null
+++ b/testsuite/gna/issue736/testsuite.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze simple_fsm.vhdl tb_simple_fsm.vhdl
+elab_simulate tb_simple_fsm
+
+analyze repro.vhdl
+elab_simulate repro
+
+clean
+
+echo "Test successful"
'n413' href='#n413'>413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716