embedded RTOS class project.
Dependencies: C12832_lcd USBDevice mbed-rtos mbed mmSPI_RTOS watchdog_RTOS
Fork of RTOS_project_fork_01 by
mmRTL/counter_08.txt@5:4409ff66b434, 2013-09-18 (annotated)
- Committer:
- gatedClock
- Date:
- Wed Sep 18 14:58:03 2013 +0000
- Revision:
- 5:4409ff66b434
- Parent:
- 0:8e898e1270d6
test results.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gatedClock | 0:8e898e1270d6 | 1 | /*----------------------------------copyright---------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 2 | // licensed for personal and academic use. |
gatedClock | 0:8e898e1270d6 | 3 | // commercial use must be approved by the account-holder of |
gatedClock | 0:8e898e1270d6 | 4 | // gated.clock@gmail.com |
gatedClock | 0:8e898e1270d6 | 5 | /*-----------------------------------module-----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 6 | module counter_08 |
gatedClock | 0:8e898e1270d6 | 7 | ( |
gatedClock | 0:8e898e1270d6 | 8 | oCount, // counter state. |
gatedClock | 0:8e898e1270d6 | 9 | iParallel7, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 10 | iParallel6, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 11 | iParallel5, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 12 | iParallel4, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 13 | iParallel3, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 14 | iParallel2, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 15 | iParallel1, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 16 | iParallel0, // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 17 | iSel, // select the parallel input. |
gatedClock | 0:8e898e1270d6 | 18 | oSerial, // serial-output data. |
gatedClock | 0:8e898e1270d6 | 19 | iSerial, // serial-input data. |
gatedClock | 0:8e898e1270d6 | 20 | iLoadEnable, // parallel-load-enable. |
gatedClock | 0:8e898e1270d6 | 21 | iShiftEnable, // serial-shift-enable. |
gatedClock | 0:8e898e1270d6 | 22 | iCountEnable, // count-increment enable. |
gatedClock | 0:8e898e1270d6 | 23 | iResetN, // synchronous reset*. |
gatedClock | 0:8e898e1270d6 | 24 | iClk // module clock. |
gatedClock | 0:8e898e1270d6 | 25 | ); |
gatedClock | 0:8e898e1270d6 | 26 | /*--------------------------------description----------------------------------- |
gatedClock | 0:8e898e1270d6 | 27 | an 8-bit preloadable counter. |
gatedClock | 0:8e898e1270d6 | 28 | -------------------------------------notes-------------------------------------- |
gatedClock | 0:8e898e1270d6 | 29 | shifting is LSB->MSB. |
gatedClock | 0:8e898e1270d6 | 30 | ------------------------------------defines-----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 31 | /*-----------------------------------ports------------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 32 | output [ 7:0] oCount; // counter state. |
gatedClock | 0:8e898e1270d6 | 33 | input [ 7:0] iParallel7; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 34 | input [ 7:0] iParallel6; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 35 | input [ 7:0] iParallel5; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 36 | input [ 7:0] iParallel4; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 37 | input [ 7:0] iParallel3; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 38 | input [ 7:0] iParallel2; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 39 | input [ 7:0] iParallel1; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 40 | input [ 7:0] iParallel0; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 41 | input [ 2:0] iSel; // select the parallel input. |
gatedClock | 0:8e898e1270d6 | 42 | output oSerial; // serial-output data. |
gatedClock | 0:8e898e1270d6 | 43 | input iSerial; // serial-input data. |
gatedClock | 0:8e898e1270d6 | 44 | input iLoadEnable; // parallel-load-enable. |
gatedClock | 0:8e898e1270d6 | 45 | input iShiftEnable; // serial-shift-enable. |
gatedClock | 0:8e898e1270d6 | 46 | input iCountEnable; // count-increment enable. |
gatedClock | 0:8e898e1270d6 | 47 | input iResetN; // synchronous reset*. |
gatedClock | 0:8e898e1270d6 | 48 | input iClk; // module clock. |
gatedClock | 0:8e898e1270d6 | 49 | /*-----------------------------------wires------------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 50 | wire [ 7:0] oCount; // counter state. |
gatedClock | 0:8e898e1270d6 | 51 | wire [ 7:0] iParallel7; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 52 | wire [ 7:0] iParallel6; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 53 | wire [ 7:0] iParallel5; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 54 | wire [ 7:0] iParallel4; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 55 | wire [ 7:0] iParallel3; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 56 | wire [ 7:0] iParallel2; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 57 | wire [ 7:0] iParallel1; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 58 | wire [ 7:0] iParallel0; // parallel-input data. |
gatedClock | 0:8e898e1270d6 | 59 | wire [ 2:0] iSel; // select the parallel input. |
gatedClock | 0:8e898e1270d6 | 60 | wire [ 7:0] wParallelIn; // select the parallel input. |
gatedClock | 0:8e898e1270d6 | 61 | wire oSerial; // serial-output data. |
gatedClock | 0:8e898e1270d6 | 62 | wire iSerial; // serial-input data. |
gatedClock | 0:8e898e1270d6 | 63 | wire iLoadEnable; // parallel-load-enable. |
gatedClock | 0:8e898e1270d6 | 64 | wire iShiftEnable; // serial-shift-enable. |
gatedClock | 0:8e898e1270d6 | 65 | wire iCountEnable; // count-increment enable. |
gatedClock | 0:8e898e1270d6 | 66 | wire iResetN; // synchronous reset*. |
gatedClock | 0:8e898e1270d6 | 67 | wire iClk; // module clock. |
gatedClock | 0:8e898e1270d6 | 68 | /*---------------------------------registers----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 69 | reg [ 7:0] rRegister; // the counter state. |
gatedClock | 0:8e898e1270d6 | 70 | /*---------------------------------variables----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 71 | /*---------------------------------parameters---------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 72 | /*-----------------------------------clocks-----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 73 | /*---------------------------------instances----------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 74 | mux8x8 U01_mux8x8 // data-input selection. |
gatedClock | 0:8e898e1270d6 | 75 | ( |
gatedClock | 0:8e898e1270d6 | 76 | .iDin7(iParallel7), |
gatedClock | 0:8e898e1270d6 | 77 | .iDin6(iParallel6), |
gatedClock | 0:8e898e1270d6 | 78 | .iDin5(iParallel5), |
gatedClock | 0:8e898e1270d6 | 79 | .iDin4(iParallel4), |
gatedClock | 0:8e898e1270d6 | 80 | .iDin3(iParallel3), |
gatedClock | 0:8e898e1270d6 | 81 | .iDin2(iParallel2), |
gatedClock | 0:8e898e1270d6 | 82 | .iDin1(iParallel1), |
gatedClock | 0:8e898e1270d6 | 83 | .iDin0(iParallel0), |
gatedClock | 0:8e898e1270d6 | 84 | .iSel (iSel), |
gatedClock | 0:8e898e1270d6 | 85 | .oDout(wParallelIn) |
gatedClock | 0:8e898e1270d6 | 86 | ); |
gatedClock | 0:8e898e1270d6 | 87 | /*-----------------------------------logic------------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 88 | always @ (posedge iClk or negedge iResetN) |
gatedClock | 0:8e898e1270d6 | 89 | begin |
gatedClock | 0:8e898e1270d6 | 90 | if (!iResetN) rRegister <= 8'h00; |
gatedClock | 0:8e898e1270d6 | 91 | else if (iLoadEnable) rRegister <= wParallelIn; |
gatedClock | 0:8e898e1270d6 | 92 | else if (iShiftEnable) rRegister <= {rRegister[6:0], iSerial}; |
gatedClock | 0:8e898e1270d6 | 93 | else if (iCountEnable) rRegister <= rRegister + 1'b1; |
gatedClock | 0:8e898e1270d6 | 94 | else rRegister <= rRegister; |
gatedClock | 0:8e898e1270d6 | 95 | end |
gatedClock | 0:8e898e1270d6 | 96 | |
gatedClock | 0:8e898e1270d6 | 97 | assign oCount = rRegister; // propagate counter state. |
gatedClock | 0:8e898e1270d6 | 98 | assign oSerial = rRegister[7]; // propagate serial-out. |
gatedClock | 0:8e898e1270d6 | 99 | /*-------------------------------*/endmodule/*--------------------------------*/ |
gatedClock | 0:8e898e1270d6 | 100 | |
gatedClock | 0:8e898e1270d6 | 101 | |
gatedClock | 0:8e898e1270d6 | 102 | |
gatedClock | 0:8e898e1270d6 | 103 | |
gatedClock | 0:8e898e1270d6 | 104 | |
gatedClock | 0:8e898e1270d6 | 105 | |
gatedClock | 0:8e898e1270d6 | 106 | |
gatedClock | 0:8e898e1270d6 | 107 | |
gatedClock | 0:8e898e1270d6 | 108 | |
gatedClock | 0:8e898e1270d6 | 109 | |
gatedClock | 0:8e898e1270d6 | 110 | |
gatedClock | 0:8e898e1270d6 | 111 | |
gatedClock | 0:8e898e1270d6 | 112 | |
gatedClock | 0:8e898e1270d6 | 113 | |
gatedClock | 0:8e898e1270d6 | 114 | |
gatedClock | 0:8e898e1270d6 | 115 | |
gatedClock | 0:8e898e1270d6 | 116 | |
gatedClock | 0:8e898e1270d6 | 117 | |
gatedClock | 0:8e898e1270d6 | 118 | |
gatedClock | 0:8e898e1270d6 | 119 | |
gatedClock | 0:8e898e1270d6 | 120 | |
gatedClock | 0:8e898e1270d6 | 121 | |
gatedClock | 0:8e898e1270d6 | 122 | |
gatedClock | 0:8e898e1270d6 | 123 | |
gatedClock | 0:8e898e1270d6 | 124 | |
gatedClock | 0:8e898e1270d6 | 125 | |
gatedClock | 0:8e898e1270d6 | 126 | |
gatedClock | 0:8e898e1270d6 | 127 | |
gatedClock | 0:8e898e1270d6 | 128 | |
gatedClock | 0:8e898e1270d6 | 129 | |
gatedClock | 0:8e898e1270d6 | 130 | |
gatedClock | 0:8e898e1270d6 | 131 | |
gatedClock | 0:8e898e1270d6 | 132 |