2 views

Uploaded by Serge Mandhev Swamotz

verilog

- device physics
- derivation of ideal diode equation
- Best Plots rf engineering
- ENEE 498R Formula Sheet
- FPGAs
- Boeing Interview Preparation
- Quiz
- PNCinterview Questions
- Midterm Exam - Solution
- 9. Midterm Exam and Reaction Paper I
- AP C Free Response Review Electromag
- KPR Chapter 1
- Cover Letter
- lab_12
- 09-RF Electronics
- Enee 474exam1
- Ch7 Markov Chains Part II
- Pointers
- computer organization lecture
- computer organization lecture

You are on page 1of 4

module vending( input wire [3:0] coin_in, input wire [3:0] selection, input wire clk, output reg [3:0] led, output reg [7:0] total_in, //output wire [7:0] total_out, output reg [7:0] cost );//initialize coin_in to 7 momentarily at start by pressing all 3 buttons to initialize total_out to 0 reg [7:0] amount_in; //reg [7:0] total_in; reg [7:0] subtraction; //wire [7:0] total_out1; //wire [7:0] coin; //coin_decoder M1(coin_in,coin);

always @(posedge clk) begin case(coin_in) 1: begin amount_in = 5; end 2: begin amount_in = 10; end 4: begin amount_in = 25; end 8: begin total_in = 0; amount_in = 0; cost = 0; subtraction = 0; led = 4'b0000; end default begin amount_in = 0;

end endcase total_in = total_in + amount_in; amount_in = 0; if (selection != 0) begin case(selection) 0: begin cost = 7'd0; subtraction = 0; led[3] = 0; led[2] = 0; led[1] = 0; led[0] = 0; end 1: begin cost = 55; if (total_in >= cost) begin subtraction = cost; led[0] led[1] led[2] led[3] end else subtraction = 0; end 2: begin cost = 60; if (total_in >= cost) begin subtraction = cost; led[1] led[0] led[2] led[3] end else subtraction = 0; end 4: begin cost = 65; if (total_in >= cost) begin subtraction = cost; led[2] = 1; led[3] = 0; = = = = 1; 0; 0; 0; = = = = 1; 0; 0; 0;

led[1] = 0; led[0] = 0; end else subtraction = 0; end 8: begin cost = 70; if (total_in >= cost) begin subtraction = cost; led[3] led[2] led[1] led[0] end else subtraction = 0; end default begin cost = 7'd0; subtraction = 0; led = 4'b0000; end endcase total_in = total_in + subtraction; subtraction = 0; end else begin cost = 7'd0; subtraction = 0; led[3] = 0; led[2] = 0; led[1] = 0; led[0] = 0; end end endmodule = = = = 1; 0; 0; 0;

TEST BENCH

module vending_machine_tb; // Inputs reg [3:0] coin_in; reg [3:0] selection; reg clk; // Outputs

wire [3:0] led; wire [7:0] total_in; wire [7:0] cost; // Instantiate the Unit Under Test (UUT) vending_machine_controller uut ( .coin_in(coin_in), .selection(selection), .clk(clk), .led(led), .total_in(total_in), .cost(cost) ); initial begin // Initialize Inputs clk=0; coin_in=8; coin_in=2; #10; coin_in=1; #10; coin_in=4; #10; coin_in=4; selection=1; end always begin #5; clk=~clk; end endmodule

- device physicsUploaded bySerge Mandhev Swamotz
- derivation of ideal diode equationUploaded bySerge Mandhev Swamotz
- Best Plots rf engineeringUploaded bySerge Mandhev Swamotz
- ENEE 498R Formula SheetUploaded bySerge Mandhev Swamotz
- FPGAsUploaded bySerge Mandhev Swamotz
- Boeing Interview PreparationUploaded bySerge Mandhev Swamotz
- QuizUploaded bySerge Mandhev Swamotz
- PNCinterview QuestionsUploaded bySerge Mandhev Swamotz
- Midterm Exam - SolutionUploaded bySerge Mandhev Swamotz
- 9. Midterm Exam and Reaction Paper IUploaded bySerge Mandhev Swamotz
- AP C Free Response Review ElectromagUploaded bySerge Mandhev Swamotz
- KPR Chapter 1Uploaded bySerge Mandhev Swamotz
- Cover LetterUploaded bySerge Mandhev Swamotz
- lab_12Uploaded bySerge Mandhev Swamotz
- 09-RF ElectronicsUploaded bySerge Mandhev Swamotz
- Enee 474exam1Uploaded bySerge Mandhev Swamotz
- Ch7 Markov Chains Part IIUploaded bySerge Mandhev Swamotz
- PointersUploaded bySerge Mandhev Swamotz
- computer organization lectureUploaded bySerge Mandhev Swamotz
- computer organization lectureUploaded bySerge Mandhev Swamotz
- 408E133-1Uploaded bySerge Mandhev Swamotz
- 408E133-1Uploaded bySerge Mandhev Swamotz
- verilogUploaded bySerge Mandhev Swamotz
- OPTICSUploaded bySerge Mandhev Swamotz
- enee460Uploaded bySerge Mandhev Swamotz
- BOMELA's Final Exam-Takehome OptionUploaded bySerge Mandhev Swamotz
- Exam Review ImportantUploaded bySerge Mandhev Swamotz
- ENEE 419R Assignment 1Uploaded bySerge Mandhev Swamotz
- Basic electric circuit theory- a one-semester text By I. D. Mayergoyz- Wes LawsonUploaded bymerrink