Taffs
Newbie level 4
Here is the code I created
It keeps saying that there is an unexpected end just before the end module. I have tried many ways to readjust but still cannot compile. I am a newbie, please help. Thanks
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 module clk_24hours ( output reg[4:0]hr_time, output reg[5:0]min_time, output buzzer_mode, input clk, input [4:0] hr_adv, input[5:0] min_adv, input [1:0] mode, input set_time); input alarm_is_set; output hr_selected, min_selected, ahr_selected, amin_selected; input [1:0] sel1, sel2, sel3, sel4; input [1:0] hr1, hr2, hr3, hr4, hr5, hr6, hr7, hr8, hr9, hr10, hr11, hr12, hr13, hr14, hr15, hr16, hr17, hr18, hr19, hr20, hr21, hr22, hr23; input [1:0] ahr1, ahr2, ahr3, ahr4, ahr5, ahr6, ahr7, ahr8, ahr9, ahr10, ahr11, ahr12, ahr13, ahr14, ahr15, ahr16, ahr17, ahr18, ahr19, ahr20, ahr21, ahr22, ahr23; input [1:0] min1, min2, min3, min4, min5, min6, min7, min8, min9, min10, min11, min12, min13, min14, min15, min16, min17, min18, min19, min20, min21, min22, min23, min24, min25, min26, min27, min28, min29, min30, min31, min32, min33, min34, min35, min36, min37, min38, min39, min40, min41, min42, min43, min44, min45, min46, min47, min48, min49, min50, min51, min52, min53, min54, min55, min56, min57, min58, min59; input [1:0] amin1, amin2, amin3, amin4, amin5, amin6, amin7, amin8, amin9, amin10, amin11, amin12, amin13, amin14, amin15, amin16, amin17, amin18, amin19, amin20, amin21, amin22, amin23, amin24, amin25, amin26, amin27, amin28, amin29, amin30, amin31, amin32, amin33, amin34, amin35, amin36, amin37, amin38, amin39, amin40, amin41, amin42, amin43, amin44, amin45, amin46, amin47, amin48, amin49, amin50, amin51, amin52, amin53, amin54, amin55, amin56, amin57, amin58, amin59; output reg[1:0] select_ed, select_ed1, select_ed2, select_ed3; output reg normal_mode = 2'b00; output reg time_set_mode = 2'b01; output reg alarm_set_mode = 2'b10; output reg alarm_mode = 2'b11; if(alarm_is_set == 1'b1) begin assign mode = alarm_mode; if(alarm_is_set != 1'b1) assign mode = normal_mode; end always@(posedge clk) begin if(mode == normal_mode) //normal mode begin assign min_time = min_selected; min_selected = min_adv; min_adv <= min_adv + 1; if(min_adv == 6'd59) min_adv = 0; else if(min_adv != 6'd59) min_adv <= min_adv + 1; end assign hr_time = hr_selected; hr_time = hr_adv; #60 hr_adv <= hr_adv + 1; if(hr_adv == 5'd23 && min_adv == 6'd59) begin hr_adv = 0; min_adv = 0; mode = normal_mode; end end if(mode == time_set_mode) always @(sel1 or hr1 or hr2 or hr3 or hr4 or hr5 or hr6 or hr7 or hr8 or hr9 or hr10 or hr11 or hr12 or hr13 or hr14 or hr15 or hr16 or hr17 or hr18 or hr19 or hr20 or hr21 or hr22 or hr23) begin case (sel1) 5'd0: select_ed = hr1; 5'd1: select_ed = hr2; 5'd2: select_ed = hr3; 5'd3: select_ed = hr4; 5'd4: select_ed = hr5; 5'd5: select_ed = hr6; 5'd6: select_ed = hr7; 5'd7: select_ed = hr8; 5'd8: select_ed = hr9; 5'd9: select_ed = hr10; 5'd10: select_ed = hr11; 5'd11: select_ed = hr12; 5'd12: select_ed = hr13; 5'd13: select_ed = hr14; 5'd14: select_ed = hr15; 5'd15: select_ed = hr16; 5'd16: select_ed = hr17; 5'd17: select_ed = hr18; 5'd18: select_ed = hr19; 5'd19: select_ed = hr20; 5'd20: select_ed = hr21; 5'd21: select_ed = hr22; 5'd22: select_ed = hr23; endcase hr_selected = sel1; end always @(sel2 or min1 or min2 or min3 or min4 or min5 or min6 or min7 or min8 or min9 or min10 or min11 or min12 or min13 or min14 or min15 or min16 or min17 or min18 or min19 or min20 or min21 or min22 or min23 or min24 or min25 or min26 or min27 or min28 or min29 or min30 or min31 or min32 or min33 or min34 or min35 or min36 or min37 or min38 or min39 or min40 or min41 or min42 or min43 or min44 or min45 or min46 or min47 or min48 or min49 or min50 or min51 or min52 or min53 or min54 or min55 or min56 or min57 or min58 or min59) begin case (sel2) 6'd0: select_ed1 = min1; 6'd1: select_ed1 = min2; 6'd2: select_ed1 = min3; 6'd3: select_ed1 = min4; 6'd4: select_ed1 = min5; 6'd5: select_ed1 = min6; 6'd6: select_ed1 = min7; 6'd7: select_ed1 = min8; 6'd8: select_ed1 = min9; 6'd9: select_ed1 = min10; 6'd10: select_ed1 = min11; 6'd11: select_ed1 = min12; 6'd12: select_ed1 = min13; 6'd13: select_ed1 = min14; 6'd14: select_ed1 = min15; 6'd15: select_ed1 = min16; 6'd16: select_ed1 = min17; 6'd17: select_ed1 = min18; 6'd18: select_ed1 = min19; 6'd19: select_ed1 = min20; 6'd20: select_ed1 = min21; 6'd21: select_ed1 = min22; 6'd22: select_ed1 = min23; 6'd23: select_ed1 = min24; 6'd24: select_ed1 = min25; 6'd25: select_ed1 = min26; 6'd26: select_ed1 = min27; 6'd27: select_ed1 = min28; 6'd28: select_ed1 = min29; 6'd29: select_ed1 = min30; 6'd30: select_ed1 = min31; 6'd31: select_ed1 = min32; 6'd32: select_ed1 = min33; 6'd33: select_ed1 = min34; 6'd34: select_ed1 = min35; 6'd35: select_ed1 = min36; 6'd36: select_ed1 = min37; 6'd37: select_ed1 = min38; 6'd38: select_ed1 = min39; 6'd39: select_ed1 = min40; 6'd40: select_ed1 = min41; 6'd41: select_ed1 = min42; 6'd42: select_ed1 = min43; 6'd43: select_ed1 = min44; 6'd44: select_ed1 = min45; 6'd45: select_ed1 = min46; 6'd46: select_ed1 = min47; 6'd47: select_ed1 = min48; 6'd48: select_ed1 = min49; 6'd49: select_ed1 = min50; 6'd50: select_ed1 = min51; 6'd51: select_ed1 = min52; 6'd52: select_ed1 = min53; 6'd53: select_ed1 = min54; 6'd54: select_ed1 = min55; 6'd55: select_ed1 = min56; 6'd56: select_ed1 = min57; 6'd57: select_ed1 = min58; 6'd58: select_ed1 = min59; endcase min_selected = sel2; end if(mode == alarm_set_mode) always @(sel3 or ahr1 or ahr2 or ahr3 or ahr4 or ahr5 or ahr6 or ahr7 or ahr8 or ahr9 or ahr10 or ahr11 or ahr12 or ahr13 or ahr14 or ahr15 or ahr16 or ahr17 or ahr18 or ahr19 or ahr20 or ahr21 or ahr22 or ahr23) begin case (sel3) 5'd0: select_ed2 = ahr1; 5'd1: select_ed2 = ahr2; 5'd2: select_ed2 = ahr3; 5'd3: select_ed2 = ahr4; 5'd4: select_ed2 = ahr5; 5'd5: select_ed2 = ahr6; 5'd6: select_ed2 = ahr7; 5'd7: select_ed2 = ahr8; 5'd8: select_ed2 = ahr9; 5'd9: select_ed2 = ahr10; 5'd10: select_ed2 = ahr11; 5'd11: select_ed2 = ahr12; 5'd12: select_ed2 = ahr13; 5'd13: select_ed2 = ahr14; 5'd14: select_ed2 = ahr15; 5'd15: select_ed2 = ahr16; 5'd16: select_ed2 = ahr17; 5'd17: select_ed2 = ahr18; 5'd18: select_ed2 = ahr19; 5'd19: select_ed2 = ahr20; 5'd20: select_ed2 = ahr21; 5'd21: select_ed2 = ahr22; 5'd22: select_ed2 = ahr23; endcase ahr_selected = sel3; end always @(sel4 or amin1 or amin2 or amin3 or amin4 or amin5 or amin6 or amin7 or amin8 or amin9 or amin10 or amin11 or amin12 or amin13 or amin14 or amin15 or amin16 or amin17 or amin18 or amin19 or amin20 or amin21 or amin22 or amin23 or amin24 or amin25 or amin26 or amin27 or amin28 or amin29 or amin30 or amin31 or amin32 or amin33 or amin34 or amin35 or amin36 or amin37 or amin38 or amin39 or amin40 or amin41 or amin42 or amin43 or amin44 or amin45 or amin46 or amin47 or amin48 or amin49 or amin50 or amin51 or amin52 or amin53 or amin54 or amin55 or amin56 or amin57 or amin58 or amin59) begin case (sel4) 6'd0: select_ed3 = amin1; 6'd1: select_ed3 = amin2; 6'd2: select_ed3 = amin3; 6'd3: select_ed3 = amin4; 6'd4: select_ed3 = amin5; 6'd5: select_ed3 = amin6; 6'd6: select_ed3 = amin7; 6'd7: select_ed3 = amin8; 6'd8: select_ed3 = amin9; 6'd9: select_ed3 = amin10; 6'd10: select_ed3 = amin11; 6'd11: select_ed3 = amin12; 6'd12: select_ed3 = amin13; 6'd13: select_ed3 = amin14; 6'd14: select_ed3 = amin15; 6'd15: select_ed3 = amin16; 6'd16: select_ed3 = amin17; 6'd17: select_ed3 = amin18; 6'd18: select_ed3 = amin19; 6'd19: select_ed3 = amin20; 6'd20: select_ed3 = amin21; 6'd21: select_ed3 = amin22; 6'd22: select_ed3 = amin23; 6'd23: select_ed3 = amin24; 6'd24: select_ed3 = amin25; 6'd25: select_ed3 = amin26; 6'd26: select_ed3 = amin27; 6'd27: select_ed3 = amin28; 6'd28: select_ed3 = amin29; 6'd29: select_ed3 = amin30; 6'd30: select_ed3 = amin31; 6'd31: select_ed3 = amin32; 6'd32: select_ed3 = amin33; 6'd33: select_ed3 = amin34; 6'd34: select_ed3 = amin35; 6'd35: select_ed3 = amin36; 6'd36: select_ed3 = amin37; 6'd37: select_ed3 = amin38; 6'd38: select_ed3 = amin39; 6'd39: select_ed3 = amin40; 6'd40: select_ed3 = amin41; 6'd41: select_ed3 = amin42; 6'd42: select_ed3 = amin43; 6'd43: select_ed3 = amin44; 6'd44: select_ed3 = amin45; 6'd45: select_ed3 = amin46; 6'd46: select_ed3 = amin47; 6'd47: select_ed3 = amin48; 6'd48: select_ed3 = amin49; 6'd49: select_ed3 = amin50; 6'd50: select_ed3 = amin51; 6'd51: select_ed3 = amin52; 6'd52: select_ed3 = amin53; 6'd53: select_ed3 = amin54; 6'd54: select_ed3 = amin55; 6'd55: select_ed3 = amin56; 6'd56: select_ed3 = amin57; 6'd57: select_ed3 = amin58; 6'd58: select_ed3 = amin59; endcase amin_selected = sel4; end if(mode == alarm_mode) begin if (amin_selected == min_adv && ahr_selected == hr_adv) assign buzzer_mode = 1'b1; else assign buzzer_mode = 1'b0; end end end module
It keeps saying that there is an unexpected end just before the end module. I have tried many ways to readjust but still cannot compile. I am a newbie, please help. Thanks
Last edited by a moderator: