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

Case statement within combinational block #45

Closed
kiteloopdesign opened this issue Jun 11, 2021 · 2 comments
Closed

Case statement within combinational block #45

kiteloopdesign opened this issue Jun 11, 2021 · 2 comments

Comments

@kiteloopdesign
Copy link

kiteloopdesign commented Jun 11, 2021

I am trying to create a case statement within a combinational block, but I am not getting the blocking assignment it should be inferred. I am getting instead a non-blocking ("<=") assignment instead.

  always @(*) begin
    case(myvar)
      0: begin
        logic_wire <= 1;
      end
      default: begin
        logic_wire <= 5;
      end
    endcase
  end

Any idea on how to get this done? This is what my code looks like

myvar= m.Reg ('myvar', width = 4 , initval = 0 )
logic_wire= m.Reg ('logic_wire', width = 1 , initval = 0 )

decCond = []
decCond.append (vg.When ( 0 ) (logic_wire ( 1 )))
# ... more conditions ...
decCond.append (vg.When () (logic_wire ( 5 )))
m.Always( ) ( vg.Case (myvar) (* decCond ) )

Thanks!

@LucasBraganca
Copy link

Hi,

You need to pass the parameter True on the assignment to get the blocking assignment.

myvar= m.Reg ('myvar', width = 4 , initval = 0 )
logic_wire= m.Reg ('logic_wire', width = 1 , initval = 0 )

decCond = []
decCond.append (vg.When ( 0 ) (logic_wire ( 1 ,True)))
# ... more conditions ...
decCond.append (vg.When () (logic_wire ( 5 ,True)))
m.Always( ) ( vg.Case (myvar) (* decCond ) )

@kiteloopdesign
Copy link
Author

Cool, obrigado Lucas, it does work indeed
It would be awesome to throw all these examples into the wiki, it should not take long and save you guys a bunch of qeustions!

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

No branches or pull requests

2 participants