Skip to content

Commit d75a314

Browse files
committed
Add an enable to Strobe, misc other updates
1 parent a61e7eb commit d75a314

File tree

7 files changed

+59
-14
lines changed

7 files changed

+59
-14
lines changed

hdl/ip/vhd/common/BUCK

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ vhdl_unit(
2727
visibility = ['PUBLIC']
2828
)
2929

30+
vhdl_unit(
31+
name = "tristate_if_pkg",
32+
srcs = glob(["interfaces/tristate_if_pkg.vhd"]),
33+
deps = [],
34+
standard = "2019",
35+
visibility = ['PUBLIC']
36+
)
37+
3038
# Strobe
3139

3240
vhdl_unit(

hdl/ip/vhd/common/interfaces/streaming_if_pkg.vhd

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ package streaming_if_pkg is
2020
ready : std_logic;
2121
end record;
2222

23-
view st_source of data_channel is
23+
view st_source_if of data_channel is
2424
valid, data : out;
2525
ready : in;
2626
end view;
2727

28-
alias st_sink is st_source'converse;
28+
alias st_sink_if is st_source_if'converse;
2929

3030
end package;
3131

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this
3+
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright 2024 Oxide Computer Company
6+
7+
-- This package relies on the VHDL 2019 feature for "interfaces"
8+
9+
library ieee;
10+
use ieee.std_logic_1164.all;
11+
12+
package tristate_if_pkg is
13+
14+
type tristate is record
15+
i : std_logic;
16+
o : std_logic;
17+
oe : std_logic;
18+
end record;
19+
20+
view tristate_if of tristate is
21+
i : in;
22+
o, oe : out;
23+
end view;
24+
25+
end package;

hdl/ip/vhd/common/strobe/sims/strobe_tb.vhd

+14-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ entity strobe_tb is
2121
end entity;
2222

2323
architecture tb of strobe_tb is
24-
constant TB_TICKS : positive := 10;
24+
constant CLK_PER : time := 8 ns;
25+
constant TB_TICKS : positive := 10;
2526
begin
2627

2728
th: entity work.strobe_th
2829
generic map (
29-
TICKS => TB_TICKS
30+
CLK_PER => CLK_PER,
31+
TICKS => TB_TICKS
3032
);
3133

3234
bench: process
3335
alias reset is << signal th.reset : std_logic >>;
36+
alias enable is << signal th.dut_enable : std_logic >>;
3437
alias strobe is << signal th.dut_strobe : std_logic >>;
3538
begin
3639
-- Always the first thing in the process, set up things for the VUnit test runner
@@ -41,11 +44,18 @@ begin
4144

4245
while test_suite loop
4346
if run("test_strobe") then
47+
enable <= '1';
4448
check_equal(strobe, '0', "Strobe should be low after reset");
45-
wait for 72 ns; -- CLK_PER_NS * (TB_TICKS - 1) ns
49+
wait for CLK_PER * (TB_TICKS - 1);
4650
check_equal(strobe, '0', "Strobe should be low after TB_TICKS-1");
47-
wait for 8 ns; -- wait one more period, bringing us to TB_TICKs
51+
wait for CLK_PER;
4852
check_equal(strobe, '1', "Strobe should be high once the TICKS count is reached");
53+
elsif run("test_strobe_enable") then
54+
wait for CLK_PER * TB_TICKS;
55+
check_equal(strobe, '0', "Strobe should be low after TB_TICKS when not enabled");
56+
enable <= '1';
57+
wait for CLK_PER * TB_TICKS;
58+
check_equal(strobe, '1', "Strobe should be high after TICKs when enabled");
4959
end if;
5060
end loop;
5161

hdl/ip/vhd/common/strobe/sims/strobe_th.vhd

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ library vunit_lib;
1515

1616
entity strobe_th is
1717
generic (
18-
TICKS : positive
18+
CLK_PER : time;
19+
TICKS : positive
1920
);
2021
end entity;
2122

2223
architecture th of strobe_th is
2324

2425
signal clk : std_logic := '0';
2526
signal reset : std_logic := '1';
27+
signal dut_enable : std_logic := '0';
2628
signal dut_strobe : std_logic;
2729

2830
begin
2931

30-
-- set up a fastish clock for the sim env
31-
-- and release reset after a bit of time
32-
clk <= not clk after 4 ns;
32+
clk <= not clk after CLK_PER / 2;
3333
reset <= '0' after 200 ns;
3434

3535
strobe_inst: entity work.strobe
@@ -39,6 +39,7 @@ begin
3939
port map (
4040
clk => clk,
4141
reset => reset,
42+
enable => dut_enable,
4243
strobe => dut_strobe
4344
);
4445

hdl/ip/vhd/common/strobe/strobe.vhd

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ entity strobe is
1818
clk : in std_logic;
1919
reset : in std_logic;
2020

21+
enable : in std_logic;
2122
strobe : out std_logic
2223
);
2324
end entity strobe;
@@ -27,14 +28,14 @@ architecture rtl of strobe is
2728
begin
2829
strobe_gen: process (clk, reset) is
2930
begin
30-
if reset = '1' then
31+
if reset then
3132
strobe_counter <= 0;
3233
strobe <= '0';
3334
elsif rising_edge(clk) then
3435
if strobe_counter = TICKS - 1 then
3536
strobe <= '1';
3637
strobe_counter <= 0;
37-
else
38+
elsif enable then
3839
strobe <= '0';
3940
strobe_counter <= strobe_counter + 1;
4041
end if;

hdl/ip/vhd/vunit_components/basic_stream/sims/th_basic_stream.vhd

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use work.basic_stream_pkg.all;
1717

1818
entity th_basic_stream is
1919
generic (
20-
source : basic_source_t;
21-
sink: basic_sink_t
20+
source : basic_source_t;
21+
sink : basic_sink_t
2222
);
2323
end entity;
2424

0 commit comments

Comments
 (0)