I'm trying to write a basic circuit in Verilog using Quartus Prime as a side project for a professor. That said, I'm having trouble with Verilog syntax. The circuit that I want to make is a collection of AND and OR gates that theoretically determine if an electric engine is to turn on. The engine will turn on if there is a) a foot on the break, b) the key is in the car, and c) there is sufficient charge on the battery. The enginer will also turn on if there is both a) charge on the battery, and b) The key is inserted into a secret slot. Unrealistic for a car design but it serves my purposes. First, my truth table:
And now, my code:
module ignition (
key,
foot,
batt,
secr,
powr,
);
//--INPUTS/OUTPUTS--
input key, foot, batt, secr;
output powr;
//--DATATYPE--
reg key, foot, batt, secr, powr
//--LOGIC--
always @ (posedge reset)
always begin
if (key == 1) && (foot == 1) && (batt == 1)
powr == 1;
else if (secr == 1) && (batt == 1)
powr == 1;
else
powr == 0
end
//--TESTBLOCK--
module ignition_tb;
reg key, foot, batt, secr, powr
initial begin
$monitor ("key=%b,foot=%b,batt=%b,secr=%b,powr=%b")
key = 0
foot = 0
batt = 0
secr = 0
powr = 0
I'm not really sure where to go from here. Is my code set up properly for verilog? How do I implement testing?
Thanks!