-1

Hey so I'm basically brand new to Verilog and not quite sure how the syntax works and things like this.

The assignment is as below

Use a push button and a switch on the Altera board to increment or decrement a 4 bit counter. The value of the counter should be displayed using the on board LEDs. Use the switch to control the direction of the counter and the push button to change the counter value.

This is what I got so far, I have no idea if its right or not, I know how to assign the inputs and outputs on the board when I get to that point but just cant get the code to compile. I keep getting:

Error (10043): Verilog HDL unsupported feature error at Lab2pt2.v(11): Procedural Continuous Assignment to register is not supported.

Below is the code:

module counter(A,B,F);
input A,B;
output reg [3:0] F;

always @(A or B)

begin
if (A == 1 & B==1)

assign F = F+1;

else(A == 0 & B==1)

assign F = F-1;

end
endmodule 
Goralight
  • 2,067
  • 6
  • 25
  • 40
  • 1
    Possible duplicate of [Using a continous assignment in a Verilog procedure?](https://stackoverflow.com/questions/23687172/using-a-continous-assignment-in-a-verilog-procedure) – Qiu Oct 03 '17 at 13:02

1 Answers1

0

You're the 2nd person trying to use procedural assigns (a rather obscure language feature) today!

The quick answer is to simply drop the 'assign' in your... assignments and things will be happier. This construct will work in simulators but in physical hardware would imply some unusual logic. It's really meant for testbenches (if then).

There are a some other problems with what you've got going here. You're missing an 'if' before the condition in your if/else expression for one.

More generally you need to start thinking of Verilog as describing hardware. Your increment/decrement statements use F on the RHS. What was F before? What does 'before' even mean in this context? What was the 1st value of F? How does the circuit know when to move from one state to the next? If you can answer these questions you'll be well on your way to a solution.

Brian Magnuson
  • 1,487
  • 1
  • 9
  • 15