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

Implement boolean types support #24

Closed
JulianKemmerer opened this issue Oct 1, 2021 · 5 comments
Closed

Implement boolean types support #24

JulianKemmerer opened this issue Oct 1, 2021 · 5 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@JulianKemmerer
Copy link
Owner

JulianKemmerer commented Oct 1, 2021

&& 'logical and' should be defined as l!=0 & r!=0 - it is not

if(x) should evaluate if(x!=0) - it does not
x ? ternary operator has similar problems

@suarezvictor
Copy link

Does it consider short circuit functionality? Thas isz for example in case of &&, the second should be skipped (i.e. if has side effects such as chamging variables, that should't ocurr) basic implementation is with nested ifs:
If(a && b) stmt; => if(a) { if(b) stmt; }

@JulianKemmerer
Copy link
Owner Author

JulianKemmerer commented Oct 2, 2021

Good question @suarezvictor

These types of functions we have been writing in PipelineC are currently 1) (and potentially 2) in the below image
image
I say this because on twitter you saw a third style using a 'clock step operator' clk() function. But that is experimental/undocumented at the moment - and maybe this would apply there - but at the moment doesnt apply to you.

So for now, in the style of function we have been writing so far, something like

expr1 & expr2

Creates hardware that is

           ______
expr1---->|      |
          | AND  |--->
expr2---->|______|

Meaning that the expressions are evaluated in parallel by parallel/duplicated hardware prior to the and. There is no opportunity to only evaluate expr1 and stop if false.

This is a result of PipelineC deriving a dataflow graph from the C code. A little bit from the docs:

// Simple example of math pipeline
float main(float x1, float x2, float y1, float y2)
{
   float x_sum;
   x_sum = x1 + x2;
   float y_sum;
   y_sum = y1 + y2;
   return x_sum + y_sum;
}

The above example instantiates 3 floating point adders. Two in parallel, and a third for the return.

Would love to answer any more questions you have :)

@JulianKemmerer
Copy link
Owner Author

JulianKemmerer commented Oct 2, 2021

I see you ask about side effects - a quick sentence if you are interested:
These functions can maintain state (making them style 1 only). But the state the maintain (even if in global namespace, declared as global variable, etc). Is not a 'shared global memory' like on a cpu. There are additional mechanisms to move data between functions like you would normally do via a global/shared memory concept. So 'global stateful side effects' are not really a thing.

@suarezvictor
Copy link

suarezvictor commented Oct 2, 2021 via email

@JulianKemmerer JulianKemmerer changed the title Implement && 'logical and' defined as l!=0 & r!=0 Implement boolean types support Oct 23, 2021
@JulianKemmerer JulianKemmerer added the bug Something isn't working label Oct 23, 2021
@JulianKemmerer JulianKemmerer added the enhancement New feature or request label Nov 14, 2021
@JulianKemmerer JulianKemmerer removed the enhancement New feature or request label Nov 28, 2021
@JulianKemmerer JulianKemmerer self-assigned this Jan 16, 2022
@JulianKemmerer JulianKemmerer added the help wanted Extra attention is needed label Sep 1, 2022
@JulianKemmerer JulianKemmerer removed their assignment Feb 3, 2023
@JulianKemmerer JulianKemmerer self-assigned this Oct 14, 2023
@JulianKemmerer
Copy link
Owner Author

Correct support for boolean operators is implemented in 827620b

The remaining part of this is simply supporting the typedef of bool as a uint1_t #52 . For now work around with #define bool uint1_t etc as in new bool.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants