Skip to content

Commit 52ce461

Browse files
committed
coresight/dp_transactor: Externalize ticker
This allows to reuse dp_transactor in contexts where ticker is external
1 parent b4f18e6 commit 52ce461

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

lib/nsl_coresight/transactor/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ vhdl-sources += dp_framed_transactor.vhd
44
deps += nsl_bnoc.framed
55
deps += nsl_io.io
66
deps += nsl_coresight.swd
7+
deps += nsl_event.tick

lib/nsl_coresight/transactor/dp_framed_transactor.vhd

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library ieee;
22
use ieee.std_logic_1164.all;
33
use ieee.numeric_std.all;
44

5-
library nsl_bnoc, nsl_coresight, nsl_io;
5+
library nsl_bnoc, nsl_coresight, nsl_io, nsl_event;
66
use nsl_coresight.transactor.all;
77

88
entity dp_framed_transactor is
@@ -54,11 +54,15 @@ architecture rtl of dp_framed_transactor is
5454

5555
data : std_ulogic_vector(31 downto 0);
5656

57+
divisor : unsigned(15 downto 0);
58+
5759
srst_drive : std_ulogic;
5860
end record;
5961

6062
signal r, rin : regs_t;
6163

64+
signal tick_s : std_ulogic;
65+
6266
begin
6367

6468
reg: process (clock_i)
@@ -109,7 +113,12 @@ begin
109113
rin.data <= cmd_i.data & r.data(31 downto 8);
110114
rin.last <= cmd_i.last;
111115
if r.cycle = 0 then
112-
rin.state <= STATE_SWD_CMD;
116+
if std_match(r.cmd, DP_CMD_DIVISOR) then
117+
rin.divisor <= unsigned(cmd_i.data & r.data(31 downto 24));
118+
rin.state <= STATE_RSP_PUT;
119+
else
120+
rin.state <= STATE_SWD_CMD;
121+
end if;
113122
end if;
114123
end if;
115124

@@ -194,11 +203,21 @@ begin
194203
end case;
195204
end process;
196205

206+
tick_gen: nsl_event.tick.tick_generator_integer
207+
port map(
208+
clock_i => clock_i,
209+
reset_n_i => reset_n_i,
210+
period_m1_i => r.divisor,
211+
tick_o => tick_s
212+
);
213+
197214
swd_port: dp_transactor
198215
port map(
199216
reset_n_i => reset_n_i,
200217
clock_i => clock_i,
201218

219+
tick_i => tick_s,
220+
202221
cmd_valid_i => s_swd_cmd_valid,
203222
cmd_ready_o => s_swd_cmd_ready,
204223
cmd_data_i.op => r.cmd,

lib/nsl_coresight/transactor/dp_transactor.vhd

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ entity dp_transactor is
1010
clock_i : in std_ulogic;
1111
reset_n_i : in std_ulogic;
1212

13+
tick_i : in std_ulogic;
14+
1315
cmd_valid_i : in std_ulogic;
1416
cmd_ready_o : out std_ulogic;
1517
cmd_data_i : in dp_cmd_data;
@@ -58,9 +60,6 @@ architecture rtl of dp_transactor is
5860
turnaround : natural range 0 to 3;
5961
cycle_count : natural range 0 to 63;
6062

61-
divisor : unsigned(15 downto 0);
62-
counter : unsigned(15 downto 0);
63-
6463
data : std_ulogic_vector(31 downto 0);
6564
op : std_ulogic_vector(7 downto 0);
6665
run_val : std_ulogic;
@@ -90,7 +89,7 @@ begin
9089
end if;
9190
end process;
9291

93-
transition: process (r, cmd_valid_i, cmd_data_i, rsp_ready_i, swd_i)
92+
transition: process (r, cmd_valid_i, cmd_data_i, rsp_ready_i, swd_i, tick_i)
9493
variable swclk_falling : boolean;
9594
variable swclk_rising : boolean;
9695
begin
@@ -103,10 +102,7 @@ begin
103102
null;
104103

105104
when others =>
106-
rin.counter <= r.counter - 1;
107-
108-
if r.counter = (r.counter'range => '0') then
109-
rin.counter <= r.divisor;
105+
if tick_i = '1' then
110106
rin.swd.clk <= not r.swd.clk;
111107
swclk_falling := r.swd.clk = '1';
112108
swclk_rising := r.swd.clk = '0';
@@ -119,8 +115,6 @@ begin
119115
rin.swd.clk <= '0';
120116
rin.swd.dio.v <= '0';
121117
rin.turnaround <= 0;
122-
rin.divisor <= (others => '1');
123-
rin.counter <= (others => '0');
124118

125119
when ST_CMD_GET =>
126120
if cmd_valid_i = '1' then
@@ -139,10 +133,6 @@ begin
139133
rin.state <= ST_RUN;
140134
rin.run_val <= r.op(6);
141135

142-
elsif std_match(r.op, DP_CMD_DIVISOR) then
143-
rin.divisor <= unsigned(r.data(31 downto 16));
144-
rin.state <= ST_RSP_PUT;
145-
146136
elsif std_match(r.op, DP_CMD_BITBANG) then
147137
rin.cycle_count <= to_integer(unsigned(r.op(4 downto 0)));
148138
rin.state <= ST_BITBANG;

lib/nsl_coresight/transactor/transactor.pkg.vhd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ package transactor is
6565
clock_i : in std_ulogic;
6666
reset_n_i : in std_ulogic;
6767

68+
tick_i : in std_ulogic;
69+
6870
cmd_valid_i : in std_ulogic;
6971
cmd_ready_o : out std_ulogic;
7072
cmd_data_i : in dp_cmd_data;

0 commit comments

Comments
 (0)