Help needed with verilog code and schematic diagram

Status
Not open for further replies.

Marho Desmond

New Member
Am new to verilog coding and my lecturer gave me a project which am finding a bit tasking. I have my main code but i have got a problem with the testbench.It doesn't output wave forms when i run it in modelsim. Wondering if some1 could look it up and tell what the problem is or possibly help.

testbench
module parking_lot_tb;
wire p1 = 1'b0;
wire p2 = 1'b0;
wire p3 = 1'b0;
wire p4 = 1'b0;
wire a1;
wire a2;
wire a3;
wire a4;
reg clk;
parking_lot dut(
p1,
p2,
p3,
p4,
a1,
a2,
a3,
a4
);

initial begin
clk = 1;
end

always begin
assign #100 p1 = ~( p1);
assign #200 p2 = ~( p2);
assign #300 p3 = ~( p3);
assign #400 p4 = ~( p4);
end

initial
$monitor($stime,,clk,,a1,,a2,,a3,,a4,,);
endmodule


Main code:
module parking_lot(
p1,
p2,
p3,
p4,
a1,
a2,
a3,
a4
);
input p1;
input p2;
input p3;
input p4;
output a1;
output a2;
output a3;
output a4;
assign a1 = ( ( ( p1 | p2 ) | p3 ) | p4 );
assign a2 = ( ( ( p1 & p2 ) | ( p2 & p3 ) ) | ( p3 & p4 ) );
assign a3 = ( ( ( ( p1 & p2 ) & p3 ) & ~( p4) ) | ( ( p2 & p3 ) & p4 ) );
assign a4 = ( ( ( p1 & p2 ) & p3 ) & p4 );
endmodule


Project Question:
A. Parking Space Problem

Problem: An individual has 4 parking spaces outside of his/her apartment complex. This individual wants to know when two adjacent spaces are open as he/she does not want anyone to park next to their car. (Normally, this person parks at the end of a large parking lot to avoid any scrapes or scratches). This individual proceeds to set up pressure switches in the parking spaces and has a logic indicator in their apartment building. They want one logic indicator to activate if two adjacent spaces become open, another logic indicator to activate if three adjacent spaces become open, a third if all spaces are open and a fourth if one space is open (in case they choose to risk it).


Truth Table:

input output
P4 P3 P2 P1 A4 A3 A2 A1
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 0 1
0 0 1 1 0 0 1 1
0 1 0 0 0 0 0 1
0 1 0 1 0 0 0 1
0 1 1 0 0 0 1 1
0 1 1 1 0 1 1 1
1 0 0 0 0 0 0 1
1 0 0 1 0 0 0 1
1 0 1 0 0 0 0 1
1 0 1 1 0 0 1 1
1 1 0 0 0 0 1 1
1 1 0 1 0 0 1 1
1 1 1 0 0 1 1 1
1 1 1 1 1 1 1 1

Parking Space 1 – P1
Parking Space 2 – P2
Parking Space 3 – P3
Parking Space 4 – P4
Only One Space Open – A1
Two or More Adjacent Spaces Open – A2
Three or More Adjacent Spaces Open – A3
Four Adjacent Spaces Open – A4

Inputs:
PIN 2 = P1
PIN 3 = P2
PIN 4 = P3
PIN 5 = P4

Outputs:
PIN 19 = A1
PIN 18 = A2
PIN 17 = A3
PIN 16 = A4
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…