Skip to content
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

Incorrect vhdl generation for default value in blackbox #6

Closed
BosJ opened this issue May 9, 2014 · 0 comments
Closed

Incorrect vhdl generation for default value in blackbox #6

BosJ opened this issue May 9, 2014 · 0 comments
Assignees
Labels
Milestone

Comments

@BosJ
Copy link
Contributor

BosJ commented May 9, 2014

The following code:

module Error where 

import CLaSH.Prelude

data Dat = Con Rec | Nop 
data Rec = Rec { testVec :: Vec 3 Bool } 

topEntity :: Dat -> Vec 3 Bool
topEntity x = testVec h where
    (Con h) = x

Is translated to:

entity topEntity_0 is
  port(x_i1      : in std_logic_vector(3 downto 0);
       bodyVar_o : out array_of_boolean(2 downto 0));
end;

architecture structural of topEntity_0 is
  signal ds1_0 : array_of_boolean(2 downto 0);
  signal h_1   : array_of_boolean(2 downto 0);
  signal ds_2  : array_of_boolean(2 downto 0);
begin
  ds1_0 <= ds_2;

  h_1 <= (fromSL(x_i1(2))
         ,fromSL(x_i1(1))
         ,fromSL(x_i1(0)));

  ds_2 <= h_1 when (x_i1(3 downto 3) = "0") else
          (others => '0');

  bodyVar_o <= ds1_0;
end;
type array_of_boolean is array (integer range <>) of boolean;

But the assignment to ds_2 should be:

  ds_2 <= h_1 when (x_i1(3 downto 3) = "0") else
          (others => false);

Workaround:

module Error where 

import CLaSH.Prelude

data Dat = Con Rec | Nop 
data Rec = Rec { testVec :: Vec 3 Bool } 

topEntity :: Dat -> Vec 3 Bool
topEntity x = case x of
        (Con h) -> testVec h
        _       -> undefined
@christiaanb christiaanb added the bug label May 9, 2014
@christiaanb christiaanb self-assigned this May 9, 2014
@christiaanb christiaanb added this to the 0.3.1 milestone May 14, 2014
martijnbastiaan added a commit that referenced this issue Jun 27, 2019
Adapt to single parameter KnownDomain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants