DE - Open Ended Assignment
DE - Open Ended Assignment
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).
Algorithm:
1. Initialize Inputs:
- Read `base_toll`, `axles`, `is_ev`, and `toll_passes`.
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`.
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;
If (is_ev) begin
Mux_select = 2’b10;
Final_rate = adjusted_rate – EV_DISCOUNT;
End else begin
Final_rate = adjusted_rate;
End
Test Bench :
module TollCalculatorWithMux_tb;
TollCalculatorWithMux tollCalc (
.base_toll(base_toll),
.axles(axles),
.is_ev(is_ev),
.toll_passes(toll_passes),
.total_toll(total_toll)
);
initial begin
$finish;
end
endmodule
Output:
The system outputs the total toll along with intermediate computations for
validation.
PRICE DISTRIBUTION
EVs ₹10-₹2(discount)
Gather the necessary details about the trip and the vehicle:
3. Subtract Discount:
○ Total Cost After Discount = Rs.16 – Rs.2 = Rs.14
Step 5: Output the Final Toll Cost
Formula Summary
1
2