Skip to content

Commit

Permalink
WIP: Blog
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Jul 17, 2023
1 parent 651a613 commit 1274c1f
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 43 deletions.
429 changes: 429 additions & 0 deletions docs/blog/vhdl_configurations.rst

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions examples/vhdl/vhdl_configuration/dff.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ begin
end process;
end;

configuration dff_rtl of tb_selecting_dut_with_vhdl_configuration is
for tb
for test_fixture
for dut : dff
use entity work.dff(rtl);
end for;
end for;
end for;
end;

architecture behavioral of dff is
begin
process
Expand All @@ -50,13 +40,3 @@ begin
q <= (others => '0') when reset else d;
end process;
end;

configuration dff_behavioral of tb_selecting_dut_with_vhdl_configuration is
for tb
for test_fixture
for dut : dff
use entity work.dff(behavioral);
end for;
end for;
end for;
end;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ entity tb_selecting_dut_with_generate_statement is
generic(
runner_cfg : string;
width : positive;
dff_arch : string
dut_arch : string
);
end entity;

Expand Down Expand Up @@ -64,7 +64,7 @@ begin
begin
clk <= not clk after clk_period / 2;

dut_selection : if dff_arch = "rtl" generate
dut_selection : if dut_arch = "rtl" generate
dut : entity work.dff(rtl)
generic map(
width => width
Expand All @@ -76,7 +76,7 @@ begin
q => q
);

elsif dff_arch = "behavioral" generate
elsif dut_arch = "behavioral" generate
dut : entity work.dff(behavioral)
generic map(
width => width
Expand All @@ -89,7 +89,7 @@ begin
);

else generate
error("Unknown DFF architecture");
error("Unknown DUT architecture");
end generate;
end block;
end architecture;
2 changes: 1 addition & 1 deletion examples/vhdl/vhdl_configuration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def hook(output_path):
tb = lib.test_bench("tb_selecting_dut_with_generate_statement")
for width in [8, 32]:
for arch in ["rtl", "behavioral"]:
tb.add_config(name=f"dff_{arch}_width={width}", generics=dict(dff_arch=arch, width=width))
tb.add_config(name=f"dut_{arch}_width={width}", generics=dict(dut_arch=arch, width=width))

# Instead of having a testbench containing a shared test fixture
# and then use VHDL configurations to select different test runners implementing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ begin
begin
clk <= not clk after clk_period / 2;

dut : dff
dut : component dff
generic map(
width => width
)
Expand All @@ -90,3 +90,23 @@ begin
);
end block;
end architecture;

configuration rtl of tb_selecting_dut_with_vhdl_configuration is
for tb
for test_fixture
for dut : dff
use entity work.dff(rtl);
end for;
end for;
end for;
end;

configuration behavioral of tb_selecting_dut_with_vhdl_configuration is
for tb
for test_fixture
for dut : dff
use entity work.dff(behavioral);
end for;
end for;
end for;
end;
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ architecture tb of tb_selecting_test_runner_with_vhdl_configuration is
);
end component;

component dff is
generic(
width : positive := width
);
port(
clk : in std_logic;
reset : in std_logic;
d : in std_logic_vector(width - 1 downto 0);
q : out std_logic_vector(width - 1 downto 0)
);
end component;

begin
test_runner_inst : test_runner
generic map(
Expand All @@ -64,7 +76,7 @@ begin
begin
clk <= not clk after clk_period / 2;

dut : entity work.dff(rtl)
dut : component dff
generic map(
width => width
)
Expand Down
22 changes: 21 additions & 1 deletion examples/vhdl/vhdl_configuration/test_reset.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,30 @@ begin
test_runner_watchdog(runner, 10 * clk_period);
end;

configuration test_reset of tb_selecting_test_runner_with_vhdl_configuration is
configuration test_reset_behavioral of tb_selecting_test_runner_with_vhdl_configuration is
for tb
for test_runner_inst : test_runner
use entity work.test_runner(test_reset_a);
end for;

for test_fixture
for dut : dff
use entity work.dff(behavioral);
end for;
end for;
end for;
end;

configuration test_reset_rtl of tb_selecting_test_runner_with_vhdl_configuration is
for tb
for test_runner_inst : test_runner
use entity work.test_runner(test_reset_a);
end for;

for test_fixture
for dut : dff
use entity work.dff(rtl);
end for;
end for;
end for;
end;
22 changes: 21 additions & 1 deletion examples/vhdl/vhdl_configuration/test_state_change.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,30 @@ begin
test_runner_watchdog(runner, 10 * clk_period);
end;

configuration test_state_change of tb_selecting_test_runner_with_vhdl_configuration is
configuration test_state_change_behavioral of tb_selecting_test_runner_with_vhdl_configuration is
for tb
for test_runner_inst : test_runner
use entity work.test_runner(test_state_change_a);
end for;

for test_fixture
for dut : dff
use entity work.dff(behavioral);
end for;
end for;
end for;
end;

configuration test_state_change_rtl of tb_selecting_test_runner_with_vhdl_configuration is
for tb
for test_runner_inst : test_runner
use entity work.test_runner(test_state_change_a);
end for;

for test_fixture
for dut : dff
use entity work.dff(rtl);
end for;
end for;
end for;
end;
30 changes: 16 additions & 14 deletions tests/acceptance/test_external_run_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,24 @@ def test_vhdl_configuration_example_project(self):
check_report(
self.report_file,
[
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.dff_rtl.Test reset"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.dff_behavioral.Test reset"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.dff_rtl.Test state change"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.dff_behavioral.Test state change"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_reset"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_state_change"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.rtl.Test reset"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.behavioral.Test reset"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.rtl.Test state change"),
("passed", "lib.tb_selecting_dut_with_vhdl_configuration.behavioral.Test state change"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_reset_behavioral"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_reset_rtl"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_state_change_behavioral"),
("passed", "lib.tb_selecting_test_runner_with_vhdl_configuration.test_state_change_rtl"),
("passed", "lib.tb_reset.width=8"),
("passed", "lib.tb_reset.width=32"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_rtl_width=8.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_behavioral_width=8.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_rtl_width=32.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_behavioral_width=32.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_rtl_width=8.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_behavioral_width=8.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_rtl_width=32.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dff_behavioral_width=32.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_rtl_width=8.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_behavioral_width=8.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_rtl_width=32.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_behavioral_width=32.Test reset"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_rtl_width=8.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_behavioral_width=8.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_rtl_width=32.Test state change"),
("passed", "lib.tb_selecting_dut_with_generate_statement.dut_behavioral_width=32.Test state change"),
("passed", "lib.tb_state_change.width=8"),
("passed", "lib.tb_state_change.width=32"),
],
Expand Down

0 comments on commit 1274c1f

Please sign in to comment.