Skip to content

Commit

Permalink
Fixed Avavlon reads
Browse files Browse the repository at this point in the history
The CoCoTb Avalon master driver and corsair do not agree with one and
other.

The driver removes the addres one a read pulse has been asserted (1
clock cycle) while the hdl of corsair expects it to remain stable for at
least one more cycle.
This has been fixed by clocking in the address at a read pulse and use
that for the read process.
  • Loading branch information
stdefeber committed Sep 27, 2024
1 parent 14dc5d4 commit a7f4668
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
7 changes: 7 additions & 0 deletions corsair/templates/amm2lb_verilog.j2
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ wire ren;
end
end

reg {{ range_decl(config['data_width'] - 1) }} raddr_int;
{{ always_begin(sig='raddr_int', width=config['data_width'], init=read_filler
)}} if (read) begin
raddr_int <= address;
end
end

assign ren = ren_int;
{% endmacro %}
{{ amm_core() }}
Expand Down
9 changes: 8 additions & 1 deletion corsair/templates/amm2lb_vhdl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ signal raddr : std_logic_vector(ADDR_W-1 downto 0);
signal ren : std_logic;
{% endif %}
signal ren_int : std_logic;
signal raddr_int : std_logic_vector(ADDR_W-1 downto 0);
{% endmacro %}
{{ amm_signals() }}
begin
Expand All @@ -120,8 +121,14 @@ wstrb <= byteenable;
end if;
{{ process_end() }}

{{ process_begin("raddr_int", "(others => '0')") }}
if (read = '1') then
raddr_int <= address;
end if;
{{ process_end() }}

ren <= ren_int;

{% endmacro %}
{{ amm_core() }}
end arch_imp;
end arch_imp;
2 changes: 1 addition & 1 deletion corsair/templates/regmap_verilog.j2
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ assign wready = 1'b1;
reg {{ range_decl(config['data_width'] - 1) }} rdata_ff;
{{ always_begin(sig='rdata_ff', width=config['data_width'], init=read_filler
)}} if (ren) begin
case (raddr)
case (raddr_int)
{% for reg in rmap %}
{{ literal(reg.address, config['address_width']) }}: rdata_ff <= {{ sig_csr_rdata(reg) }};
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions corsair/templates/regmap_vhdl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,10 @@ wready <= '1';
{% set loop_ns = namespace(first_reg = True) %}
{% for reg in rmap %}
{% if loop_ns.first_reg %}
if raddr = {{ literal(reg.address, "ADDR_W", width_is_param=1)}} then {{ literal_comment(reg.address) }}
if raddr_int = {{ literal(reg.address, "ADDR_W", width_is_param=1)}} then {{ literal_comment(reg.address) }}
rdata_ff <= {{ sig_csr_rdata(reg) }};
{% else %}
elsif raddr = {{ literal(reg.address, "ADDR_W", width_is_param=1)}} then {{ literal_comment(reg.address) }}
elsif raddr_int = {{ literal(reg.address, "ADDR_W", width_is_param=1)}} then {{ literal_comment(reg.address) }}
rdata_ff <= {{ sig_csr_rdata(reg) }};
{% endif %}
{% set loop_ns.first_reg = False %}
Expand Down

0 comments on commit a7f4668

Please sign in to comment.