need WinCUPL code help

Discussion in 'Programmer's Corner' started by guilty, Oct 11, 2009.

  1. guilty

    guilty Thread Starter New Member

    Joined:
    Oct 11, 2009
    Messages:
    1
    hi, actually , i was a bit confused where to post this, but i decided to post it here in programming section because it is related to program code. so, admin, feel free to move it if this is in the wrong section.

    so, here is my problem, i need to write a program for a counter, 5 bit MUX, and 5 bit DEMUX, and here is my code,

    Code:
    Name     lab 3.2 ;
    PartNo   00 ;
    Date     10/01/2009 ;
    Revision 01 ;
    Designer TEST  ;
    Company  TEST ;
    Assembly None ;
    Location  ;
    Device   G22V10 ;
    /* *************** INPUT PINS *********************/
    PIN 4    = A ; /*input1 mux*/  
    PIN 5    = B ; /*input2 mux*/ 
    PIN 6    = C ; /*input3 mux*/
    PIN 7    = D ; /*input4 mux*/
    PIN 8    = E ; /*input5 mux*/
    PIN 9    = F ; /*input demux*/
    PIN 10   = G ;/*selector 1*/
    PIN 11   = H ; /*selector 2*/
    PIN 13   = I ; /*selector 3*/
     
    
    /* *************** OUTPUT PINS *********************/
    PIN 17    = U ; /*output mux*/ 
    PIN 18    = V ; /*output1 demux*/ 
    PIN 19    = W ; /*output2 demux*/
    PIN 20    = X ; /*output3 demux*/
    PIN 21    = Y ; /*output4 demux*/
    PIN 22    = Z ; /*output5 demux*/
    
    /* *************** FLIP-FLOP ************************/
    Pin 1 = clock;
    Pin 2 = reset;
    Pin 3 = preset;
    
    Pin 14 = Q0; /*output of a flip-flop 1*/
    pin 15 = Q1; /*output of a flip-flop 2*/
    pin 16 = Q2; /*output of a flip-flop 3*/
    /***************** EQUATIONS ***********/
    
    /*** MUX ***/
    U= (A &((G:0)&(H:0) & (I:0))) 
       # (B & ((G:0)& (H:0)& (I:1))) /*if F=0,G=0,H=1 then output O= input k*/
       # (C & ((G:0)& (H:1)& (I:0)))/*if F=0,G=1,H=0 then output O=input L*/
       # (D & ((G:0)& (H:1)& (I:1))) /*if F=0,G=1,H=1 then output O=input M*/
       # (E & ((G:1)& (H:0)& (I:0)));/*if F=1,G=0,H=0 then output O=input N*/
    
    
    /*** DEMUX ***/
    V = (F & ((G:0) & (H:0) & (I:0)));/*if F=0,G=0,H=0 then input I will be sent to output P*/
    W = (F & ((G:0) & (H:0) & (I:1)));/*if F=0,G=1,H=0 then input I will be sent to output Q*/
    X = (F & ((G:0) & (H:1) & (I:0)));
    Y = (F & ((G:0) & (H:1) & (I:1)));
    Z = (F & ((G:1) & (H:0) & (I:0)));
    /***** 1 bit counter to be connected to selector (S) input *****/
    
    field count = [Q2,Q1,Q0];
    $define s0 'b'000/* define the values of the counter bit in */ 
    $define s1 'b'001 /* each of the two counter states*/ 
    $define s2 'b'010
    $define s3 'b'011
    $define s4 'b'100
    count.ar = reset;  /*connect the reset input to counter reset*/ 
    count.sp = preset;  /*connect the preset input to counter preset*/
    
    sequenced count { /*describe the action of the state machine*/
     present s0 default next s1; /* if the current counter output = 0 then next output 1 */
     present s1 default next s2; /*if current counter output = 1 then next output 0*/
     present s2 default next s3;
     present s3 default next s4;
     present s4 default next s0;
    }
    
    it will be connected like this: 5 input to the MUX, all HIGH, and connect the output of the counter to be the selector for the MUX, and the output of the MUX goes to the input of the DEMUX, so, the all the output will be LOW except one HIGH. and the HIGH output will shift to another output one after another every time the clock is pulsed.

    so, i just need to confirm if my code is correct or not... thanks in advance..:)
Similar Threads: need WinCUPL
Forum Title Date
Programmer's Corner large c programming project code examples for microcontrollers needed Jun 23, 2014
Programmer's Corner Need help to solve the program Jun 14, 2014
Programmer's Corner Urgent help needed May 19, 2014
Programmer's Corner Need a simple assembly language base project: Apr 19, 2014
Programmer's Corner I really need help with DDS on the FRDM-KL25z Mbed Jan 12, 2014

Share This Page