0% found this document useful (0 votes)
9 views10 pages

DE - Open Ended Assignment

The document outlines a toll tax calculation system designed to compute total toll costs based on vehicle type, axle count, and electric vehicle (EV) status. It details a workflow for inputting data, calculating base tolls, applying axle charges, and providing discounts for EVs, along with an algorithm and code for implementation. Additionally, it includes test cases to validate the system's functionality and expected outputs.

Uploaded by

pratikshab740
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

DE - Open Ended Assignment

The document outlines a toll tax calculation system designed to compute total toll costs based on vehicle type, axle count, and electric vehicle (EV) status. It details a workflow for inputting data, calculating base tolls, applying axle charges, and providing discounts for EVs, along with an algorithm and code for implementation. Additionally, it includes test cases to validate the system's functionality and expected outputs.

Uploaded by

pratikshab740
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

DE Open Ended Assignment

TOLL TAX CALCULATION

Arati Ambekar -UEC2023302


Pratiksha Birajdar – UEC2023305
Pranjali Chavan – UEC2023308
Rahi Gaykar – UEC2023315

Problem Statement – Develop a system to calculate the total toll


cost for vehicles passing through toll points based on vehicle type, axle
count, and electric vehicle (EV) status.

Introduction –
The binary toll calculator uses a binary representation to manage and calculate toll
charges efficiently, especially for routes with multiple toll points. This approach is
particularly useful for optimizing computations in systems where toll costs depend
on predefined entry and exit points, like highways, bridges, or tunnels with fixed toll
stations.

Workflow Explanation -
Step 1: Input Data
Gather the necessary details about the trip and the vehicle:
• Vehicle Type: Car, truck, motorcycle, bus, etc.
• Axle Count: Total number of axles (e.g., standard trucks have 2 axles; some
may have 4 or more).
• EV Status: Whether the vehicle is an electric vehicle (to apply discounts if
applicable).

Step 2: Base Toll Cost = Rs. 10.

Step 3: Apply Additional Charges for Extra Axles


1. Determine Axle-Based Costs
For vehicles with more than the standard number of axles, calculate additional
tolls.
2. Add Axle Charges to Base Cost
Step 4: Apply EV Discounts
• Determine Discount Eligibility: Check if the vehicle is an EV.
• Calculate Discount:
• Example: -Rs. 2 discount for EVs.
EV Discount = Rs. 10 – Rs.2= Rs. 8

Step 5: Output the Final Toll Cost


• Multiply the final rate by the number of toll passes booths passed.

Algorithm:
1. Initialize Inputs:
- Read `base_toll`, `axles`, `is_ev`, and `toll_passes`.

2. Set Base Toll:


- Assign `adjusted_rate = base_toll`.

3. Calculate Axle Charges:


- If `axles > 2`:
- Set `mux_select = 2’b01` (addition).
- Calculate `adjusted_rate = base_toll + ((axles – 2) * EXTRA_AXLE_FEE)`.
- Else: Set `mux_select = 2’b00` (pass-through).

4. Apply EV Discount:
- If `is_ev = 1`:
- Set `mux_select = 2’b10` (subtraction).
- Calculate `final_rate = adjusted_rate – EV_DISCOUNT`.
- Else: Assign `final_rate = adjusted_rate`.

5. Calculate Total Toll:


- Set `mux_select = 2’b11` (multiplication).
- Compute `total_toll = final_rate * toll_passes`.
-
6. Output Result:
- Display the `total_toll` and intermediate steps for verification.

Input Data:
• The system takes inputs: base_toll, axles, is_ev, and toll_passes.
• Control signals (mux_select) determine the operation performed by the
multiplexer.
• The base toll (base_toll) is initialized.
Code:
Module TollCalculatorWithMux (
Input [3:0] base_toll,
Input [3:0] axles,
Input is_ev,
Input [3:0] toll_passes,
Output reg [7:0] total_toll
);

// Parameters
Parameter EXTRA_AXLE_FEE = 4’b0001;
Parameter EV_DISCOUNT = 4’b0010;

// Control Signals for Multiplexer


Reg [1:0] mux_select;
Reg [7:0] operation_result;
Reg [7:0] adjusted_rate;
Reg [7:0] final_rate;

// Multiplexer logic for operations


Always @(*) begin
Case (mux_select)
2’b00: operation_result = adjusted_rate;
2’b01: operation_result = adjusted_rate + EV_DISCOUNT;
2’b10: operation_result = adjusted_rate – EV_DISCOUNT;
2’b11: operation_result = adjusted_rate * toll_passes;
Default: operation_result = 8’b00000000;
Endcase
End

// Toll Calculation Logic


Always @(*) begin
Adjusted_rate = base_toll;
If (axles > 4’b0010) begin
Mux_select = 2’b01;
Adjusted_rate = base_toll + ((axles – 4’b0010) * EXTRA_AXLE_FEE);
End else begin
Mux_select = 2’b00;
Adjusted_rate = base_toll;
End

If (is_ev) begin
Mux_select = 2’b10;
Final_rate = adjusted_rate – EV_DISCOUNT;
End else begin
Final_rate = adjusted_rate;
End

Mux_select = 2’b11; // Select multiplication operation


Total_toll = final_rate * toll_passes;
End
Endmodule

Test Bench :

module TollCalculatorWithMux_tb;

reg [3:0] base_toll;


reg [3:0] axles;
reg is_ev;
reg [3:0] toll_passes;
wire [7:0] total_toll;

TollCalculatorWithMux tollCalc (
.base_toll(base_toll),
.axles(axles),
.is_ev(is_ev),
.toll_passes(toll_passes),
.total_toll(total_toll)
);

//dump signal to waveform


initial begin
$dumpfile("dump.vcd");
$dumpvars(1);
end

initial begin

// Test Case 1: Non-EV vehicle with 2 axles,1 toll pass


base_toll = 4'b1010;
axles = 4'b0010;
is_ev = 0;
toll_passes = 4'b0001;
#10;
$display("Test Case 1 - Expected Total Toll: 10, Calculated Total Toll: %d",
total_toll);

// Test Case 2: EV with 3 axles, 2 toll passes


base_toll = 4'b1010;
axles = 4'b0011;
is_ev = 1;
toll_passes = 4'b0010;
#10;
$display("Test Case 2 - Expected Total Toll: 18, Calculated Total Toll: %d",
total_toll);

// Test Case 3: Non-EV with 4 axles, 3 toll passes


base_toll = 4'b1010;
axles = 4'b0100;
is_ev = 0;
toll_passes = 4'b0011;
#10;
$display("Test Case 3 - Expected Total Toll: 36, Calculated Total Toll: %d",
total_toll);

// Test Case 4: EV with 2 axles, 4 toll passes


base_toll = 4'b1010;
axles = 4'b0010;
is_ev = 1;
toll_passes = 4'b0100;
#10;
$display("Test Case 4 - Expected Total Toll: 32, Calculated Total Toll: %d",
total_toll);

$finish;
end
endmodule

Output:
The system outputs the total toll along with intermediate computations for
validation.
PRICE DISTRIBUTION

Type of vehicle Toll for that type of vehicle

Four wheeler ₹10 = base toll

EVs ₹10-₹2(discount)

Vehicles with extra axles ₹10 + (no. Of axles*₹1)


Example:
Step 1: Input Data

Gather the necessary details about the trip and the vehicle:

● Vehicle Type: Car, truck, motorcycle, bus, etc.


● Axle Count: Total number of axles (e.g., standard trucks have 2 axles; some may
have 4 or more).
● EV Status: Whether the vehicle is an electric vehicle (to apply discounts if
applicable)

Step 2: Base Toll Cost :

● Base toll cost : Rs. 10.

Step 3: Apply Additional Charges for Extra Axles

1. Determine Axle-Based Costs:


For vehicles with more than the standard number of axles, calculate additional
tolls.
○ Example: Each extra axle adds Rs. 1 per toll point.
○ If a truck with 4 axles travels through 3 toll points (2 extra axles):
Additional Cost = Rs. 1 × 2 (extra axles) × 3 (toll points) = Rs.6.
2. Add Axle Charges to Base Cost:
○ Total Cost (Base + Axle Charges) = Rs. 10 + Rs.6 = Rs.16

Step 4: Apply EV Discounts

1. Determine Discount Eligibility:


Check if the vehicle is an EV.
2. Calculate Discount:
Apply a percentage or flat discount on the base cost.
○ Example: -Rs.2 discount for EVs.
■ EV Discount = Rs.10 – Rs.2= Rs.8

3. Subtract Discount:
○ Total Cost After Discount = Rs.16 – Rs.2 = Rs.14
Step 5: Output the Final Toll Cost

Provide the total toll cost along with a breakdown:

● Base Toll Cost: Rs.10


● Axle Charges: Rs.6
● EV Discount: - Rs.2
● Total Cost: Rs.14

Formula Summary

Total Toll Cost =


(Base Toll Cost) + (Axle Charges) − (EV Discount)

Test Bench waveform :

1
2

You might also like