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

Update TopEntity annotation docs to include Enable parameter #1736

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

christiaanb
Copy link
Member

Fixes #654

@leonschoorl
Copy link
Member

There are a couple of examples like:

-- {\-\# ANN topEntity (defSyn "f") \#-\}
-- f :: Int -> T -> (T,Bool)
-- f a b = ...

Those ANNotations should be on f, not topEntity.

@christiaanb
Copy link
Member Author

christiaanb commented Mar 30, 2021

There are a couple of examples like:

-- {\-\# ANN topEntity (defSyn "f") \#-\}
-- f :: Int -> T -> (T,Bool)
-- f a b = ...

Those ANNotations should be on f, not topEntity.

I've now updated those as well

@leonschoorl
Copy link
Member

I was just trying the first example of Portname:

data T = MkT Int Bool

{-# ANN f (defSyn "f") #-}
f :: Int -> T -> (T,Bool)
f a b = (b,True)

First of all the output doesn't match what is in the documentation:

entity f is
  port(a      : in signed(63 downto 0);
       b_0    : in signed(63 downto 0);
       b_1    : in boolean;
       result : out std_logic_vector(65 downto 0));
end;

But what is surprising is that it unpacks the input T into two ports, but not the output T.

@leonschoorl
Copy link
Member

The later examples are also slightly wrong, clash doesn't use types like f_types.t or f_types.tup2 anymore on ports of top entities, they're now always basic VHDL types like std_logic_vector.

@christiaanb
Copy link
Member Author

@leonschoorl can you just fix the issues yourself? :)

@christiaanb
Copy link
Member Author

christiaanb commented Mar 30, 2021

But what is surprising is that it unpacks the input T into two ports, but not the output T.

That's because defSyn doesn't annotate the arguments; making Clash default to its unannotated behavior: which is to split product types into smaller parts. However, the output must be annotated (just because of how the data type is defined), and defSyn uses PortName "", which tells clash to use a single port for the result.

Perhaps we should use Maybe PortName for the t_output, and then when it's Nothing we could have Clash default to its unannotated behavior: splitting product types into smaller parts. But that's something for a different PR perhaps, although changing the type definition is not really worth it, as most people that care will pick a proper result port annotation.

Also fixes all the examples and updates their shown outputs.

Fixes #646
Fixes #654
@leonschoorl
Copy link
Member

I went through all the examples in the TopEntity module and updated them and their output.
Now it also fixes #646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port naming doesn't match documentation
2 participants