-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-fclash-aggressive-x-optimization-blackboxes does not work on deepErrorX
of BitVector
#2117
Comments
This is checked in the blackbox templates like so:
We should special case the implementation of clash-compiler/clash-lib/src/Clash/Netlist/BlackBox/Util.hs Lines 476 to 480 in 0b4a9ae
|
@martijnbastiaan it would be nice to have something which also worked for something like this: import Clash.Explicit.Prelude
topEntity
:: Clock XilinxSystem
-> Reset XilinxSystem
-> Enable XilinxSystem
-> Signal XilinxSystem (Bit, Bit)
-> Signal XilinxSystem (Bit, Bit)
topEntity clk rst en = register clk rst en (deepErrorX "undefined reset") But I see that is potentially difficult as this unpacks to: -- Automatically generated VHDL-93
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.MATH_REAL.ALL;
use std.textio.all;
use work.all;
use work.Main_topEntity_types.all;
entity topEntity is
port(-- clock
clk : in Main_topEntity_types.clk_XilinxSystem;
-- reset
rst : in Main_topEntity_types.rst_XilinxSystem;
-- enable
en : in Main_topEntity_types.en_XilinxSystem;
i_0 : in std_logic;
i_1 : in std_logic;
result_0 : out std_logic;
result_1 : out std_logic);
end;
architecture structural of topEntity is
signal result_4 : Main_topEntity_types.Tup2 := (Tup2_sel0_std_logic_0 => '-', Tup2_sel1_std_logic_1 => '-');
signal i : Main_topEntity_types.Tup2;
signal result : Main_topEntity_types.Tup2;
begin
i <= ( Tup2_sel0_std_logic_0 => i_0
, Tup2_sel1_std_logic_1 => i_1 );
-- register begin
result_4_register : process(clk)
begin
if rising_edge(clk) then
if rst = '1' then
result_4 <= (Tup2_sel0_std_logic_0 => '-', Tup2_sel1_std_logic_1 => '-');
elsif en then
result_4 <= i;
end if;
end if;
end process;
-- register end
result <= result_4;
result_0 <= result.Tup2_sel0_std_logic_0;
result_1 <= result.Tup2_sel1_std_logic_1;
end; |
I think this would be a matter of recursing on clash-compiler/clash-lib/src/Clash/Netlist/Types.hs Lines 440 to 442 in 0b4a9ae
in the case I linked earlier, would you agree? |
I wouldn't do that for aggressive blackbox X optimization though. Digging into product types seems like something the normal aggressive X optimization flag should do since it's just data |
Are you proposing that
|
EDIT: No, this is wrong. The docs for |
While that's certainly nice to have, I fail to see how that would help in this specific instance. The reset value of |
Or the users should use |
I think both should work. I wouldn't say it's unreasonably to treat @jonfowler We quickly discussed this in the office just now; if you supply a patch we'll accept it :) |
Thanks, but I'm not going to have time to do this at the moment (it should be a minor change but being unfamiliar with the codebase means it's going to take me quite a while to investigate / do this properly). |
I'll give it a go. Reviewer beware: also not really my area of expertise ;-) |
We've released v1.6.3, which includes a fix for this issue. |
The following code generates a reset on the data when compiled with
clash -fclash-aggressive-x-optimization-blackboxes --vhdl
:vhdl:
Replacing
BitVector
forUnsigned
does not have this problem.Presumably this is because of a BitVector creates a mask not a direct
errorX
and presumably similar problems will exist with records where every field iserrorX
but the structure is defined. The intuitive fix would be to pack the data and check whether it is all undefined as opposed to relying on the Haskell representation.The text was updated successfully, but these errors were encountered: