question: There are three doors in a room with a light switch next to each one (SW_1, SW 2, and SW 3). The room has two lightbulbs in the center. You can turn on and off the lightbulbs with any light switch. Initially, the two lightbulbs are off. When a person enters the room and presses on the light switch, then the lights become on if they were off and they become off they were on. SW 1 SW 2 SW 3
1 // C++ code 2 // 3 void setup() { 4 5 6} 7 8 9 { 10 digitalWrite(LED_BUILTIN, HIGH); 11 delay (1000); // Wait for 1000 millisecond(s) 12 digitalWrite(LED_BUILTIN, LOW); 13 delay (1000); // Wait for 1000 millisecond(s) 14 15 16 module melfsm (din, reset, clk, y); 17 input dn; 18 input clk; 19 input reset; 20 output reg y; 21 reg [1:0] cst, nst; 22 parameter SO 23 S1 E 2'b01, 24 $2 S3 = 12 12222 N N N N N N M M M33MO 25 26 30 31 2345 10 32 29 case (cst) 33 34 27 always @ (cst or din) /// use posedge clk to avoid glitch 28 begin 35 pinMode(LED_BUILTIN, OUTPUT); void loop() } 36 = = 2'b10, 2'b11; 2'b00, //all states SO: if (din == 1'b1) I begin nst = $1; y l'b0; end else begin
36 3 3 3 3 37 38 3446 WNTO68L9 39 40 41 42 43 44 55 45 46 47 48 49 50 51 557SWNHOS 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 begin nst = cst; y=1"b0; end s1: if (din = 1'b0) begin nst = S2; y=1'b0; end else begin y=1'b0; nst = cst; end S2: if (din H 1'bl) begin nst S3; y=1'b0; end else begin nst = 50; y=1b0; end $3: if (din begin nst=50; y=1¹b1; 1'60) end else begin nst = $1; y=l'bộ; end I default: nst = 50; endcase
70 71 72 73 74 75 76 77 78 791 80 81 82 default: nst = SO; endcase end always@ (posedge clk) begin I if (reset) cst <=50; else ast <= nst; end endmodule
∞ UNO ARDUINO POWER ANALO wwwww
Design the FSM, Hardware Schematic, and write the code for the following Design the FSM, Hardware Schematic, and write the code for the following question: There are three doors in a room with
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am